symbolism 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ *.sw?
2
+ .rvmrc
3
+ *.gem
@@ -0,0 +1,14 @@
1
+ # Symbolism
2
+
3
+ Convert a class to a symbol, and a symbol to a class.
4
+
5
+ ## Installation
6
+
7
+ # gem install symbolism
8
+
9
+ ## Usage
10
+
11
+ After requiring symbolism in your project, You can now convert _any_ symbol to a class, and _any_ class to a symbol.
12
+
13
+ String.to_sym #==> :string
14
+ :string.to_class #==> String
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,8 @@
1
+ Feature: Converting a class to a symbol
2
+
3
+ Scenario: Calling `to_sym` on a class
4
+ Given a class
5
+ When I call to_sym on it
6
+ Then I should receive the symbolized version of that class name
7
+ When I call to_class on that symbol
8
+ Then I should receive the original class back
@@ -0,0 +1,18 @@
1
+ Given /^a class$/ do
2
+ end
3
+
4
+ When /^I call to_sym on it$/ do
5
+ @sym = String.to_sym
6
+ end
7
+
8
+ Then /^I should receive the symbolized version of that class name$/ do
9
+ @sym.should == :string
10
+ end
11
+
12
+ When /^I call to_class on that symbol$/ do
13
+ @class = @sym.to_class
14
+ end
15
+
16
+ Then /^I should receive the original class back$/ do
17
+ @class.should == String
18
+ end
@@ -0,0 +1,19 @@
1
+ Given /^a symbol$/ do
2
+ @sym = :object
3
+ end
4
+
5
+ When /^I call to_class on it$/ do
6
+ @class = @sym.to_class
7
+ end
8
+
9
+ Then /^I should receive the class name that the symbol represented$/ do
10
+ @class.should == Object
11
+ end
12
+
13
+ When /^I call to_sym on that class$/ do
14
+ @sym = @class.to_sym
15
+ end
16
+
17
+ Then /^I should receive the original symbol back$/ do
18
+ @sym.should == :object
19
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift './lib'
2
+
3
+ require 'active_support/core_ext/string'
4
+ require 'symbolism'
@@ -0,0 +1,8 @@
1
+ Feature: Converting a symbol to a class
2
+
3
+ Scenario: Calling `to_class` on a symbol
4
+ Given a symbol
5
+ When I call to_class on it
6
+ Then I should receive the class name that the symbol represented
7
+ When I call to_sym on that class
8
+ Then I should receive the original symbol back
@@ -0,0 +1,2 @@
1
+ require 'symbolism/class'
2
+ require 'symbolism/symbol'
@@ -0,0 +1,13 @@
1
+ module Symbolism
2
+ module Conversions
3
+ module Symbol
4
+ def to_class
5
+ self.to_s.camelize.constantize
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ class Symbol
12
+ include Symbolism::Conversions::Symbol
13
+ end
@@ -0,0 +1,17 @@
1
+ module Symbolism
2
+ module Conversions
3
+ module Class
4
+ def to_sym
5
+ self.to_s.underscore.to_sym
6
+ end
7
+
8
+ def to_class
9
+ self
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ class Class
16
+ include Symbolism::Conversions::Class
17
+ end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{symbolism}
3
+ s.version = File.read "VERSION"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Matt Parker"]
7
+ s.date = %q{2011-02-23}
8
+ s.description = %q{Converts classes to symbols, and symbols to classes.}
9
+ s.email = %q{moonmaster9000@gmail.com}
10
+ s.extra_rdoc_files = [
11
+ "README.markdown"
12
+ ]
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+
18
+ s.homepage = %q{http://github.com/moonmaster9000/symbolism}
19
+ s.require_paths = ["lib"]
20
+ s.rubygems_version = %q{1.5.0}
21
+ s.summary = %q{Converts classes to symbols, and symbols to classes.}
22
+
23
+ s.add_dependency(%q<activesupport>, ["~> 3.0"])
24
+ s.add_dependency(%q<i18n>, ["~> 0.5.0"])
25
+ s.add_development_dependency(%q<cucumber>, ["~> 0.10.0"])
26
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: symbolism
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Matt Parker
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-23 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 3
32
+ - 0
33
+ version: "3.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: i18n
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 11
45
+ segments:
46
+ - 0
47
+ - 5
48
+ - 0
49
+ version: 0.5.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: cucumber
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 55
61
+ segments:
62
+ - 0
63
+ - 10
64
+ - 0
65
+ version: 0.10.0
66
+ type: :development
67
+ version_requirements: *id003
68
+ description: Converts classes to symbols, and symbols to classes.
69
+ email: moonmaster9000@gmail.com
70
+ executables: []
71
+
72
+ extensions: []
73
+
74
+ extra_rdoc_files:
75
+ - README.markdown
76
+ files:
77
+ - .gitignore
78
+ - README.markdown
79
+ - VERSION
80
+ - features/class.feature
81
+ - features/step_definitions/class_steps.rb
82
+ - features/step_definitions/symbol_steps.rb
83
+ - features/support/env.rb
84
+ - features/symbol.feature
85
+ - lib/symbolism.rb
86
+ - lib/symbolism/class.rb
87
+ - lib/symbolism/symbol.rb
88
+ - symbolism.gemspec
89
+ has_rdoc: true
90
+ homepage: http://github.com/moonmaster9000/symbolism
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options: []
95
+
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirements: []
117
+
118
+ rubyforge_project:
119
+ rubygems_version: 1.5.0
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Converts classes to symbols, and symbols to classes.
123
+ test_files:
124
+ - features/class.feature
125
+ - features/step_definitions/class_steps.rb
126
+ - features/step_definitions/symbol_steps.rb
127
+ - features/support/env.rb
128
+ - features/symbol.feature