active_hash 0.9.8 → 0.9.9
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.
- data/CHANGELOG +6 -0
- data/Gemfile +1 -20
- data/README.md +9 -17
- data/active_hash.gemspec +14 -2
- data/lib/active_hash.rb +2 -2
- data/lib/active_hash/base.rb +8 -0
- data/lib/active_hash/version.rb +1 -1
- data/lib/associations/associations.rb +7 -0
- data/spec/active_hash/base_spec.rb +1 -0
- data/spec/associations/associations_spec.rb +7 -0
- metadata +110 -27
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
2012-04-05
|
|
2
|
+
- Allow gems like simple_form to read metadata about belongs_to associations that point to active hash objects (kbrock)
|
|
3
|
+
|
|
4
|
+
2012-01-19
|
|
5
|
+
- Move specs to appraisal (flavorjones)
|
|
6
|
+
|
|
1
7
|
2012-01-18 (v0.9.8)
|
|
2
8
|
- Make ActiveHash.find with array raise an exception when record cannot be found (mocoso)
|
|
3
9
|
|
data/Gemfile
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "http://rubygems.org/"
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
|
-
|
|
5
|
-
group :development do
|
|
6
|
-
activerecord_version = ENV['ACTIVE_HASH_ACTIVERECORD_VERSION']
|
|
7
|
-
|
|
8
|
-
if activerecord_version == "edge"
|
|
9
|
-
git "git://github.com/rails/rails.git" do
|
|
10
|
-
gem "activerecord"
|
|
11
|
-
gem "activesupport"
|
|
12
|
-
end
|
|
13
|
-
elsif activerecord_version && activerecord_version.strip != ""
|
|
14
|
-
gem "activerecord", activerecord_version
|
|
15
|
-
else
|
|
16
|
-
gem "activerecord"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
gem "rake", "0.8.7"
|
|
20
|
-
gem "rspec", "2.2.0"
|
|
21
|
-
gem "sqlite3-ruby", ">= 1.3.2"
|
|
22
|
-
end
|
data/README.md
CHANGED
|
@@ -54,6 +54,10 @@ If you are Pat Nakajima, you probably prefer _add_:
|
|
|
54
54
|
add :id => 2, :name => "Canada"
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
## WARNING
|
|
58
|
+
|
|
59
|
+
If you add data to an ActiveHash file during an initializer, it will not be reloaded in development in Rails.
|
|
60
|
+
|
|
57
61
|
## Auto-Defined fields
|
|
58
62
|
|
|
59
63
|
ActiveHash will auto-define all fields for you when you load the hash. For example, if you have the following class:
|
|
@@ -359,28 +363,16 @@ To make users' lives easier, please maintain support for:
|
|
|
359
363
|
* Ruby 1.92
|
|
360
364
|
* ActiveRecord/ActiveSupport from 2.3.2 through edge
|
|
361
365
|
|
|
362
|
-
To that end,
|
|
363
|
-
Before releasing a new version of ActiveHash, please run the prelease shell script like so:
|
|
364
|
-
|
|
365
|
-
./prerelease
|
|
366
|
-
|
|
367
|
-
It requires you to have rvm installed, and it requires the latest patch-versions of 1.8.7, ree and 1.9.2. The prerelease script will:
|
|
368
|
-
|
|
369
|
-
* switch to rvm's ruby-1.8.7
|
|
370
|
-
* check for an active_hash gemset, and create one if it's not there
|
|
371
|
-
* check for bundler and install it if it's not there
|
|
372
|
-
* run `bundle exec rspec spec` against AR versions 2.3.2, 2.3.5, 2.3.11, the currently released version and edge
|
|
373
|
-
* switch to ree-1.8.7 and do the same
|
|
374
|
-
* switch to ruby-1.9.2 and do the same
|
|
366
|
+
To that end, run specs against all rubies before committing:
|
|
375
367
|
|
|
376
|
-
|
|
377
|
-
|
|
368
|
+
rake appraisal:install
|
|
369
|
+
rake appraisal spec
|
|
378
370
|
|
|
379
|
-
Once
|
|
371
|
+
Once appraisal passes in all supported rubies, follow these steps to release a new version of active_hash:
|
|
380
372
|
|
|
381
373
|
* update the changelog with a brief summary of the changes that are included in the release
|
|
382
374
|
* bump the gem version by editing the `version.rb` file
|
|
383
|
-
* if there are new contributors, add them to the list of authors in the
|
|
375
|
+
* if there are new contributors, add them to the list of authors in the gemspec
|
|
384
376
|
* run `rake build`
|
|
385
377
|
* commit those changes
|
|
386
378
|
* run `rake install` and verify that the gem loads correctly from an irb session
|
data/active_hash.gemspec
CHANGED
|
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
"Joel Chippindale",
|
|
25
25
|
"Kevin Olsen",
|
|
26
26
|
"Vladimir Andrijevik",
|
|
27
|
-
"Adam Anderson"
|
|
27
|
+
"Adam Anderson",
|
|
28
|
+
"Keenan Brock"
|
|
28
29
|
]
|
|
29
30
|
s.date = %q{2012-01-18}
|
|
30
31
|
s.email = %q{jeff@zilkey.com}
|
|
@@ -60,11 +61,22 @@ Gem::Specification.new do |s|
|
|
|
60
61
|
|
|
61
62
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
62
63
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
64
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.2.0"])
|
|
65
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
|
66
|
+
s.add_development_dependency(%q<activerecord>, [">= 2.2.2"])
|
|
67
|
+
s.add_development_dependency(%q<appraisal>, [">= 0"])
|
|
63
68
|
else
|
|
64
69
|
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
70
|
+
s.add_dependency(%q<rspec>, ["~> 2.2.0"])
|
|
71
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
72
|
+
s.add_dependency(%q<activerecord>, [">= 2.2.2"])
|
|
73
|
+
s.add_dependency(%q<appraisal>, [">= 0"])
|
|
65
74
|
end
|
|
66
75
|
else
|
|
67
76
|
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
|
77
|
+
s.add_dependency(%q<rspec>, ["~> 2.2.0"])
|
|
78
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
|
79
|
+
s.add_dependency(%q<activerecord>, [">= 2.2.2"])
|
|
80
|
+
s.add_dependency(%q<appraisal>, [">= 0"])
|
|
68
81
|
end
|
|
69
82
|
end
|
|
70
|
-
|
data/lib/active_hash.rb
CHANGED
|
@@ -2,13 +2,13 @@ require 'active_support'
|
|
|
2
2
|
|
|
3
3
|
begin
|
|
4
4
|
require 'active_support/core_ext'
|
|
5
|
-
rescue
|
|
5
|
+
rescue
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
begin
|
|
9
9
|
require 'active_model'
|
|
10
10
|
require 'active_model/naming'
|
|
11
|
-
rescue
|
|
11
|
+
rescue LoadError
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
require 'active_hash/base'
|
data/lib/active_hash/base.rb
CHANGED
data/lib/active_hash/version.rb
CHANGED
|
@@ -16,6 +16,13 @@ module ActiveHash
|
|
|
16
16
|
define_method("#{association_id}=") do |new_value|
|
|
17
17
|
send "#{options[:foreign_key]}=", new_value ? new_value.id : nil
|
|
18
18
|
end
|
|
19
|
+
|
|
20
|
+
create_reflection(
|
|
21
|
+
:belongs_to,
|
|
22
|
+
association_id.to_sym,
|
|
23
|
+
options,
|
|
24
|
+
options[:class_name].constantize
|
|
25
|
+
)
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
end
|
|
@@ -126,6 +126,13 @@ describe ActiveHash::Base, "associations" do
|
|
|
126
126
|
school.city.should be_nil
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
|
+
|
|
130
|
+
it "finds active record metadata for this association" do
|
|
131
|
+
School.belongs_to_active_hash :city
|
|
132
|
+
association = School.reflect_on_association(:city)
|
|
133
|
+
association.should_not be_nil
|
|
134
|
+
association.klass.name.should == City.name
|
|
135
|
+
end
|
|
129
136
|
end
|
|
130
137
|
end
|
|
131
138
|
|
metadata
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_hash
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 41
|
|
5
5
|
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 9
|
|
9
|
+
- 9
|
|
10
|
+
version: 0.9.9
|
|
6
11
|
platform: ruby
|
|
7
|
-
authors:
|
|
12
|
+
authors:
|
|
8
13
|
- Jeff Dean
|
|
9
14
|
- Mike Dalessio
|
|
10
15
|
- Corey Innis
|
|
@@ -21,30 +26,99 @@ authors:
|
|
|
21
26
|
- Kevin Olsen
|
|
22
27
|
- Vladimir Andrijevik
|
|
23
28
|
- Adam Anderson
|
|
29
|
+
- Keenan Brock
|
|
24
30
|
autorequire:
|
|
25
31
|
bindir: bin
|
|
26
32
|
cert_chain: []
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
date: 2012-01-18 00:00:00 Z
|
|
35
|
+
dependencies:
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
30
37
|
name: activesupport
|
|
31
|
-
|
|
38
|
+
prerelease: false
|
|
39
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
32
40
|
none: false
|
|
33
|
-
requirements:
|
|
34
|
-
- -
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
hash: 3
|
|
45
|
+
segments:
|
|
46
|
+
- 2
|
|
47
|
+
- 2
|
|
48
|
+
- 2
|
|
36
49
|
version: 2.2.2
|
|
37
50
|
type: :runtime
|
|
51
|
+
version_requirements: *id001
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: rspec
|
|
54
|
+
prerelease: false
|
|
55
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
56
|
+
none: false
|
|
57
|
+
requirements:
|
|
58
|
+
- - ~>
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
hash: 7
|
|
61
|
+
segments:
|
|
62
|
+
- 2
|
|
63
|
+
- 2
|
|
64
|
+
- 0
|
|
65
|
+
version: 2.2.0
|
|
66
|
+
type: :development
|
|
67
|
+
version_requirements: *id002
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: sqlite3
|
|
70
|
+
prerelease: false
|
|
71
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
72
|
+
none: false
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
hash: 3
|
|
77
|
+
segments:
|
|
78
|
+
- 0
|
|
79
|
+
version: "0"
|
|
80
|
+
type: :development
|
|
81
|
+
version_requirements: *id003
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: activerecord
|
|
38
84
|
prerelease: false
|
|
39
|
-
|
|
85
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
86
|
+
none: false
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
hash: 3
|
|
91
|
+
segments:
|
|
92
|
+
- 2
|
|
93
|
+
- 2
|
|
94
|
+
- 2
|
|
95
|
+
version: 2.2.2
|
|
96
|
+
type: :development
|
|
97
|
+
version_requirements: *id004
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: appraisal
|
|
100
|
+
prerelease: false
|
|
101
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
102
|
+
none: false
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
hash: 3
|
|
107
|
+
segments:
|
|
108
|
+
- 0
|
|
109
|
+
version: "0"
|
|
110
|
+
type: :development
|
|
111
|
+
version_requirements: *id005
|
|
40
112
|
description:
|
|
41
113
|
email: jeff@zilkey.com
|
|
42
114
|
executables: []
|
|
115
|
+
|
|
43
116
|
extensions: []
|
|
44
|
-
|
|
117
|
+
|
|
118
|
+
extra_rdoc_files:
|
|
45
119
|
- LICENSE
|
|
46
120
|
- README.md
|
|
47
|
-
files:
|
|
121
|
+
files:
|
|
48
122
|
- CHANGELOG
|
|
49
123
|
- LICENSE
|
|
50
124
|
- README.md
|
|
@@ -66,29 +140,38 @@ files:
|
|
|
66
140
|
- spec/spec_helper.rb
|
|
67
141
|
homepage: http://github.com/zilkey/active_hash
|
|
68
142
|
licenses: []
|
|
143
|
+
|
|
69
144
|
post_install_message:
|
|
70
145
|
rdoc_options: []
|
|
71
|
-
|
|
146
|
+
|
|
147
|
+
require_paths:
|
|
72
148
|
- lib
|
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
150
|
none: false
|
|
75
|
-
requirements:
|
|
76
|
-
- -
|
|
77
|
-
- !ruby/object:Gem::Version
|
|
78
|
-
|
|
79
|
-
|
|
151
|
+
requirements:
|
|
152
|
+
- - ">="
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
hash: 3
|
|
155
|
+
segments:
|
|
156
|
+
- 0
|
|
157
|
+
version: "0"
|
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
159
|
none: false
|
|
81
|
-
requirements:
|
|
82
|
-
- -
|
|
83
|
-
- !ruby/object:Gem::Version
|
|
84
|
-
|
|
160
|
+
requirements:
|
|
161
|
+
- - ">="
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
hash: 3
|
|
164
|
+
segments:
|
|
165
|
+
- 0
|
|
166
|
+
version: "0"
|
|
85
167
|
requirements: []
|
|
168
|
+
|
|
86
169
|
rubyforge_project:
|
|
87
|
-
rubygems_version: 1.8.
|
|
170
|
+
rubygems_version: 1.8.17
|
|
88
171
|
signing_key:
|
|
89
172
|
specification_version: 3
|
|
90
173
|
summary: An ActiveRecord-like model that uses a hash or file as a datasource
|
|
91
|
-
test_files:
|
|
174
|
+
test_files:
|
|
92
175
|
- Gemfile
|
|
93
176
|
- spec/active_file/base_spec.rb
|
|
94
177
|
- spec/active_hash/base_spec.rb
|