gorillib 0.4.0pre → 0.4.1pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/CHANGELOG.md +36 -1
  2. data/Gemfile +23 -19
  3. data/Guardfile +1 -1
  4. data/Rakefile +31 -31
  5. data/TODO.md +2 -30
  6. data/VERSION +1 -1
  7. data/examples/builder/ironfan.rb +4 -4
  8. data/gorillib.gemspec +40 -25
  9. data/lib/gorillib/array/average.rb +13 -0
  10. data/lib/gorillib/array/sorted_median.rb +11 -0
  11. data/lib/gorillib/array/sorted_percentile.rb +11 -0
  12. data/lib/gorillib/array/sorted_sample.rb +12 -0
  13. data/lib/gorillib/builder.rb +8 -14
  14. data/lib/gorillib/collection/has_collection.rb +31 -31
  15. data/lib/gorillib/collection/list_collection.rb +58 -0
  16. data/lib/gorillib/collection/model_collection.rb +63 -0
  17. data/lib/gorillib/collection.rb +57 -85
  18. data/lib/gorillib/logger/log.rb +26 -22
  19. data/lib/gorillib/model/base.rb +52 -39
  20. data/lib/gorillib/model/doc_string.rb +15 -0
  21. data/lib/gorillib/model/factories.rb +56 -61
  22. data/lib/gorillib/model/lint.rb +24 -0
  23. data/lib/gorillib/model/serialization.rb +12 -2
  24. data/lib/gorillib/model/validate.rb +2 -2
  25. data/lib/gorillib/pathname.rb +21 -6
  26. data/lib/gorillib/some.rb +2 -0
  27. data/lib/gorillib/type/extended.rb +0 -2
  28. data/lib/gorillib/type/url.rb +9 -0
  29. data/lib/gorillib/utils/console.rb +4 -1
  30. data/notes/HOWTO.md +22 -0
  31. data/notes/bucket.md +155 -0
  32. data/notes/builder.md +170 -0
  33. data/notes/collection.md +81 -0
  34. data/notes/factories.md +86 -0
  35. data/notes/model-overlay.md +209 -0
  36. data/notes/model.md +135 -0
  37. data/notes/structured-data-classes.md +127 -0
  38. data/spec/array/average_spec.rb +24 -0
  39. data/spec/array/sorted_median_spec.rb +18 -0
  40. data/spec/array/sorted_percentile_spec.rb +24 -0
  41. data/spec/array/sorted_sample_spec.rb +28 -0
  42. data/spec/gorillib/builder_spec.rb +46 -28
  43. data/spec/gorillib/collection_spec.rb +195 -10
  44. data/spec/gorillib/model/lint_spec.rb +28 -0
  45. data/spec/gorillib/model/record/factories_spec.rb +27 -13
  46. data/spec/gorillib/model/serialization_spec.rb +3 -5
  47. data/spec/gorillib/model_spec.rb +86 -104
  48. data/spec/spec_helper.rb +2 -1
  49. data/spec/support/gorillib_test_helpers.rb +83 -7
  50. data/spec/support/model_test_helpers.rb +9 -28
  51. metadata +52 -44
  52. data/lib/gorillib/configurable.rb +0 -28
  53. data/spec/gorillib/configurable_spec.rb +0 -62
  54. data/spec/support/shared_examples/included_module.rb +0 -20
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorillib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0pre
4
+ version: 0.4.1pre
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,74 +9,63 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000Z
12
+ date: 2012-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &2159487420 !ruby/object:Gem::Requirement
16
+ requirement: &70333747262840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2159487420
24
+ version_requirements: *70333747262840
25
25
  - !ruby/object:Gem::Dependency
26
- name: json
27
- requirement: &2159486860 !ruby/object:Gem::Requirement
26
+ name: bundler
27
+ requirement: &70333747262300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
32
+ version: '1.1'
33
+ type: :development
34
34
  prerelease: false
35
- version_requirements: *2159486860
35
+ version_requirements: *70333747262300
36
36
  - !ruby/object:Gem::Dependency
37
- name: configliere
38
- requirement: &2159486180 !ruby/object:Gem::Requirement
37
+ name: rake
38
+ requirement: &70333747261280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.4.13
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *2159486180
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: &2159485700 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '1'
43
+ version: '0'
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *2159485700
46
+ version_requirements: *70333747261280
58
47
  - !ruby/object:Gem::Dependency
59
- name: pry
60
- requirement: &2159485080 !ruby/object:Gem::Requirement
48
+ name: oj
49
+ requirement: &70333747260520 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
64
53
  - !ruby/object:Gem::Version
65
- version: '0'
54
+ version: '1.2'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *2159485080
57
+ version_requirements: *70333747260520
69
58
  - !ruby/object:Gem::Dependency
70
- name: jeweler
71
- requirement: &2159484400 !ruby/object:Gem::Requirement
59
+ name: json
60
+ requirement: &70333747259920 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
- - - ~>
63
+ - - ! '>='
75
64
  - !ruby/object:Gem::Version
76
- version: '1.6'
65
+ version: '0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *2159484400
68
+ version_requirements: *70333747259920
80
69
  description: ! 'Gorillib: infochimps lightweight subset of ruby convenience methods'
81
70
  email: coders@infochimps.org
82
71
  executables: []
@@ -101,17 +90,22 @@ files:
101
90
  - gorillib.gemspec
102
91
  - lib/alt/kernel/call_stack.rb
103
92
  - lib/gorillib.rb
93
+ - lib/gorillib/array/average.rb
104
94
  - lib/gorillib/array/compact_blank.rb
105
95
  - lib/gorillib/array/deep_compact.rb
106
96
  - lib/gorillib/array/extract_options.rb
107
97
  - lib/gorillib/array/random.rb
98
+ - lib/gorillib/array/sorted_median.rb
99
+ - lib/gorillib/array/sorted_percentile.rb
100
+ - lib/gorillib/array/sorted_sample.rb
108
101
  - lib/gorillib/array/wrap.rb
109
102
  - lib/gorillib/base.rb
110
103
  - lib/gorillib/builder.rb
111
104
  - lib/gorillib/builder/field.rb
112
105
  - lib/gorillib/collection.rb
113
106
  - lib/gorillib/collection/has_collection.rb
114
- - lib/gorillib/configurable.rb
107
+ - lib/gorillib/collection/list_collection.rb
108
+ - lib/gorillib/collection/model_collection.rb
115
109
  - lib/gorillib/datetime/parse.rb
116
110
  - lib/gorillib/datetime/to_flat.rb
117
111
  - lib/gorillib/enumerable/sum.rb
@@ -150,9 +144,11 @@ files:
150
144
  - lib/gorillib/model/active_model_shim.rb
151
145
  - lib/gorillib/model/base.rb
152
146
  - lib/gorillib/model/defaults.rb
147
+ - lib/gorillib/model/doc_string.rb
153
148
  - lib/gorillib/model/errors.rb
154
149
  - lib/gorillib/model/factories.rb
155
150
  - lib/gorillib/model/field.rb
151
+ - lib/gorillib/model/lint.rb
156
152
  - lib/gorillib/model/named_schema.rb
157
153
  - lib/gorillib/model/overlay.rb
158
154
  - lib/gorillib/model/record_schema.rb
@@ -172,10 +168,23 @@ files:
172
168
  - lib/gorillib/string/simple_inflector.rb
173
169
  - lib/gorillib/string/truncate.rb
174
170
  - lib/gorillib/type/extended.rb
171
+ - lib/gorillib/type/url.rb
175
172
  - lib/gorillib/utils/capture_output.rb
176
173
  - lib/gorillib/utils/console.rb
177
174
  - lib/gorillib/utils/nuke_constants.rb
178
175
  - lib/gorillib/utils/stub_module.rb
176
+ - notes/HOWTO.md
177
+ - notes/bucket.md
178
+ - notes/builder.md
179
+ - notes/collection.md
180
+ - notes/factories.md
181
+ - notes/model-overlay.md
182
+ - notes/model.md
183
+ - notes/structured-data-classes.md
184
+ - spec/array/average_spec.rb
185
+ - spec/array/sorted_median_spec.rb
186
+ - spec/array/sorted_percentile_spec.rb
187
+ - spec/array/sorted_sample_spec.rb
179
188
  - spec/examples/builder/ironfan_spec.rb
180
189
  - spec/extlib/hash_spec.rb
181
190
  - spec/extlib/mash_spec.rb
@@ -183,7 +192,6 @@ files:
183
192
  - spec/gorillib/array/extract_options_spec.rb
184
193
  - spec/gorillib/builder_spec.rb
185
194
  - spec/gorillib/collection_spec.rb
186
- - spec/gorillib/configurable_spec.rb
187
195
  - spec/gorillib/datetime/parse_spec.rb
188
196
  - spec/gorillib/datetime/to_flat_spec.rb
189
197
  - spec/gorillib/enumerable/sum_spec.rb
@@ -205,6 +213,7 @@ files:
205
213
  - spec/gorillib/metaprogramming/class_attribute_spec.rb
206
214
  - spec/gorillib/metaprogramming/delegation_spec.rb
207
215
  - spec/gorillib/metaprogramming/singleton_class_spec.rb
216
+ - spec/gorillib/model/lint_spec.rb
208
217
  - spec/gorillib/model/record/defaults_spec.rb
209
218
  - spec/gorillib/model/record/factories_spec.rb
210
219
  - spec/gorillib/model/record/overlay_spec.rb
@@ -234,7 +243,6 @@ files:
234
243
  - spec/support/matchers/enumerate_method.rb
235
244
  - spec/support/matchers/evaluate_to_true.rb
236
245
  - spec/support/model_test_helpers.rb
237
- - spec/support/shared_examples/included_module.rb
238
246
  homepage: http://infochimps.com/labs
239
247
  licenses:
240
248
  - MIT
@@ -248,9 +256,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
256
  - - ! '>='
249
257
  - !ruby/object:Gem::Version
250
258
  version: '0'
251
- segments:
252
- - 0
253
- hash: -645354043939848167
254
259
  required_rubygems_version: !ruby/object:Gem::Requirement
255
260
  none: false
256
261
  requirements:
@@ -259,11 +264,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
264
  version: '0'
260
265
  requirements: []
261
266
  rubyforge_project:
262
- rubygems_version: 1.8.15
267
+ rubygems_version: 1.8.11
263
268
  signing_key:
264
269
  specification_version: 3
265
270
  summary: include only what you need. No dependencies, no creep
266
271
  test_files:
272
+ - spec/array/average_spec.rb
273
+ - spec/array/sorted_median_spec.rb
274
+ - spec/array/sorted_percentile_spec.rb
275
+ - spec/array/sorted_sample_spec.rb
267
276
  - spec/examples/builder/ironfan_spec.rb
268
277
  - spec/extlib/hash_spec.rb
269
278
  - spec/extlib/mash_spec.rb
@@ -271,7 +280,6 @@ test_files:
271
280
  - spec/gorillib/array/extract_options_spec.rb
272
281
  - spec/gorillib/builder_spec.rb
273
282
  - spec/gorillib/collection_spec.rb
274
- - spec/gorillib/configurable_spec.rb
275
283
  - spec/gorillib/datetime/parse_spec.rb
276
284
  - spec/gorillib/datetime/to_flat_spec.rb
277
285
  - spec/gorillib/enumerable/sum_spec.rb
@@ -293,6 +301,7 @@ test_files:
293
301
  - spec/gorillib/metaprogramming/class_attribute_spec.rb
294
302
  - spec/gorillib/metaprogramming/delegation_spec.rb
295
303
  - spec/gorillib/metaprogramming/singleton_class_spec.rb
304
+ - spec/gorillib/model/lint_spec.rb
296
305
  - spec/gorillib/model/record/defaults_spec.rb
297
306
  - spec/gorillib/model/record/factories_spec.rb
298
307
  - spec/gorillib/model/record/overlay_spec.rb
@@ -322,5 +331,4 @@ test_files:
322
331
  - spec/support/matchers/enumerate_method.rb
323
332
  - spec/support/matchers/evaluate_to_true.rb
324
333
  - spec/support/model_test_helpers.rb
325
- - spec/support/shared_examples/included_module.rb
326
334
  has_rdoc:
@@ -1,28 +0,0 @@
1
- require 'configliere'
2
- require 'gorillib/builder'
3
- require 'gorillib/string/inflections'
4
-
5
- module Gorillib
6
- module Configurable
7
- extend Gorillib::Concern
8
- include Gorillib::Builder
9
-
10
- module ClassMethods
11
- def receive(attrs = {}, &blk)
12
- conf = settings.load_configuration_in_order!(configuration_scope.to_s)
13
- super(attrs.merge(conf), &blk)
14
- end
15
-
16
- def config(name, type, options = {})
17
- field(name, type, options)
18
- end
19
- end
20
-
21
- included do
22
- self.class_attribute(:configuration_scope, :settings)
23
- self.configuration_scope = self.to_s.underscore.to_sym
24
- self.settings = Configliere::Param.new.use(:commandline, :config_file)
25
- end
26
-
27
- end
28
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'gorillib/configurable'
3
-
4
- describe Gorillib::Configurable do
5
- include_context 'included_module'
6
-
7
- it 'defines a config() method on the class' do
8
- subject.should respond_to(:config)
9
- end
10
-
11
- it 'creates a class attribute :settings' do
12
- subject.should respond_to(:settings)
13
- subject.receive.should respond_to(:settings)
14
- end
15
-
16
- it 'creates a class attribute :configuration_scope' do
17
- subject.should respond_to(:configuration_scope)
18
- subject.receive.should respond_to(:configuration_scope)
19
- end
20
-
21
- context 'config' do
22
- let(:test_field) { :gonads }
23
- let(:test_default) { 'strife' }
24
- let(:test_type) { String }
25
-
26
- before(:each) { subject.config(test_field, test_type, :default => test_default) }
27
-
28
- # it 'defines a field on settings with optional defaults' do
29
- # subject.settings.send(test_field).should == test_default
30
- # end
31
-
32
- it 'defines a receiver for the given field' do
33
- subject.receive.send(test_field).should == test_default
34
- end
35
-
36
- end
37
-
38
- context 'receive' do
39
-
40
- it 'resolves configuration in order' do
41
- subject.settings.should_receive(:load_configuration_in_order!).and_return({})
42
- subject.receive
43
- end
44
-
45
- before do
46
- subject.class_eval do
47
- config :yo_momma, String, :default => 'is so ugly'
48
- config :she, String
49
- end
50
- subject.stub(:settings).and_return(test_settings)
51
- end
52
-
53
- let(:creation_attrs) { { yo_momma: 'is so fat', she: 'eats wheat THICKS' } }
54
- let(:configuration) { { yo_momma: 'is so dumb', she: 'got hit by a parked car' } }
55
- let(:test_settings) { double :settings, :load_configuration_in_order! => configuration }
56
-
57
- it 'overrides attributes with configuration settings' do
58
- subject.receive(creation_attrs).attributes.should include(creation_attrs.merge(configuration))
59
- end
60
- end
61
- end
62
-
@@ -1,20 +0,0 @@
1
- shared_context 'included_module' do
2
-
3
- let(:included_module) { described_class }
4
- let(:klass_name) { 'FakeModel' }
5
-
6
- def create_fake_model_klass name
7
- klass = self.class.const_set(name.to_sym, Class.new)
8
- mod = included_module
9
- klass.class_eval{ include(mod) }
10
- klass
11
- end
12
-
13
- def remove_fake_model_klass name
14
- self.class.send(:remove_const, name.to_sym) if self.class.const_defined? name.to_sym
15
- end
16
-
17
- subject { create_fake_model_klass(klass_name) }
18
- after(:each) { remove_fake_model_klass(klass_name) }
19
-
20
- end