hash-to-obj 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fac97be8d0c513fd32e27704024deea023fa55cb
4
- data.tar.gz: 930bb5f01ff267421a7ced58c3b1f89e89a3fcb9
3
+ metadata.gz: f22189599e11ddacb42d4eaef80ca2b1d00ca80b
4
+ data.tar.gz: d1c44150dd4816abc90d5c5d4dac59ead133c68b
5
5
  SHA512:
6
- metadata.gz: 9ba08e29a2f015b144c345c5b177c4e39c36b86030d9d8a3c609524cce6448923c4bb5567f2256b74f8865ccc0e941981037af97151f79cecf950116c102402f
7
- data.tar.gz: a481b39b901627e060070d6d509abbb472294925cd5a27c80688a48550d0fd0fec39a4b2ae88839aa6d4f45dab9951dbf245373ab7f10a359678735f48feec72
6
+ metadata.gz: 35c63268f4c5dc63bb86b50d895f3a30734c5d3e53dd664c5d644bd5e77666e905ce39b47cac865c4aecdbbd741f8279a42f34047d17ae2bda4e7e4333f7b495
7
+ data.tar.gz: 5c8918c57f77ba6f48b84364e128ae89e61fe5839839e2ddd1a94ee31c7441577a3ba040385b8de320b893c9681f03ab51c6f92900de4264c6b2ef46b9375a0f
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
2
+ this software and associated documentation files (the "Software"), to deal in
3
+ the Software without restriction, including without limitation the rights to
4
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
5
+ the Software, and to permit persons to whom the Software is furnished to do so,
6
+ subject to the following conditions:
7
+ The above copyright notice and this permission notice shall be included in all
8
+ copies or substantial portions of the Software.
9
+
10
+ Distributions of all or part of the Software intended to be used by the
11
+ recipients as they would use the unmodified Software, containing modifications
12
+ that substantially alter, remove, or disable functionality of the Software,
13
+ outside of the documented configuration mechanisms provided by the Software,
14
+ shall be modified such that the Original Author's bug reporting email addresses
15
+ and urls are either replaced with the contact information of the parties
16
+ responsible for the changes, or removed entirely.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = HashToObj::VERSION
9
9
  spec.authors = ['Sam Maxwell']
10
10
  spec.email = ['raindropenter@gmail.com']
11
+ spec.license = 'MITNFA'
11
12
 
12
13
  spec.summary = 'Simple Ruby gem to objectify hashes'
13
14
  spec.description = "Call 'objectify my_hash' to add accessor methods to "\
@@ -1,4 +1,5 @@
1
1
  require 'hash-to-obj/version'
2
+ require 'hash-to-obj/default_module'
2
3
 
3
4
  ##
4
5
  # We extend this to objectify our hashes. It will generate some methods on the
@@ -0,0 +1,14 @@
1
+ module HashToObj
2
+ ##
3
+ # Extend this for a small DSL around creating default methods.
4
+ module DefaultModule
5
+ ##
6
+ # Defines a method that simulates a defaulted key in the hash. If the key is
7
+ # added to the hash later, this will correctly pick up on that. You can
8
+ # specify a default value as well. This value is NOT copied.
9
+ def default_key(key, value=nil)
10
+ define_method(key) { self.has_key?(key) ? self[key] : value }
11
+ define_method("#{key}=") { |new_value| self[key] = new_value}
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module HashToObj
2
2
  # :category:
3
3
  # Current version of hash-to-obj
4
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.3.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-to-obj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Maxwell
@@ -78,14 +78,17 @@ files:
78
78
  - ".rspec"
79
79
  - ".travis.yml"
80
80
  - Gemfile
81
+ - LICENSE
81
82
  - README.md
82
83
  - Rakefile
83
84
  - bin/setup
84
85
  - hash-to-obj.gemspec
85
86
  - lib/hash-to-obj.rb
87
+ - lib/hash-to-obj/default_module.rb
86
88
  - lib/hash-to-obj/version.rb
87
89
  homepage: https://github.com/ReinAkane/hash-to-obj
88
- licenses: []
90
+ licenses:
91
+ - MITNFA
89
92
  metadata: {}
90
93
  post_install_message:
91
94
  rdoc_options: []