hstruct 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## v0.2.0
2
+
3
+ * when converting back to a hash, leave empty values out
4
+
5
+ ## v0.1.0
6
+
7
+ Initial release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Ruby Struct with the convenience of instantiating from a hash.
1
+ Struct with the convenience of instantiating from a Hash.
2
2
 
3
3
  When you care about speed, this is the Ruby structure that you've been
4
4
  looking for. HStructs are faster than any other gem out there, but still
data/hstruct.gemspec CHANGED
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "hstruct"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["Gerhard Lazu"]
9
9
  spec.email = ["gerhard@lazu.co.uk"]
10
- spec.description = %q{Ruby Struct with the convenience of instantiating from a hash.}
11
- spec.summary = %q{When you care about speed, this is the Ruby structure that you've been looking for.}
10
+ spec.description = %q{Struct with the convenience of instantiating from a Hash}
11
+ spec.summary = %q{When you care about speed and convenience, this is what you've been looking for}
12
12
  spec.homepage = "https://github.com/cambridge-healthcare/hstruct"
13
13
  spec.license = "MIT"
14
14
 
data/lib/hstruct.rb CHANGED
@@ -4,6 +4,6 @@ class HStruct < Struct
4
4
  end
5
5
 
6
6
  def to_hash
7
- Hash[each_pair.to_a]
7
+ Hash[each_pair.reject { |k, v| v.nil? }.to_a]
8
8
  end
9
9
  end
@@ -2,11 +2,9 @@ require_relative '../spec_helper'
2
2
 
3
3
  require 'hstruct'
4
4
 
5
- Person = HStruct.new(:first_name, :last_name)
5
+ Person = HStruct.new(:first_name, :last_name, :dob)
6
6
 
7
7
  describe HStruct do
8
- let(:person) { }
9
-
10
8
  it "is a Struct" do
11
9
  Person.ancestors.should include Struct
12
10
  end
@@ -17,7 +15,7 @@ describe HStruct do
17
15
  person.last_name.should be_nil
18
16
  end
19
17
 
20
- it "can be converted back to a hash" do
18
+ it "when converting back to a hash, leaves empty values out" do
21
19
  person = Person.new(:first_name => "Jimmy")
22
20
  person.last_name = "Kiel"
23
21
  person.to_hash.should eql Hash[:first_name => "Jimmy", :last_name => "Kiel"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,7 +107,7 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
- description: Ruby Struct with the convenience of instantiating from a hash.
110
+ description: Struct with the convenience of instantiating from a Hash
111
111
  email:
112
112
  - gerhard@lazu.co.uk
113
113
  executables: []
@@ -116,6 +116,7 @@ extra_rdoc_files: []
116
116
  files:
117
117
  - .gitignore
118
118
  - .rspec
119
+ - CHANGELOG.md
119
120
  - Gemfile
120
121
  - Guardfile
121
122
  - LICENSE.txt
@@ -150,8 +151,8 @@ rubyforge_project:
150
151
  rubygems_version: 1.8.23
151
152
  signing_key:
152
153
  specification_version: 3
153
- summary: When you care about speed, this is the Ruby structure that you've been looking
154
- for.
154
+ summary: When you care about speed and convenience, this is what you've been looking
155
+ for
155
156
  test_files:
156
157
  - spec/lib/hstruct_spec.rb
157
158
  - spec/spec_helper.rb