sixarm_ruby_string_to_class 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ?@�*�&G=P�Ǚ���^y]`5���`���I �����h<�
data/.gemtest ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # SixArm.com » Ruby » <br> String#to_class method to convert a string to a class.
2
+
3
+ * Docs: <http://sixarm.com/sixarm_ruby_string_to_class/doc>
4
+ * Repo: <http://github.com/sixarm/sixarm_ruby_string_to_class>
5
+ * Email: Joel Parker Henderson, <joel@sixarm.com>
6
+
7
+
8
+ ## Introduction
9
+
10
+ Ruby String#to_class method to convert from a String to a class
11
+
12
+ Example:
13
+
14
+ "Foo".to_class #=> Foo class
15
+
16
+ From Mirage at http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/
17
+
18
+
19
+ ## Quickstart
20
+
21
+ Install:
22
+
23
+ gem install sixarm_ruby_string_to_class
24
+
25
+ Bundler:
26
+
27
+ gem "sixarm_ruby_string_to_class", "=1.1.0"
28
+
29
+ Require:
30
+
31
+ require "sixarm_ruby_string_to_class"
32
+
33
+
34
+ ## Install with high security (optional)
35
+
36
+ To enable high security for all our gems:
37
+
38
+ wget http://sixarm.com/sixarm.pem
39
+ gem cert --add sixarm.pem
40
+ gem sources --add http://sixarm.com
41
+
42
+ To install with high security:
43
+
44
+ gem install sixarm_ruby_ --test --trust-policy HighSecurity
45
+
46
+
47
+ ## Examples
48
+
49
+ "Foo".to_class #=> Foo class
50
+ "MyModule::MyClass".to_class #=> MyModule::MyClass class
51
+
52
+
53
+ ## More
54
+
55
+ For docs go to <http://sixarm.com/sixarm_ruby_string_to_class/doc>
56
+
57
+ Want to help? We're happy to get pull requests.
58
+
59
+
60
+
61
+ ## Changes
62
+
63
+ * 2012-03-18 1.1.0 Upgrade for Ruby 1.9.3, minitest/spec, and improved docs.
64
+ * 2011-10-06 1.0.4 Updates for gem publishing
65
+
66
+
67
+ ## License
68
+
69
+ You may choose any of these open source licenses:
70
+
71
+ * Apache License
72
+ * BSD License
73
+ * CreativeCommons License, Non-commercial Share Alike
74
+ * GNU General Public License Version 2 (GPL 2)
75
+ * GNU Lesser General Public License (LGPL)
76
+ * MIT License
77
+ * Perl Artistic License
78
+ * Ruby License
79
+
80
+ The software is provided "as is", without warranty of any kind,
81
+ express or implied, including but not limited to the warranties of
82
+ merchantability, fitness for a particular purpose and noninfringement.
83
+
84
+ In no event shall the authors or copyright holders be liable for any
85
+ claim, damages or other liability, whether in an action of contract,
86
+ tort or otherwise, arising from, out of or in connection with the
87
+ software or the use or other dealings in the software.
88
+
89
+ This license is for the included software that is created by SixArm;
90
+ some of the included software may have its own licenses, copyrights,
91
+ authors, etc. and these do take precedence over the SixArm license.
92
+
93
+ Copyright (c) 2005-2012 Joel Parker Henderson
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib' << 'test'
7
+ t.pattern = 'test/*.rb'
8
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.4
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+
7
+ class String
8
+
9
+ # Ruby String#to_class method to convert from a String to a class
10
+ #
11
+ # From Mirage at http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/
12
+ #
13
+ # @example
14
+ # "Foo::Bar".to_class => Foo::Bar
15
+ #
16
+ # @return [Class] the string converted to a class
17
+
18
+ def to_class
19
+ split('::').inject(Kernel) {|scope, const_name| scope.const_get(const_name)}
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'sixarm_ruby_string_to_class'
6
+
7
+ describe String do
8
+
9
+ describe "#to_class" do
10
+
11
+ it "string to top level class" do
12
+ "A".to_class.must_equal A
13
+ end
14
+
15
+ it "string to module::class" do
16
+ "B::BB".to_class.must_equal B::BB
17
+ end
18
+
19
+ it "string to module::module::class" do
20
+ "C::CC::CCC".to_class.must_equal C::CC::CCC
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ class A
28
+ end
29
+
30
+ module B
31
+ class BB
32
+ end
33
+ end
34
+
35
+ module C
36
+ module CC
37
+ class CCC
38
+ end
39
+ end
40
+ end
41
+
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_string_to_class
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - SixArm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - !binary |-
13
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQW0yZ0F3SUJB
14
+ Z0lKQUtQd0VFVFU1YkhvTUEwR0NTcUdTSWIzRFFFQkJRVUFNR0F4Q3pBSkJn
15
+ TlYKQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZB
16
+ WURWUVFIRXcxVFlXNGdSbkpoYm1OcApjMk52TVE4d0RRWURWUVFLRXdaVGFY
17
+ aEJjbTB4RXpBUkJnTlZCQU1UQ25OcGVHRnliUzVqYjIwd0hoY05NVEF4Ck1q
18
+ RXpNak15TnpFeldoY05NVE13T1RBNE1qTXlOekV6V2pCZ01Rc3dDUVlEVlFR
19
+ R0V3SlZVekVUTUJFR0ExVUUKQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFV
20
+ RUJ4TU5VMkZ1SUVaeVlXNWphWE5qYnpFUE1BMEdBMVVFQ2hNRwpVMmw0UVhK
21
+ dE1STXdFUVlEVlFRREV3cHphWGhoY20wdV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03-20 00:00:00.000000000 Z
39
+ dependencies: []
40
+ description:
41
+ email: sixarm@sixarm.com
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - .gemtest
47
+ - Rakefile
48
+ - README.md
49
+ - VERSION
50
+ - lib/sixarm_ruby_string_to_class.rb
51
+ - test/sixarm_ruby_string_to_class_test.rb
52
+ homepage: http://sixarm.com/
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.19
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: SixArm.com » Ruby » String#to_class method to convert a string to a class.
76
+ test_files:
77
+ - test/sixarm_ruby_string_to_class_test.rb
78
+ has_rdoc: true
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ -��C38N����6�'J�y���z�,� N[\.\l8�F���tPgA��T�hx���`���x]Q���7��� q��,m�rL��8,���.��'���L��y���c,p�Ҹ$���aW,j���Y&q��