easyconf-rails 0.0.3 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data.tar.gz.sig +3 -2
  2. data/lib/easyconf-rails.rb +18 -1
  3. metadata +4 -4
  4. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- �W}��ǝ�G��h��XS��S�:���[e��|z ���2~?�P8��x����k&s�D��˚�F����:�a_��e�c�N�UF�B�2�㏳Ӆ��
2
- �!��3���}|\'Ԑ>�R�ȟ���Z��]G������>:�RJa ����L6>�6IyDg����Y� 4��h3J0rMê�i3���̌6��·�s���;��M��gK(7+dF��#�A��~����a���g6��kd�] +��
1
+ E
2
+ L��m��N,�����w(z$����X��ɮ�+�0*�B���U FCH)�>�9ˈr�.[O %��d���t%̙:���l[��I���h֫��5�砵�Q2H�|��}
3
+ �p �a�w����C�͘C���ӫ7��w�%li.0��Rg֒�e�N0�I�<�n2����G���<���sV����l:�6�ҷ
@@ -1,5 +1,22 @@
1
1
  require 'ostruct'
2
2
 
3
+ # SemiOpenStruct is like OpenStruct, except that accessing an uninitialized key
4
+ # will raise a KeyError.
5
+ class SemiOpenStruct < OpenStruct
6
+ # Return true if the given key is present.
7
+ def has_key?(key)
8
+ singleton_methods.grep(/[^=]$/).include?(key)
9
+ end
10
+
11
+ def method_missing(key, *val)
12
+ if key.to_s.end_with?('=') and (val.length == 1)
13
+ super(key, val.first)
14
+ else
15
+ raise(NameError, "undefined method `#{key}' for #{self}")
16
+ end
17
+ end
18
+ end
19
+
3
20
  class EasyConfRails < Rails::Railtie
4
21
  # Turn a Hash or Array and all of its Hash children into OpenStructs.
5
22
  def hash_to_openstruct(hash)
@@ -9,7 +26,7 @@ class EasyConfRails < Rails::Railtie
9
26
  end
10
27
  end
11
28
 
12
- hash.is_a?(Array) ? hash : OpenStruct.new(hash)
29
+ hash.is_a?(Array) ? hash : SemiOpenStruct.new(hash)
13
30
  end
14
31
 
15
32
  # Merge two hashes recursively, with precedence going to the earliest Hash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyconf-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,11 +50,11 @@ cert_chain:
50
50
  -----END CERTIFICATE-----
51
51
 
52
52
  '
53
- date: 2011-12-07 00:00:00.000000000 Z
53
+ date: 2012-01-30 00:00:00.000000000 Z
54
54
  dependencies:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
- requirement: &73151190 !ruby/object:Gem::Requirement
57
+ requirement: &77519290 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
60
  - - ! '>='
@@ -62,7 +62,7 @@ dependencies:
62
62
  version: '0'
63
63
  type: :runtime
64
64
  prerelease: false
65
- version_requirements: *73151190
65
+ version_requirements: *77519290
66
66
  description: Configure Rails apps with a simple YAML file.
67
67
  email: the.magical.kat@gmail.com
68
68
  executables: []
metadata.gz.sig CHANGED
Binary file