hashmodel 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,6 @@ A simple MVC type model class for storing deeply nested hashes as records.
4
4
  It's meant to be used for small, in-memory recordset that you want an easy, flexible way to query.
5
5
  It is not meant as a data storage device for managing huge datasets.
6
6
 
7
- Note:
8
- This started out as a programming exercise to learn more about Ruby but is now fairly well featured so can be quite useful.
9
- It is not however a thoroughly tested or industrial strength model and it's not meant to be used to parse your entire user database.
10
- If you're looking for an excellent model class take a look at ActiveModel, it's probably more of what you're looking for.
11
-
12
7
  ## Synopsis
13
8
 
14
9
  The major usefulness of this class is it allows you to filter and search flattened records based on any field.
@@ -34,11 +29,7 @@ Or more powerfully you can search using boolean like logic e.g.
34
29
 
35
30
  ## Status
36
31
 
37
- ###**Beta**
38
-
39
- I'm doing real-world testing now and am fixing design holes and adding functionality so I wouldn't use this version until I'm done. None of the previous versions were all that useful but after I release this version I'll only develop in branches.
40
-
41
- I expect the design to stay pretty stable from this point forward so no more surprising changes in the design or its use.
32
+ 2011.03.18 - Production: 0.3.1
42
33
 
43
34
  ## Developer Notes
44
35
 
@@ -227,7 +218,11 @@ I've covered most of the major stuff here but to see all of the functionality ta
227
218
 
228
219
  ## Version History
229
220
 
230
- 0.3.0.beta3 - 2011.01.12
221
+ 0.3.1 - 2011.03.18
222
+
223
+ * Fixed design flaw that caused HashModel not to respond to Array methods if a deserialized copy (e.g. Marshal.load) was used before a new instance of the class had been created.
224
+
225
+ 0.3.0 - 2011.01.13
231
226
 
232
227
  * HashModel\#where searches can now use symbols instead of @variables (you can still use @ if you want).
233
228
  e.g. hash_model.where{:x == "x" && :y == "y"} instead of the less natural hash_model.where{@x == "x" && @y == "y"}
File without changes
@@ -390,6 +390,14 @@ class HashModel
390
390
 
391
391
  private
392
392
 
393
+ # If the object is serialized it loses the dynamically mapped methods
394
+ # This will catch that and try to remap them.
395
+ def method_missing(symbol , *args)
396
+ mimic_methods
397
+ return send(symbol, *args) if respond_to?(symbol)
398
+ super(symbol, args)
399
+ end
400
+
393
401
  # Convert a hash of multiple key/value pairs to an array of single hashes.
394
402
  # {:field1 => "value1", :field2 => "value2"}
395
403
  # becomes
@@ -2,7 +2,7 @@ class HashModel
2
2
  module VERSION # :nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ # WARNING!
4
+ # The following test is valid ONLY if it is run by itself!
5
+ # If a HashModel object has been instantiated before this test
6
+ # the test will not properly verify that the dynamic methods are
7
+ # recreated.
8
+
9
+ describe HashModel do
10
+
11
+ let(:hm_file) {File.expand_path((File.dirname(__FILE__) + '/hashmodel.dat'))}
12
+ let(:hm) {Marshal.load(File.open(hm_file, "r"))}
13
+
14
+ context "after deserializing an instance" do
15
+
16
+ it "remaps dynamic methods if one of them is called" do
17
+ lambda{hm.length}.should_not raise_error
18
+ end
19
+
20
+ end
21
+
22
+ context "when a legitimatly non-exisitant method is called" do
23
+ it "should raise an error" do
24
+ lambda{hm.ice_cream}.should raise_error(NoMethodError)
25
+ end
26
+ end
27
+
28
+ end
@@ -84,6 +84,14 @@ describe "HashModel" do
84
84
 
85
85
  end # "raw data"
86
86
 
87
+ describe "flattened data" do
88
+
89
+ it "reports the length of the flattened data" do
90
+ @hm.length.should == 5
91
+ end
92
+
93
+ end
94
+
87
95
  end # "general properties"
88
96
 
89
97
  describe "adding records" do
metadata CHANGED
@@ -1,84 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hashmodel
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 0
9
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Mike Bethany
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-01-13 00:00:00 -05:00
12
+ date: 2011-03-18 00:00:00.000000000 -04:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: sourcify
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2152188960 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
31
23
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: file-tail
35
24
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2152188960
26
+ - !ruby/object:Gem::Dependency
27
+ name: file-tail
28
+ requirement: &2152188520 !ruby/object:Gem::Requirement
37
29
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
44
34
  type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
35
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2152188520
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &2152188060 !ruby/object:Gem::Requirement
50
40
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
57
45
  type: :development
58
- version_requirements: *id003
59
- - !ruby/object:Gem::Dependency
60
- name: cucumber
61
46
  prerelease: false
62
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2152188060
48
+ - !ruby/object:Gem::Dependency
49
+ name: cucumber
50
+ requirement: &2152187620 !ruby/object:Gem::Requirement
63
51
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
70
56
  type: :development
71
- version_requirements: *id004
72
- description: A simple MVC type model class for storing records based on nested hashes as an array of hashes. You can store deeply nested hashes and still easily flatten and query the records using flattened field names.
73
- email:
57
+ prerelease: false
58
+ version_requirements: *2152187620
59
+ description: A simple MVC type model class for storing records based on nested hashes
60
+ as an array of hashes. You can store deeply nested hashes and still easily flatten
61
+ and query the records using flattened field names.
62
+ email:
74
63
  - mikbe.tk@gmail.com
75
64
  executables: []
76
-
77
65
  extensions: []
78
-
79
66
  extra_rdoc_files: []
80
-
81
- files:
67
+ files:
82
68
  - .document
83
69
  - .gitignore
84
70
  - .rspec
@@ -87,6 +73,7 @@ files:
87
73
  - LICENSE.txt
88
74
  - README.markdown
89
75
  - Rakefile
76
+ - _brainstorm/StrangeMarshal.txt
90
77
  - _brainstorm/_readme
91
78
  - _brainstorm/block_wheres.rb
92
79
  - _brainstorm/clone.rb
@@ -113,41 +100,36 @@ files:
113
100
  - lib/hash_model/hash_model.rb
114
101
  - lib/hash_model/version.rb
115
102
  - lib/hashmodel.rb
103
+ - spec/hash_model/_marshelling_spec.rb
116
104
  - spec/hash_model/hash_model_spec.rb
105
+ - spec/hash_model/hashmodel.dat
117
106
  - spec/spec_helper.rb
118
107
  has_rdoc: true
119
108
  homepage: http://github.com/mikbe/hashmodel
120
109
  licenses: []
121
-
122
110
  post_install_message:
123
111
  rdoc_options: []
124
-
125
- require_paths:
112
+ require_paths:
126
113
  - lib
127
- required_ruby_version: !ruby/object:Gem::Requirement
114
+ required_ruby_version: !ruby/object:Gem::Requirement
128
115
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- segments:
133
- - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
121
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- segments:
141
- - 0
142
- version: "0"
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
143
126
  requirements: []
144
-
145
127
  rubyforge_project:
146
- rubygems_version: 1.3.7
128
+ rubygems_version: 1.6.2
147
129
  signing_key:
148
130
  specification_version: 3
149
131
  summary: Store nested hashes as records and easily search them (even nested ones)
150
- test_files:
132
+ test_files:
151
133
  - features/README
152
134
  - features/hash_model_flatten.feature
153
135
  - features/hash_model_grouping.feature
@@ -155,5 +137,7 @@ test_files:
155
137
  - features/step_definitions/hash_model_steps.rb
156
138
  - features/support/env.rb
157
139
  - features/support/helper.rb
140
+ - spec/hash_model/_marshelling_spec.rb
158
141
  - spec/hash_model/hash_model_spec.rb
142
+ - spec/hash_model/hashmodel.dat
159
143
  - spec/spec_helper.rb