Remove singleton code sample, update gemfile

This commit is contained in:
Josh Lockhart
2016-11-19 17:29:12 -05:00
parent 2c7e510017
commit efbcbf5de2
3 changed files with 91 additions and 132 deletions

View File

@@ -1,2 +1,3 @@
source 'https://rubygems.org'
gem 'github-pages'
gem 'rouge'

View File

@@ -2,125 +2,146 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
activesupport (4.2.5.1)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.8)
addressable (2.4.0)
blankslate (2.1.2.4)
classifier-reborn (2.0.4)
fast-stemmer (~> 1.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
colorator (0.1)
ethon (0.8.1)
concurrent-ruby (1.0.2)
ethon (0.9.1)
ffi (>= 1.3.0)
execjs (2.6.0)
faraday (0.9.2)
execjs (2.7.0)
faraday (0.10.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.10)
fast-stemmer (1.0.2)
ffi (1.9.14)
ffi (1.9.14-x64-mingw32)
gemoji (2.1.0)
github-pages (48)
github-pages (39)
RedCloth (= 4.2.9)
github-pages-health-check (= 0.6.1)
jekyll (= 3.0.3)
github-pages-health-check (~> 0.2)
jekyll (= 2.4.0)
jekyll-coffeescript (= 1.0.1)
jekyll-feed (= 0.3.1)
jekyll-gist (= 1.4.0)
jekyll-mentions (= 1.0.0)
jekyll-paginate (= 1.1.0)
jekyll-redirect-from (= 0.9.1)
jekyll-mentions (= 0.2.1)
jekyll-redirect-from (= 0.8.0)
jekyll-sass-converter (= 1.3.0)
jekyll-seo-tag (= 1.0.0)
jekyll-sitemap (= 0.10.0)
jekyll-textile-converter (= 0.1.0)
jemoji (= 0.5.1)
kramdown (= 1.9.0)
liquid (= 3.0.6)
jekyll-sitemap (= 0.8.1)
jemoji (= 0.5.0)
kramdown (= 1.5.0)
liquid (= 2.6.2)
maruku (= 0.7.0)
mercenary (~> 0.3)
rdiscount (= 2.1.8)
redcarpet (= 3.3.3)
rouge (= 1.10.1)
pygments.rb (= 0.6.3)
rdiscount (= 2.1.7)
redcarpet (= 3.3.2)
terminal-table (~> 1.4)
github-pages-health-check (0.6.1)
addressable (~> 2.3)
net-dns (~> 0.8)
github-pages-health-check (0.3.2)
net-dns (~> 0.6)
public_suffix (~> 1.4)
typhoeus (~> 0.7)
html-pipeline (2.3.0)
activesupport (>= 2, < 5)
nokogiri (>= 1.4)
html-pipeline (1.9.0)
activesupport (>= 2)
nokogiri (~> 1.4)
i18n (0.7.0)
jekyll (3.0.3)
jekyll (2.4.0)
classifier-reborn (~> 2.0)
colorator (~> 0.1)
jekyll-coffeescript (~> 1.0)
jekyll-gist (~> 1.0)
jekyll-paginate (~> 1.0)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 3.0)
liquid (~> 2.6.1)
mercenary (~> 0.3.3)
rouge (~> 1.7)
pygments.rb (~> 0.6.0)
redcarpet (~> 3.1)
safe_yaml (~> 1.0)
toml (~> 0.1.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-feed (0.3.1)
jekyll-gist (1.4.0)
octokit (~> 4.2)
jekyll-mentions (1.0.0)
html-pipeline (~> 2.2)
jekyll (~> 3.0)
jekyll-mentions (0.2.1)
html-pipeline (~> 1.9.0)
jekyll (~> 2.0)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.9.1)
jekyll-redirect-from (0.8.0)
jekyll (>= 2.0)
jekyll-sass-converter (1.3.0)
sass (~> 3.2)
jekyll-seo-tag (1.0.0)
jekyll (>= 2.0)
jekyll-sitemap (0.10.0)
jekyll-textile-converter (0.1.0)
RedCloth (~> 4.0)
jekyll-watch (1.3.1)
listen (~> 3.0)
jemoji (0.5.1)
jekyll-sitemap (0.8.1)
jekyll-watch (1.5.0)
listen (~> 3.0, < 3.1)
jemoji (0.5.0)
gemoji (~> 2.0)
html-pipeline (~> 2.2)
html-pipeline (~> 1.9)
jekyll (>= 2.0)
json (1.8.3)
kramdown (1.9.0)
liquid (3.0.6)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
mercenary (0.3.5)
mini_portile2 (2.0.0)
minitest (5.8.4)
kramdown (1.5.0)
liquid (2.6.2)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
maruku (0.7.0)
mercenary (0.3.6)
mini_portile2 (2.1.0)
minitest (5.9.1)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
octokit (4.2.0)
sawyer (~> 0.6.0, >= 0.5.3)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
nokogiri (1.6.8.1-x64-mingw32)
mini_portile2 (~> 2.1.0)
octokit (4.6.1)
sawyer (~> 0.8.0, >= 0.5.3)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.12)
public_suffix (1.5.3)
rb-fsevent (0.9.7)
pygments.rb (0.6.3)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.2.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdiscount (2.1.8)
redcarpet (3.3.3)
rouge (1.10.1)
rdiscount (2.1.7)
redcarpet (3.3.2)
rouge (2.0.7)
safe_yaml (1.0.4)
sass (3.4.21)
sawyer (0.6.0)
addressable (~> 2.3.5)
faraday (~> 0.8, < 0.10)
terminal-table (1.5.2)
sass (3.4.22)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.5)
toml (0.1.2)
parslet (~> 1.5.0)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.1.1)
yajl-ruby (1.2.1)
PLATFORMS
ruby
x64-mingw32
DEPENDENCIES
github-pages
rouge
BUNDLED WITH
1.13.6

View File

@@ -68,70 +68,7 @@ yourself a lot of trouble down the road by using factories.
When designing web applications, it often makes sense conceptually and architecturally to allow access to one and only
one instance of a particular class. The singleton pattern enables us to do this.
{% highlight php %}
<?php
class Singleton
{
/**
* @var Singleton The reference to *Singleton* instance of this class
*/
private static $instance;
/**
* Returns the *Singleton* instance of this class.
*
* @return Singleton The *Singleton* instance.
*/
public static function getInstance()
{
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
/**
* Protected constructor to prevent creating a new instance of the
* *Singleton* via the `new` operator from outside of this class.
*/
protected function __construct()
{
}
/**
* Private clone method to prevent cloning of the instance of the
* *Singleton* instance.
*
* @return void
*/
private function __clone()
{
}
/**
* Private unserialize method to prevent unserializing of the *Singleton*
* instance.
*
* @return void
*/
private function __wakeup()
{
}
}
class SingletonChild extends Singleton
{
}
$obj = Singleton::getInstance();
var_dump($obj === Singleton::getInstance()); // bool(true)
$anotherObj = SingletonChild::getInstance();
var_dump($anotherObj === Singleton::getInstance()); // bool(false)
var_dump($anotherObj === SingletonChild::getInstance()); // bool(true)
{% endhighlight %}
**TODO: NEED NEW SINGLETON CODE EXAMPLE**
The code above implements the singleton pattern using a [*static* variable](http://php.net/language.variables.scope#language.variables.scope.static) and the static creation method `getInstance()`.
Note the following: