deepstruct 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency "rspec"
22
+ s.add_development_dependency "rake"
22
23
  end
@@ -5,34 +5,34 @@ module DeepStruct
5
5
  def initialize(value)
6
6
  @value = value
7
7
  end
8
-
8
+
9
9
  def unwrap
10
10
  @value
11
11
  end
12
-
12
+
13
13
  def [](index)
14
14
  return DeepStruct.wrap(@value[index])
15
15
  end
16
-
16
+
17
17
  def []=(index, value)
18
18
  @value[index] = value
19
19
  end
20
-
20
+
21
21
  def inspect
22
22
  "#<#{self.class} #{@value.inspect}>"
23
23
  end
24
24
 
25
25
  def to_json
26
- @value.to_json
26
+ @value.to_json
27
27
  end
28
28
  end
29
-
29
+
30
30
  class HashWrapper < DeepWrapper
31
31
  def respond_to?(method)
32
- @value.respond_to?(method) || self.has_key?(method.to_s.chomp('='))
32
+ @value.respond_to?(method) || self.has_key?(method.to_s.chomp('='))
33
33
  end
34
34
 
35
- # Given a symbol or a string this yields the variant of the key that
35
+ # Given a symbol or a string this yields the variant of the key that
36
36
  # exists in the wrapped hash if any. If none exists (or the key is not
37
37
  # a symbol or string) the input value is passed through unscathed.
38
38
  def indiffrently(key, &block)
@@ -43,7 +43,7 @@ module DeepStruct
43
43
  end
44
44
 
45
45
  def []=(key, value)
46
- indiffrently(key) { |key| @value[key] = value }
46
+ indiffrently(key) { |key| @value[key] = value }
47
47
  end
48
48
 
49
49
  def [](key)
@@ -59,8 +59,8 @@ module DeepStruct
59
59
  method = method.to_s
60
60
  if method.chomp!('?')
61
61
  key = method.to_sym
62
- @value.has_key?(key) && !!@value[key]
63
- elsif method.chomp!('=')
62
+ @value.has_key?(key) && !!self[key]
63
+ elsif method.chomp!('=')
64
64
  raise ArgumentError, "wrong number of arguments (#{arg_count} for 1)", caller(1) if args.length != 1
65
65
  self[method] = args[0]
66
66
  elsif args.length == 0 && self.has_key?(method)
@@ -70,7 +70,7 @@ module DeepStruct
70
70
  end
71
71
  end
72
72
  end
73
-
73
+
74
74
  class ArrayWrapper < DeepWrapper
75
75
  include Enumerable
76
76
 
@@ -85,7 +85,7 @@ module DeepStruct
85
85
  end
86
86
  alias :length :size
87
87
  end
88
-
88
+
89
89
  def self.wrap(value)
90
90
  case value
91
91
  when Hash
@@ -1,3 +1,3 @@
1
1
  module Deepstruct
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: A sibling of ostruct that handles deeply nested structures and basic
31
47
  data type detection
32
48
  email:
@@ -57,12 +73,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
73
  - - ! '>='
58
74
  - !ruby/object:Gem::Version
59
75
  version: '0'
76
+ segments:
77
+ - 0
78
+ hash: 4197967560630197465
60
79
  required_rubygems_version: !ruby/object:Gem::Requirement
61
80
  none: false
62
81
  requirements:
63
82
  - - ! '>='
64
83
  - !ruby/object:Gem::Version
65
84
  version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 4197967560630197465
66
88
  requirements: []
67
89
  rubyforge_project: deepstruct
68
90
  rubygems_version: 1.8.24