thorero 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/History.txt +1 -0
  2. data/LICENSE +20 -0
  3. data/Manifest +45 -0
  4. data/Manifest.txt +29 -0
  5. data/README.txt +3 -0
  6. data/Rakefile +180 -0
  7. data/lib/extlib.rb +32 -0
  8. data/lib/extlib/assertions.rb +8 -0
  9. data/lib/extlib/blank.rb +42 -0
  10. data/lib/extlib/class.rb +175 -0
  11. data/lib/extlib/hash.rb +410 -0
  12. data/lib/extlib/hook.rb +366 -0
  13. data/lib/extlib/inflection.rb +141 -0
  14. data/lib/extlib/lazy_array.rb +106 -0
  15. data/lib/extlib/logger.rb +202 -0
  16. data/lib/extlib/mash.rb +143 -0
  17. data/lib/extlib/module.rb +37 -0
  18. data/lib/extlib/object.rb +165 -0
  19. data/lib/extlib/object_space.rb +13 -0
  20. data/lib/extlib/pathname.rb +5 -0
  21. data/lib/extlib/pooling.rb +233 -0
  22. data/lib/extlib/rubygems.rb +38 -0
  23. data/lib/extlib/simple_set.rb +39 -0
  24. data/lib/extlib/string.rb +132 -0
  25. data/lib/extlib/struct.rb +8 -0
  26. data/lib/extlib/tasks/release.rb +11 -0
  27. data/lib/extlib/time.rb +12 -0
  28. data/lib/extlib/version.rb +3 -0
  29. data/lib/extlib/virtual_file.rb +10 -0
  30. data/spec/blank_spec.rb +85 -0
  31. data/spec/hash_spec.rb +524 -0
  32. data/spec/hook_spec.rb +1198 -0
  33. data/spec/inflection_spec.rb +50 -0
  34. data/spec/lazy_array_spec.rb +896 -0
  35. data/spec/mash_spec.rb +244 -0
  36. data/spec/module_spec.rb +58 -0
  37. data/spec/object_space_spec.rb +9 -0
  38. data/spec/object_spec.rb +98 -0
  39. data/spec/pooling_spec.rb +486 -0
  40. data/spec/simple_set_spec.rb +26 -0
  41. data/spec/spec_helper.rb +8 -0
  42. data/spec/string_spec.rb +200 -0
  43. data/spec/struct_spec.rb +12 -0
  44. data/spec/time_spec.rb +16 -0
  45. data/spec/virtual_file_spec.rb +21 -0
  46. data/thorero.gemspec +147 -0
  47. metadata +146 -0
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Extlib::SimpleSet do
4
+
5
+ before do
6
+ @s = Extlib::SimpleSet.new("Foo")
7
+ end
8
+
9
+ it "should support <<" do
10
+ @s << "Hello"
11
+ @s.should be_include("Hello")
12
+ end
13
+
14
+ it "should support merge" do
15
+ @s.should include("Foo")
16
+ @t = @s.merge(["Bar"])
17
+ @t.should be_kind_of(Extlib::SimpleSet)
18
+ @t.should include("Foo")
19
+ @t.should include("Bar")
20
+ end
21
+
22
+ it "should support inspect" do
23
+ @s.inspect.should == "#<SimpleSet: {\"Foo\"}>"
24
+ end
25
+
26
+ end
@@ -0,0 +1,8 @@
1
+
2
+ $TESTING=true
3
+ require "rubygems"
4
+ require "spec"
5
+ require "yaml"
6
+
7
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'extlib')
8
+
@@ -0,0 +1,200 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+ describe String, "#to_const_string" do
4
+ it "swaps slashes with ::" do
5
+ "foo/bar".to_const_string.should == "Foo::Bar"
6
+ end
7
+
8
+ it "replaces snake_case with CamelCase" do
9
+ "foo/bar/baz_bat".to_const_string.should == "Foo::Bar::BazBat"
10
+ end
11
+
12
+ it "leaves constant string as is" do
13
+ "Merb::Test".to_const_string.should == "Merb::Test"
14
+ end
15
+ end
16
+
17
+
18
+
19
+ describe String, "#to_const_path" do
20
+ it "swaps :: with slash" do
21
+ "Foo::Bar".to_const_path.should == "foo/bar"
22
+ end
23
+
24
+ it "snake_cases string" do
25
+ "Merb::Test::ViewHelper".to_const_path.should == "merb/test/view_helper"
26
+ end
27
+
28
+ it "leaves slash-separated snake case string as is" do
29
+ "merb/test/view_helper".to_const_path.should == "merb/test/view_helper"
30
+ end
31
+ end
32
+
33
+
34
+
35
+ describe String, "#camel_case" do
36
+ it "handles lowercase without underscore" do
37
+ "merb".camel_case.should == "Merb"
38
+ end
39
+
40
+ it "handles lowercase with 1 underscore" do
41
+ "merb_core".camel_case.should == "MerbCore"
42
+ end
43
+
44
+ it "handles lowercase with more than 1 underscore" do
45
+ "so_you_want_contribute_to_merb_core".camel_case.should == "SoYouWantContributeToMerbCore"
46
+ end
47
+
48
+ it "handles lowercase with more than 1 underscore in a row" do
49
+ "__python__is__like__this".camel_case.should == "PythonIsLikeThis"
50
+ end
51
+
52
+ it "handle first capital letter with underscores" do
53
+ "Python__Is__Like__This".camel_case.should == "PythonIsLikeThis"
54
+ end
55
+
56
+ it "leaves CamelCase as is" do
57
+ "TestController".camel_case.should == "TestController"
58
+ end
59
+ end
60
+
61
+
62
+
63
+ describe String, "#snake_case" do
64
+ it "lowercases one word CamelCase" do
65
+ "Merb".snake_case.should == "merb"
66
+ end
67
+
68
+ it "makes one underscore snake_case two word CamelCase" do
69
+ "MerbCore".snake_case.should == "merb_core"
70
+ end
71
+
72
+ it "handles CamelCase with more than 2 words" do
73
+ "SoYouWantContributeToMerbCore".snake_case.should == "so_you_want_contribute_to_merb_core"
74
+ end
75
+
76
+ it "handles CamelCase with more than 2 capital letter in a row" do
77
+ "CNN".snake_case.should == "cnn"
78
+ "CNNNews".snake_case.should == "cnn_news"
79
+ "HeadlineCNNNews".snake_case.should == "headline_cnn_news"
80
+ end
81
+
82
+ it "does NOT change one word lowercase" do
83
+ "merb".snake_case.should == "merb"
84
+ end
85
+
86
+ it "leaves snake_case as is" do
87
+ "merb_core".snake_case.should == "merb_core"
88
+ end
89
+ end
90
+
91
+
92
+
93
+ describe String, "#escape_regexp" do
94
+ it "escapes all * in a string" do
95
+ "*and*".escape_regexp.should == "\\*and\\*"
96
+ end
97
+
98
+ it "escapes all ? in a string" do
99
+ "?and?".escape_regexp.should == "\\?and\\?"
100
+ end
101
+
102
+ it "escapes all { in a string" do
103
+ "{and{".escape_regexp.should == "\\{and\\{"
104
+ end
105
+
106
+ it "escapes all } in a string" do
107
+ "}and}".escape_regexp.should == "\\}and\\}"
108
+ end
109
+
110
+ it "escapes all . in a string" do
111
+ ".and.".escape_regexp.should == "\\.and\\."
112
+ end
113
+
114
+ it "escapes all regexp special characters used in a string" do
115
+ "*?{}.".escape_regexp.should == "\\*\\?\\{\\}\\."
116
+ end
117
+ end
118
+
119
+
120
+
121
+ describe String, "#unescape_regexp" do
122
+ it "unescapes all \\* in a string" do
123
+ "\\*and\\*".unescape_regexp.should == "*and*"
124
+ end
125
+
126
+ it "unescapes all \\? in a string" do
127
+ "\\?and\\?".unescape_regexp.should == "?and?"
128
+ end
129
+
130
+ it "unescapes all \\{ in a string" do
131
+ "\\{and\\{".unescape_regexp.should == "{and{"
132
+ end
133
+
134
+ it "unescapes all \\} in a string" do
135
+ "\\}and\\}".unescape_regexp.should == "}and}"
136
+ end
137
+
138
+ it "unescapes all \\. in a string" do
139
+ "\\.and\\.".unescape_regexp.should == ".and."
140
+ end
141
+
142
+ it "unescapes all regexp special characters used in a string" do
143
+ "\\*\\?\\{\\}\\.".unescape_regexp.should == "*?{}."
144
+ end
145
+ end
146
+
147
+
148
+
149
+ describe String, "#/" do
150
+ it "concanates operands with File::SEPARATOR" do
151
+ ("merb" / "core").should == "merb#{File::SEPARATOR}core"
152
+ end
153
+ end
154
+
155
+
156
+ require 'rbconfig'
157
+ describe String, "#relative_path_from" do
158
+ it "uses other operand as base for path calculation" do
159
+ site_dir = Config::CONFIG["sitedir"]
160
+
161
+ two_levels_up = site_dir.split(File::SEPARATOR)
162
+ 2.times { two_levels_up.pop } # remove two deepest directories
163
+ two_levels_up = File::SEPARATOR + two_levels_up.join(File::SEPARATOR)
164
+
165
+ two_levels_up.relative_path_from(site_dir).should == "../.."
166
+ end
167
+ end
168
+
169
+
170
+ describe String, ".translate" do
171
+ before(:each) do
172
+ String.stub!(:translations).and_return({ "on snakes and rubies" => "a serpenti e rubini" })
173
+ end
174
+
175
+ it 'looks up for translation in translations dictionary' do
176
+ String.translate("on snakes and rubies").should == "a serpenti e rubini"
177
+ end
178
+
179
+ it 'returns string that has no translations as it is' do
180
+ String.translate("shapes").should == "shapes"
181
+ String.translate("kalopsia").should == "kalopsia"
182
+ String.translate("holding on to nothing").should == "holding on to nothing"
183
+ end
184
+ end
185
+
186
+
187
+
188
+ describe String, ".translations" do
189
+ before(:each) do
190
+
191
+ end
192
+
193
+ it 'returns empty hash by default' do
194
+ String.translations.should == {}
195
+ end
196
+
197
+ it 'returns @translations if set' do
198
+ pending "is it @translations on metaclass or @@translations? leaving it out for now"
199
+ end
200
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+ describe Struct do
4
+
5
+ it "should have attributes" do
6
+
7
+ s = Struct.new(:name).new('bob')
8
+ s.attributes.should == { :name => 'bob' }
9
+
10
+ end
11
+
12
+ end
data/spec/time_spec.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'json'
3
+
4
+ describe Time, "#to_json" do
5
+
6
+ before do
7
+ @expected = "\"2008-03-28T22:54:20Z\""
8
+ end
9
+
10
+ it "should transform itself into a ISO 8601 compatible string" do
11
+ Time.utc(2008, 3, 28, 22, 54, 20).to_json.should == @expected
12
+ Time.xmlschema("2008-03-28T22:54:20Z").to_json.should == @expected
13
+ Time.xmlschema("2008-03-28T17:54:20-05:00").to_json.should == @expected
14
+ end
15
+
16
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+ describe VirtualFile do
4
+ it 'inherits from StringIO' do
5
+ VirtualFile.superclass.should == StringIO
6
+ end
7
+
8
+ it 'has path reader' do
9
+ @vf = VirtualFile.new("virtual", "elvenpath")
10
+
11
+ # =~ /#{Dir::tmpdir}/ causes RegExp to fail with nested *?+ on 1.8.6
12
+ @vf.path.should == "elvenpath"
13
+ end
14
+
15
+ it 'has path writer' do
16
+ @vf = VirtualFile.new("virtual", "elvenpath")
17
+
18
+ @vf.path = "newbase"
19
+ @vf.path.should == "newbase"
20
+ end
21
+ end
data/thorero.gemspec ADDED
@@ -0,0 +1,147 @@
1
+
2
+ # Gem::Specification for Thorero-0.9.4
3
+ # Originally generated by Echoe
4
+
5
+ --- !ruby/object:Gem::Specification
6
+ name: thorero
7
+ version: !ruby/object:Gem::Version
8
+ version: 0.9.4
9
+ platform: ruby
10
+ authors:
11
+ - Test Test
12
+ autorequire:
13
+ bindir: bin
14
+
15
+ date: 2008-08-01 00:00:00 +03:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: english
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ version:
28
+ - !ruby/object:Gem::Dependency
29
+ name: echoe
30
+ type: :development
31
+ version_requirement:
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: "0"
37
+ version:
38
+ description: Support Library for DataMapper and DataObjects
39
+ email: test.test@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - lib/extlib/assertions.rb
46
+ - lib/extlib/blank.rb
47
+ - lib/extlib/class.rb
48
+ - lib/extlib/hash.rb
49
+ - lib/extlib/hook.rb
50
+ - lib/extlib/inflection.rb
51
+ - lib/extlib/lazy_array.rb
52
+ - lib/extlib/logger.rb
53
+ - lib/extlib/mash.rb
54
+ - lib/extlib/module.rb
55
+ - lib/extlib/object.rb
56
+ - lib/extlib/object_space.rb
57
+ - lib/extlib/pathname.rb
58
+ - lib/extlib/pooling.rb
59
+ - lib/extlib/rubygems.rb
60
+ - lib/extlib/simple_set.rb
61
+ - lib/extlib/string.rb
62
+ - lib/extlib/struct.rb
63
+ - lib/extlib/tasks/release.rb
64
+ - lib/extlib/time.rb
65
+ - lib/extlib/version.rb
66
+ - lib/extlib/virtual_file.rb
67
+ - lib/extlib.rb
68
+ - LICENSE
69
+ - README.txt
70
+ files:
71
+ - History.txt
72
+ - lib/extlib/assertions.rb
73
+ - lib/extlib/blank.rb
74
+ - lib/extlib/class.rb
75
+ - lib/extlib/hash.rb
76
+ - lib/extlib/hook.rb
77
+ - lib/extlib/inflection.rb
78
+ - lib/extlib/lazy_array.rb
79
+ - lib/extlib/logger.rb
80
+ - lib/extlib/mash.rb
81
+ - lib/extlib/module.rb
82
+ - lib/extlib/object.rb
83
+ - lib/extlib/object_space.rb
84
+ - lib/extlib/pathname.rb
85
+ - lib/extlib/pooling.rb
86
+ - lib/extlib/rubygems.rb
87
+ - lib/extlib/simple_set.rb
88
+ - lib/extlib/string.rb
89
+ - lib/extlib/struct.rb
90
+ - lib/extlib/tasks/release.rb
91
+ - lib/extlib/time.rb
92
+ - lib/extlib/version.rb
93
+ - lib/extlib/virtual_file.rb
94
+ - lib/extlib.rb
95
+ - LICENSE
96
+ - Manifest.txt
97
+ - Rakefile
98
+ - README.txt
99
+ - spec/blank_spec.rb
100
+ - spec/hash_spec.rb
101
+ - spec/hook_spec.rb
102
+ - spec/inflection_spec.rb
103
+ - spec/lazy_array_spec.rb
104
+ - spec/mash_spec.rb
105
+ - spec/module_spec.rb
106
+ - spec/object_space_spec.rb
107
+ - spec/object_spec.rb
108
+ - spec/pooling_spec.rb
109
+ - spec/simple_set_spec.rb
110
+ - spec/spec_helper.rb
111
+ - spec/string_spec.rb
112
+ - spec/struct_spec.rb
113
+ - spec/time_spec.rb
114
+ - spec/virtual_file_spec.rb
115
+ - Manifest
116
+ - thorero.gemspec
117
+ has_rdoc: false
118
+ homepage: http://thorero.rubyforge.org
119
+ post_install_message:
120
+ rdoc_options:
121
+ - --line-numbers
122
+ - --inline-source
123
+ - --title
124
+ - Thorero
125
+ - --main
126
+ - README.txt
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ version:
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "="
138
+ - !ruby/object:Gem::Version
139
+ version: "1.2"
140
+ version:
141
+ requirements: []
142
+
143
+ rubyforge_project: thorero
144
+ rubygems_version: 1.2.0
145
+ specification_version: 2
146
+ summary: Support Library for DataMapper and DataObjects
147
+ test_files: []
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thorero
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.4
5
+ platform: ruby
6
+ authors:
7
+ - Test Test
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-01 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: english
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: echoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Support Library for DataMapper and DataObjects
36
+ email: test.test@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - lib/extlib/assertions.rb
43
+ - lib/extlib/blank.rb
44
+ - lib/extlib/class.rb
45
+ - lib/extlib/hash.rb
46
+ - lib/extlib/hook.rb
47
+ - lib/extlib/inflection.rb
48
+ - lib/extlib/lazy_array.rb
49
+ - lib/extlib/logger.rb
50
+ - lib/extlib/mash.rb
51
+ - lib/extlib/module.rb
52
+ - lib/extlib/object.rb
53
+ - lib/extlib/object_space.rb
54
+ - lib/extlib/pathname.rb
55
+ - lib/extlib/pooling.rb
56
+ - lib/extlib/rubygems.rb
57
+ - lib/extlib/simple_set.rb
58
+ - lib/extlib/string.rb
59
+ - lib/extlib/struct.rb
60
+ - lib/extlib/tasks/release.rb
61
+ - lib/extlib/time.rb
62
+ - lib/extlib/version.rb
63
+ - lib/extlib/virtual_file.rb
64
+ - lib/extlib.rb
65
+ - LICENSE
66
+ - README.txt
67
+ files:
68
+ - History.txt
69
+ - lib/extlib/assertions.rb
70
+ - lib/extlib/blank.rb
71
+ - lib/extlib/class.rb
72
+ - lib/extlib/hash.rb
73
+ - lib/extlib/hook.rb
74
+ - lib/extlib/inflection.rb
75
+ - lib/extlib/lazy_array.rb
76
+ - lib/extlib/logger.rb
77
+ - lib/extlib/mash.rb
78
+ - lib/extlib/module.rb
79
+ - lib/extlib/object.rb
80
+ - lib/extlib/object_space.rb
81
+ - lib/extlib/pathname.rb
82
+ - lib/extlib/pooling.rb
83
+ - lib/extlib/rubygems.rb
84
+ - lib/extlib/simple_set.rb
85
+ - lib/extlib/string.rb
86
+ - lib/extlib/struct.rb
87
+ - lib/extlib/tasks/release.rb
88
+ - lib/extlib/time.rb
89
+ - lib/extlib/version.rb
90
+ - lib/extlib/virtual_file.rb
91
+ - lib/extlib.rb
92
+ - LICENSE
93
+ - Manifest.txt
94
+ - Rakefile
95
+ - README.txt
96
+ - spec/blank_spec.rb
97
+ - spec/hash_spec.rb
98
+ - spec/hook_spec.rb
99
+ - spec/inflection_spec.rb
100
+ - spec/lazy_array_spec.rb
101
+ - spec/mash_spec.rb
102
+ - spec/module_spec.rb
103
+ - spec/object_space_spec.rb
104
+ - spec/object_spec.rb
105
+ - spec/pooling_spec.rb
106
+ - spec/simple_set_spec.rb
107
+ - spec/spec_helper.rb
108
+ - spec/string_spec.rb
109
+ - spec/struct_spec.rb
110
+ - spec/time_spec.rb
111
+ - spec/virtual_file_spec.rb
112
+ - Manifest
113
+ - thorero.gemspec
114
+ has_rdoc: false
115
+ homepage: http://thorero.rubyforge.org
116
+ post_install_message:
117
+ rdoc_options:
118
+ - --line-numbers
119
+ - --inline-source
120
+ - --title
121
+ - Thorero
122
+ - --main
123
+ - README.txt
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: "0"
131
+ version:
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "="
135
+ - !ruby/object:Gem::Version
136
+ version: "1.2"
137
+ version:
138
+ requirements: []
139
+
140
+ rubyforge_project: thorero
141
+ rubygems_version: 1.2.0
142
+ signing_key:
143
+ specification_version: 2
144
+ summary: Support Library for DataMapper and DataObjects
145
+ test_files: []
146
+