opal-singleton 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ /build
@@ -0,0 +1,13 @@
1
+ require 'opal'
2
+
3
+ desc 'Build specified dependencies to build dir'
4
+ task :dependencies do
5
+ Opal::DependencyBuilder.new(out: 'build').build
6
+ end
7
+
8
+ desc 'Build latest opal-singleton to build dir'
9
+ task :build => :dependencies do
10
+ Opal::Builder.new(out: 'build/opal-singleton.js').build
11
+ end
12
+
13
+ task :default => :build
@@ -0,0 +1,37 @@
1
+ #--
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
6
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7
+ #
8
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
+ #++
10
+
11
+ module Singleton
12
+ def clone
13
+ raise TypeError, "can't clone instance of singleton #{self.class}"
14
+ end
15
+
16
+ def dup
17
+ raise TypeError, "can't dup instance of singleton #{self.class}"
18
+ end
19
+
20
+ def self.included(klass)
21
+ super
22
+
23
+ class << klass
24
+ def new
25
+ raise ArgumentError, "you can't call #new on a Singleton" if @instance
26
+
27
+ @instance = super
28
+ end
29
+
30
+ undef_method :allocate
31
+
32
+ def instance
33
+ @instance ||= new()
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new {|s|
2
+ s.name = 'opal-singleton'
3
+ s.version = '0.0.1'
4
+ s.author = 'meh.'
5
+ s.email = 'meh@paranoici.org'
6
+ s.homepage = 'http://github.com/opal/opal-singleton'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.summary = 'Opal implementation of singleton'
9
+
10
+ s.files = `git ls-files`.split("\n")
11
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.require_paths = ['lib']
14
+ }
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opal-singleton
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - meh.
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email: meh@paranoici.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - Rakefile
22
+ - lib/opal/singleton.rb
23
+ - opal-singleton.gemspec
24
+ homepage: http://github.com/opal/opal-singleton
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.10
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Opal implementation of singleton
48
+ test_files: []