empty_object 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWUwMmZhNGFmOGQwMDZjMWFiNmJkM2U4MWY2Mzg3M2I4YzYyZTQ5Nw==
5
+ data.tar.gz: !binary |-
6
+ NGRkMDhmZDlkMzBmN2IwMDgzOGNjYTdkZGJhYjM4MTFlMTUxZWM1Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NmJiN2NiMTM4MzMwMDIxNTM0OTQ4ZmViODNmZTBiZmY4MzkwMTBhNTI4ZTYx
10
+ Yjk0NTc2YzlkYWFjMzdlYmMxYWRiMTUxYzljNjFiYmU3N2ZlZTBhMGUxODZk
11
+ ODNmOWUyMDczNjY2MWIxMjExMTQ2OWY0YzQ0YjMwYmFhNzA4NDk=
12
+ data.tar.gz: !binary |-
13
+ MmFmMjFkYmIxZDRjNGM5MDViMDdjYmFmYzY0NWIwMjA2MDM2OGI3MDkzNDJl
14
+ YjUxNzY1NWFiOTU5NjEzMDhjNWVmZTg1MDQ3NGZmOTQzZjA3MmRjN2UwNGI0
15
+ NDYzYmE4ZmQ1NjBlNGZlOTliZTdmY2E5NjMzNzVmYTE4NDA5MmQ=
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Adam Luzsi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ empty_object
2
+ ============
3
+
4
+ EmptyObject is a super cleaned out class inheritance for metaprogramming and DSL making
5
+
6
+ ### Example
7
+
8
+ ```ruby
9
+
10
+ require 'empty_object'
11
+
12
+ class Test < EmptyObject
13
+
14
+ def hello_world obj= nil
15
+ if obj.nil?
16
+ obj= "world"
17
+ end
18
+ ::Kernel.puts("Hello #{obj}!")
19
+ end
20
+
21
+ def method_missing(method, *args)
22
+ #DSL here
23
+ self.hello_world method
24
+ end
25
+
26
+ end
27
+
28
+ test= Test.new
29
+
30
+ test.test
31
+ #> Hello test!
32
+
33
+ test.sup?
34
+ #> Hello sup?!
35
+
36
+ test.woooooooooooooooooooorld!
37
+ #> Hello woooooooooooooooooooorld!!
38
+
39
+ ```
40
+
41
+ Only defined methods are
42
+ * alias
43
+ * __send__
44
+ * object_id
45
+
46
+ Have fun metaprogramming! :)
@@ -0,0 +1 @@
1
+ require File.join "bundler","gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__),"files.rb"))
4
+
5
+ ### Specification for the new Gem
6
+ Gem::Specification.new do |spec|
7
+
8
+ spec.name = "empty_object"
9
+ spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
10
+ spec.authors = ["Adam Luzsi"]
11
+ spec.email = ["adamluzsi@gmail.com"]
12
+ spec.description = %q{ super cleaned out class inheritance for metaprogramming and DSL making }
13
+ spec.summary = %q{ super cleaned out class inheritance for metaprogramming and DSL making }
14
+ spec.homepage = "https://github.com/adamluzsi/empty_object"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = SpecFiles
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ end
@@ -0,0 +1,24 @@
1
+ require_relative "../lib/empty_object"
2
+
3
+ class Test < EmptyObject
4
+
5
+ def hello_world obj= nil
6
+ if obj.nil?
7
+ obj= "world"
8
+ end
9
+ ::Kernel.puts("Hello #{obj}!")
10
+ end
11
+
12
+ def method_missing(method, *args)
13
+ #DSL here
14
+ self.hello_world method
15
+ end
16
+
17
+ end
18
+
19
+ test= Test.new
20
+
21
+ test.test
22
+ test.sup?
23
+ test.woooooooooooooooooooorld!
24
+ test.send
@@ -0,0 +1,24 @@
1
+ ### Get Files from dir
2
+ begin
3
+
4
+ files_to_be_loaded = %w[version.rb]
5
+
6
+ SpecFiles= Array.new
7
+
8
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
9
+ one_file_name = File.expand_path one_file_name
10
+ file_name = one_file_name[(File.expand_path(File.dirname(__FILE__)).to_s.length+1)..(one_file_name.length-1)]
11
+
12
+ if !one_file_name.include?("pkg")
13
+ if !File.directory? file_name
14
+ SpecFiles.push file_name
15
+ STDOUT.puts file_name if $DEBUG
16
+ if files_to_be_loaded.include? one_file_name.split(File::SEPARATOR).last
17
+ load one_file_name
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,7 @@
1
+ class EmptyObject < BasicObject
2
+
3
+ keep_methods = [:object_id, :__send__, :alias]
4
+ remove_methods = self.instance_methods - keep_methods
5
+ remove_methods.each { |m| undef_method m }
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: empty_object
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Luzsi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ! ' super cleaned out class inheritance for metaprogramming and DSL making '
14
+ email:
15
+ - adamluzsi@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - LICENSE
22
+ - README.md
23
+ - Rakefile
24
+ - VERSION
25
+ - empty_object.gemspec
26
+ - examples/sample.rb
27
+ - files.rb
28
+ - lib/empty_object.rb
29
+ homepage: https://github.com/adamluzsi/empty_object
30
+ licenses:
31
+ - MIT
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.2.1
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: super cleaned out class inheritance for metaprogramming and DSL making
53
+ test_files: []
54
+ has_rdoc: