gorillib 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,14 @@
1
+ h3. 2011-06-29 - Version 0.1.3: Fancier receivers
2
+
3
+ * can now mix activemodel into a receiver, getting all its validation and other awesomeness
4
+ * added receiver_model as an experimental 'I'm a fancy cadillac-style receiver'
5
+
6
+ h3. 2011-06-24 Version 0.1.2: Receiver body fixes
7
+
8
+ * Better @Object.try@ (via active_support)
9
+ * Receiver body can now be an interpolated string or a hash; this lets you use anonymous classes. Added tuple methods (does an in-order traversal).
10
+ * Bugfix for inclusion order in ActsAsHash
11
+
1
12
  h3. Version 0.1.0: Hashlike refactor, Receiver arrives
2
13
 
3
14
  v0.1.0 brings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/gorillib.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gorillib}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
12
- s.date = %q{2011-06-24}
12
+ s.date = %q{2011-06-29}
13
13
  s.description = %q{Gorillib: infochimps lightweight subset of ruby convenience methods}
14
14
  s.email = %q{coders@infochimps.org}
15
15
  s.extra_rdoc_files = [
@@ -71,8 +71,10 @@ Gem::Specification.new do |s|
71
71
  "lib/gorillib/receiver/active_model_shim.rb",
72
72
  "lib/gorillib/receiver/acts_as_hash.rb",
73
73
  "lib/gorillib/receiver/acts_as_loadable.rb",
74
+ "lib/gorillib/receiver/locale/en.yml",
74
75
  "lib/gorillib/receiver/tree_diff.rb",
75
76
  "lib/gorillib/receiver/validations.rb",
77
+ "lib/gorillib/receiver_model.rb",
76
78
  "lib/gorillib/some.rb",
77
79
  "lib/gorillib/string/constantize.rb",
78
80
  "lib/gorillib/string/human.rb",
@@ -97,7 +99,6 @@ Gem::Specification.new do |s|
97
99
  "spec/hash/zip_spec.rb",
98
100
  "spec/hashlike/behave_same_as_hash_spec.rb",
99
101
  "spec/hashlike/hashlike_behavior_spec.rb",
100
- "spec/hashlike/hashlike_via_accessors_fuzzing_spec.rb",
101
102
  "spec/hashlike/hashlike_via_accessors_spec.rb",
102
103
  "spec/hashlike_spec.rb",
103
104
  "spec/logger/log_spec.rb",
@@ -152,7 +153,6 @@ Gem::Specification.new do |s|
152
153
  "spec/hash/zip_spec.rb",
153
154
  "spec/hashlike/behave_same_as_hash_spec.rb",
154
155
  "spec/hashlike/hashlike_behavior_spec.rb",
155
- "spec/hashlike/hashlike_via_accessors_fuzzing_spec.rb",
156
156
  "spec/hashlike/hashlike_via_accessors_spec.rb",
157
157
  "spec/hashlike_spec.rb",
158
158
  "spec/logger/log_spec.rb",
@@ -803,10 +803,10 @@ module Gorillib
803
803
 
804
804
  def self.included(base)
805
805
  base.class_eval do
806
- base.send(:include, EnumerateFromKeys) unless base.method_defined?(:each_pair)
807
- unless base.include?(Enumerable)
808
- base.send(:include, Enumerable)
809
- base.send(:include, OverrideEnumerable)
806
+ include EnumerateFromKeys unless method_defined?(:each_pair)
807
+ unless include?(Enumerable)
808
+ include Enumerable
809
+ include OverrideEnumerable
810
810
  end
811
811
 
812
812
  # included here so they win out over Enumerable
@@ -1,19 +1,32 @@
1
- require 'active_model'
1
+ # require 'active_model'
2
+
3
+ require 'active_model/deprecated_error_methods'
4
+ require 'active_model/errors'
5
+ require 'active_model/naming'
6
+ require 'active_model/validator'
7
+ require 'active_model/translation'
8
+ require 'active_model/validations'
9
+ require 'active_support/i18n'
10
+ I18n.load_path << File.join(File.expand_path(File.dirname(__FILE__)), 'locale/en.yml')
2
11
 
3
12
  module Receiver
4
- class ActiveModelShim
5
- extend ActiveModel::Naming
13
+ module ActiveModelShim
6
14
 
7
15
  def to_model
8
16
  self
9
17
  end
10
18
 
11
- def valid?() true end
12
19
  def new_record?() true end
13
20
  def destroyed?() false end
14
-
15
21
  def errors
16
22
  @_errors ||= ActiveModel::Errors.new(self)
17
23
  end
24
+
25
+ def self.included(base)
26
+ base.class_eval do
27
+ extend ActiveModel::Naming
28
+ include ActiveModel::Validations
29
+ end
30
+ end
18
31
  end
19
32
  end
@@ -185,9 +185,11 @@ module Receiver
185
185
  end
186
186
 
187
187
  def self.included base
188
- base.send(:include, Gorillib::Hashlike)
189
- base.extend(ClassMethods)
190
- base.send(:include, InstanceMethods)
188
+ base.class_eval do
189
+ include Gorillib::Hashlike
190
+ extend ClassMethods
191
+ include InstanceMethods
192
+ end
191
193
  end
192
194
  end
193
195
  end
@@ -0,0 +1,27 @@
1
+ en:
2
+ errors:
3
+ # The default format to use in full error messages.
4
+ format: "%{attribute} %{message}"
5
+
6
+ # The values :model, :attribute and :value are always available for interpolation
7
+ # The value :count is available when applicable. Can be used for pluralization.
8
+ messages:
9
+ inclusion: "is not included in the list"
10
+ exclusion: "is reserved"
11
+ invalid: "is invalid"
12
+ confirmation: "doesn't match confirmation"
13
+ accepted: "must be accepted"
14
+ empty: "can't be empty"
15
+ blank: "can't be blank"
16
+ too_long: "is too long (maximum is %{count} characters)"
17
+ too_short: "is too short (minimum is %{count} characters)"
18
+ wrong_length: "is the wrong length (should be %{count} characters)"
19
+ not_a_number: "is not a number"
20
+ not_an_integer: "must be an integer"
21
+ greater_than: "must be greater than %{count}"
22
+ greater_than_or_equal_to: "must be greater than or equal to %{count}"
23
+ equal_to: "must be equal to %{count}"
24
+ less_than: "must be less than %{count}"
25
+ less_than_or_equal_to: "must be less than or equal to %{count}"
26
+ odd: "must be odd"
27
+ even: "must be even"
@@ -0,0 +1,21 @@
1
+ require 'gorillib/hashlike'
2
+ require 'gorillib/hashlike/tree_merge'
3
+ require 'gorillib/receiver'
4
+ require 'gorillib/receiver/acts_as_hash'
5
+ require 'gorillib/receiver/acts_as_loadable'
6
+ require 'gorillib/receiver/active_model_shim'
7
+
8
+ module Gorillib
9
+ module ReceiverModel
10
+ def self.included base
11
+ base.class_eval do
12
+ include Receiver
13
+ include Receiver::ActsAsHash
14
+ include Receiver::ActsAsLoadable
15
+ include Gorillib::Hashlike
16
+ include Gorillib::Hashlike::TreeMerge
17
+ include Receiver::ActiveModelShim
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__)+'/../spec_helper'
2
2
  require 'enumerator'
3
3
  require 'gorillib/hashlike'
4
+ require 'gorillib/enumerable/sum'
4
5
 
5
6
  require GORILLIB_ROOT_DIR('spec/support/hashlike_helper')
6
7
  require GORILLIB_ROOT_DIR('spec/support/hashlike_fuzzing_helper')
@@ -53,7 +54,6 @@ describe Gorillib::Hashlike do
53
54
  end
54
55
  end
55
56
 
56
-
57
57
  #
58
58
  # With a few exceptions (see HASHLIKE_DEPENDENT_METHODS), all hashlike methods go through only the following core methods:
59
59
  #
@@ -64,7 +64,7 @@ describe Gorillib::Hashlike do
64
64
  # these exceptions call a tightly-bound peer:
65
65
  #
66
66
  HASHLIKE_DEPENDENT_METHODS = Hash.new([]).merge({
67
- :merge => [:update], :rassoc => [:key], :flatten => [:to_hash], :invert => [:to_hash],
67
+ :merge => [:update], :rassoc => [:key], :flatten => [:to_hash], :invert => [:to_hash], :sum => [:inject, :map],
68
68
  :keep_if => [:select!], :delete_if => [:reject!], :select => [:select!, :keep_if], :reject => [:reject!, :delete_if],
69
69
  })
70
70
  Enumerable.public_instance_methods.map(&:to_sym).each{|meth| HASHLIKE_DEPENDENT_METHODS[meth] << :each }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gorillib
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Infochimps
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-24 00:00:00 -05:00
13
+ date: 2011-06-29 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -242,8 +242,10 @@ files:
242
242
  - lib/gorillib/receiver/active_model_shim.rb
243
243
  - lib/gorillib/receiver/acts_as_hash.rb
244
244
  - lib/gorillib/receiver/acts_as_loadable.rb
245
+ - lib/gorillib/receiver/locale/en.yml
245
246
  - lib/gorillib/receiver/tree_diff.rb
246
247
  - lib/gorillib/receiver/validations.rb
248
+ - lib/gorillib/receiver_model.rb
247
249
  - lib/gorillib/some.rb
248
250
  - lib/gorillib/string/constantize.rb
249
251
  - lib/gorillib/string/human.rb
@@ -268,7 +270,6 @@ files:
268
270
  - spec/hash/zip_spec.rb
269
271
  - spec/hashlike/behave_same_as_hash_spec.rb
270
272
  - spec/hashlike/hashlike_behavior_spec.rb
271
- - spec/hashlike/hashlike_via_accessors_fuzzing_spec.rb
272
273
  - spec/hashlike/hashlike_via_accessors_spec.rb
273
274
  - spec/hashlike_spec.rb
274
275
  - spec/logger/log_spec.rb
@@ -315,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
316
  requirements:
316
317
  - - ">="
317
318
  - !ruby/object:Gem::Version
318
- hash: -517886677893709781
319
+ hash: 1350507123130852997
319
320
  segments:
320
321
  - 0
321
322
  version: "0"
@@ -348,7 +349,6 @@ test_files:
348
349
  - spec/hash/zip_spec.rb
349
350
  - spec/hashlike/behave_same_as_hash_spec.rb
350
351
  - spec/hashlike/hashlike_behavior_spec.rb
351
- - spec/hashlike/hashlike_via_accessors_fuzzing_spec.rb
352
352
  - spec/hashlike/hashlike_via_accessors_spec.rb
353
353
  - spec/hashlike_spec.rb
354
354
  - spec/logger/log_spec.rb
@@ -1,37 +0,0 @@
1
- # require File.dirname(__FILE__)+'/../spec_helper'
2
- # require GORILLIB_ROOT_DIR('spec/support/hashlike_fuzzing_helper')
3
- # require 'gorillib/hashlike'
4
- # require 'gorillib/hashlike/hashlike_via_accessors'
5
- #
6
- # class UsingHashlikeViaAccessors
7
- # include Gorillib::Hashlike::HashlikeViaAccessors
8
- # include Gorillib::Hashlike
9
- #
10
- # attr_accessor :a, :b, :c, :nil_val, :false_val, :z
11
- #
12
- # # We override these just to be able to compare exceptions.
13
- # def to_s()
14
- # '{' + [:a, :b, :c, :nil_val, :false_val, :z].map{|k| [k, self[k]].join('=>') }.join(',') + '}'
15
- # end
16
- # def ==(other_hash)
17
- # (length == other_hash.length) && all?{|k,v| v == other_hash[k] }
18
- # end
19
- # end
20
- #
21
- #
22
- # describe Gorillib::Hashlike::HashlikeViaAccessors do
23
- # include HashlikeFuzzingHelper
24
- #
25
- #
26
- # before do
27
- # @total = 0
28
- # hsh = { :a => 3, :b => 4, :c => nil, :nil_val => nil, :false_val => false, :z => nil }
29
- # @hsh_symk = hsh.dup
30
- # @hsh_strk = {} ; hsh.each{|k,v| @hsh_strk[k.to_s] = v }
31
- # @hsh_wia = hsh.with_indifferent_access
32
- # @hshlike = InternalHash.new.merge(hsh)
33
- #
34
- # p [@hshlike]
35
- # end
36
- #
37
- # end