hstruct 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### v0.4.0
2
+
3
+ * leaving empty values out when converting to a hash was too intrusive.
4
+ If you need that, do it in your own implementation, it's trivial
5
+
1
6
  ### v0.3.0
2
7
 
3
8
  * it can be instantiated with no arguments
data/hstruct.gemspec CHANGED
@@ -4,7 +4,7 @@ $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.3.0"
7
+ spec.version = "0.4.0"
8
8
  spec.authors = ["Gerhard Lazu"]
9
9
  spec.email = ["gerhard@lazu.co.uk"]
10
10
  spec.description = %q{Struct with the convenience of instantiating from a Hash}
@@ -17,10 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "benchmark-ips"
20
+ spec.add_development_dependency "benchmark-ips", "~> 1.2"
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "guard-rspec"
23
- spec.add_development_dependency "rake"
24
- spec.add_development_dependency "rspec"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
25
24
  spec.add_development_dependency "pry"
26
25
  end
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.reject { |k, v| v.nil? }.to_a]
7
+ Hash[each_pair.to_a]
8
8
  end
9
9
  end
@@ -0,0 +1,34 @@
1
+ require_relative '../test_helper'
2
+
3
+ require 'hstruct'
4
+
5
+ Person = HStruct.new(:first_name, :last_name)
6
+
7
+ describe "Person defined from an HStruct" do
8
+ it "is a Struct" do
9
+ Person.ancestors.must_include Struct
10
+ end
11
+
12
+ it "can be instantiated with no arguments" do
13
+ Person.new.must_be_instance_of Person
14
+ end
15
+
16
+ describe "instantiated from a hash" do
17
+ let(:person) { Person.new(:first_name => "Jimmy") }
18
+
19
+ it "first name" do
20
+ person.first_name.must_equal "Jimmy"
21
+ end
22
+
23
+ it "last name" do
24
+ person.last_name.must_equal nil
25
+ end
26
+
27
+ describe "when converting back to a hash" do
28
+ it "includes empty values" do
29
+ person.to_hash.must_equal Hash[:first_name => "Jimmy", :last_name => nil]
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+
3
+ Dir.glob('./test/**/*_spec.rb', &method(:require)) if __FILE__ == $0
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.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-17 00:00:00.000000000 Z
12
+ date: 2013-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '1.2'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: '1.2'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,54 +43,38 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '1.3'
46
- - !ruby/object:Gem::Dependency
47
- name: guard-rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: rake
64
48
  requirement: !ruby/object:Gem::Requirement
65
49
  none: false
66
50
  requirements:
67
- - - ! '>='
51
+ - - ~>
68
52
  - !ruby/object:Gem::Version
69
- version: '0'
53
+ version: '10.0'
70
54
  type: :development
71
55
  prerelease: false
72
56
  version_requirements: !ruby/object:Gem::Requirement
73
57
  none: false
74
58
  requirements:
75
- - - ! '>='
59
+ - - ~>
76
60
  - !ruby/object:Gem::Version
77
- version: '0'
61
+ version: '10.0'
78
62
  - !ruby/object:Gem::Dependency
79
- name: rspec
63
+ name: minitest
80
64
  requirement: !ruby/object:Gem::Requirement
81
65
  none: false
82
66
  requirements:
83
- - - ! '>='
67
+ - - ~>
84
68
  - !ruby/object:Gem::Version
85
- version: '0'
69
+ version: '5.0'
86
70
  type: :development
87
71
  prerelease: false
88
72
  version_requirements: !ruby/object:Gem::Requirement
89
73
  none: false
90
74
  requirements:
91
- - - ! '>='
75
+ - - ~>
92
76
  - !ruby/object:Gem::Version
93
- version: '0'
77
+ version: '5.0'
94
78
  - !ruby/object:Gem::Dependency
95
79
  name: pry
96
80
  requirement: !ruby/object:Gem::Requirement
@@ -118,15 +102,14 @@ files:
118
102
  - .rspec
119
103
  - CHANGELOG.md
120
104
  - Gemfile
121
- - Guardfile
122
105
  - LICENSE.txt
123
106
  - README.md
124
107
  - Rakefile
125
108
  - benchmarks/hstruct.rb
126
109
  - hstruct.gemspec
127
110
  - lib/hstruct.rb
128
- - spec/lib/hstruct_spec.rb
129
- - spec/spec_helper.rb
111
+ - test/lib/hstruct_spec.rb
112
+ - test/test_helper.rb
130
113
  homepage: https://github.com/cambridge-healthcare/hstruct
131
114
  licenses:
132
115
  - MIT
@@ -154,6 +137,6 @@ specification_version: 3
154
137
  summary: When you care about speed and convenience, this is what you've been looking
155
138
  for
156
139
  test_files:
157
- - spec/lib/hstruct_spec.rb
158
- - spec/spec_helper.rb
140
+ - test/lib/hstruct_spec.rb
141
+ - test/test_helper.rb
159
142
  has_rdoc:
data/Guardfile DELETED
@@ -1,5 +0,0 @@
1
- guard :rspec do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
5
- end
@@ -1,28 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- require 'hstruct'
4
-
5
- Person = HStruct.new(:first_name, :last_name, :dob)
6
-
7
- describe HStruct do
8
- it "is a Struct" do
9
- Person.ancestors.should include Struct
10
- end
11
-
12
- it "can be instantiated with no arguments" do
13
- expect { Person.new }.to_not raise_error(ArgumentError)
14
- end
15
-
16
- it "can be instantiated from hash" do
17
- person = Person.new(:first_name => "Jimmy")
18
- person.first_name.should eql "Jimmy"
19
- person.last_name.should be_nil
20
- end
21
-
22
- it "when converting back to a hash, leaves empty values out" do
23
- person = Person.new(:first_name => "Jimmy")
24
- person.last_name = "Kiel"
25
- person.to_hash.should eql Hash[:first_name => "Jimmy", :last_name => "Kiel"]
26
- end
27
- end
28
-
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
- config.run_all_when_everything_filtered = true
10
- config.filter_run :focus
11
-
12
- # Run specs in random order to surface order dependencies. If you find an
13
- # order dependency and want to debug it, you can fix the order by providing
14
- # the seed, which is printed after each run.
15
- # --seed 1234
16
- config.order = 'random'
17
- end