named 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rvmrc
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in named.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Adam Hunter
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Named
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'named'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install named
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/named.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Named
2
+ end
3
+
4
+ require "named/version"
5
+ require 'named/naming'
6
+ require 'named/class'
7
+ require 'named/module'
@@ -0,0 +1,26 @@
1
+ module Named
2
+ module Class
3
+ include Naming
4
+
5
+ def self.new(name, superclass = Object, &block)
6
+ ::Class.new(superclass, &block).tap do |klass|
7
+ klass.extend(ClassMethods)
8
+ klass.send(:include, self)
9
+ klass.name = name
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ include Naming
15
+
16
+ def to_s
17
+ [Named::Class, superclass, name, inspect_object_id].join(':')
18
+ end
19
+ end
20
+
21
+ # implementation from: http://stackoverflow.com/a/2818916/4376
22
+ def to_s
23
+ "#<#{self.class}:#{inspect_object_id}>".sub(":#{self.class.inspect_object_id}", '')
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ module Named
2
+ class Module < ::Module
3
+ include Naming
4
+
5
+ def initialize(name, &block)
6
+ super(&block)
7
+ self.name = name
8
+ end
9
+
10
+ # @returns [String] NamedModule:CustomName:0x00123abc
11
+ def to_s
12
+ [self.class.name, name, inspect_object_id].join(':')
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Named
2
+ module Naming
3
+ attr_accessor :name
4
+
5
+ def inspect_object_id
6
+ "0x00%x" % (object_id << 1)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Named
2
+ VERSION = "1.0.0"
3
+ end
data/named.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'named/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "named"
8
+ spec.version = Named::VERSION
9
+ spec.authors = ["Adam Hunter", "Nathan Long"]
10
+ spec.email = ["adamhunter@me.com", "nathanmlong@gmail.com"]
11
+ spec.description = %q{Give anonymous modules and classes names when they are inspected.}
12
+ spec.summary = %q{Allows providing a name when creating an anonymous module or class using Named::Module.new or Named::Class.new}
13
+ spec.homepage = "https://github.com/adamhunter/named"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rspec", "~> 2.13"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Named::Class do
4
+ it "is a module" do
5
+ expect(Named::Class).to be_a(Module)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Named::Module do
4
+ it "is a class" do
5
+ expect(Named::Module).to be_a(Class)
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'named'
2
+
3
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+
9
+ # Run specs in random order to surface order dependencies. If you find an
10
+ # order dependency and want to debug it, you can fix the order by providing
11
+ # the seed, which is printed after each run.
12
+ # --seed 1234
13
+ config.order = 'random'
14
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: named
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Hunter
9
+ - Nathan Long
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-04-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '2.13'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2.13'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: Give anonymous modules and classes names when they are inspected.
64
+ email:
65
+ - adamhunter@me.com
66
+ - nathanmlong@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - .rspec
73
+ - Gemfile
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - lib/named.rb
78
+ - lib/named/class.rb
79
+ - lib/named/module.rb
80
+ - lib/named/naming.rb
81
+ - lib/named/version.rb
82
+ - named.gemspec
83
+ - spec/named/class_spec.rb
84
+ - spec/named/module_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: https://github.com/adamhunter/named
87
+ licenses:
88
+ - MIT
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -2815502534427764522
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
109
+ - 0
110
+ hash: -2815502534427764522
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 1.8.23
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Allows providing a name when creating an anonymous module or class using
117
+ Named::Module.new or Named::Class.new
118
+ test_files:
119
+ - spec/named/class_spec.rb
120
+ - spec/named/module_spec.rb
121
+ - spec/spec_helper.rb