static_model 0.2.1 → 0.2.2
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/History.txt +5 -0
- data/lib/static_model/base.rb +3 -1
- data/lib/static_model/version.rb +1 -1
- data/lib/static_model.rb +8 -5
- data/test/test_helper.rb +4 -1
- data/test/test_static_model.rb +14 -0
- metadata +6 -5
data/History.txt
CHANGED
data/lib/static_model/base.rb
CHANGED
@@ -77,7 +77,9 @@ module StaticModel
|
|
77
77
|
return if loaded? && !reload
|
78
78
|
raise(StaticModel::DataFileNotFound, "You must set a data file to load from") unless File.readable?(data_file)
|
79
79
|
begin
|
80
|
-
|
80
|
+
raw_data = File.open(data_file) {|f| f.read }
|
81
|
+
parsed_data = ERB.new(raw_data).result
|
82
|
+
data = YAML::load(parsed_data)
|
81
83
|
rescue
|
82
84
|
raise(StaticModel::BadDataFile, "The data file you specified '#{data_file}' was not in a readable format.")
|
83
85
|
end
|
data/lib/static_model/version.rb
CHANGED
data/lib/static_model.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
require 'active_support/inflector'
|
7
|
-
require 'active_support/core_ext/hash'
|
8
|
-
require 'active_support/core_ext/string'
|
4
|
+
require 'yaml' unless defined?(YAML)
|
5
|
+
require 'erb' unless defined?(ERB)
|
9
6
|
|
7
|
+
unless defined?(ActiveSupport::CoreExtensions)
|
8
|
+
require 'active_support/inflector'
|
9
|
+
require 'active_support/core_ext/hash'
|
10
|
+
require 'active_support/core_ext/string'
|
11
|
+
require 'active_support/core_ext/integer'
|
12
|
+
end
|
10
13
|
|
11
14
|
require 'static_model/errors'
|
12
15
|
require 'static_model/associations'
|
data/test/test_helper.rb
CHANGED
data/test/test_static_model.rb
CHANGED
@@ -147,6 +147,20 @@ class TestStaticModel < Test::Unit::TestCase
|
|
147
147
|
|
148
148
|
end
|
149
149
|
end
|
150
|
+
|
151
|
+
context "loading a data_file with embedded erb" do
|
152
|
+
setup do
|
153
|
+
@projects = Project.all
|
154
|
+
end
|
155
|
+
|
156
|
+
should "evaluate erb expressions at load time" do
|
157
|
+
assert_equal 1.day.ago.strftime('%m/%d/%Y %I:%M%p'), @projects.first.created_at
|
158
|
+
end
|
159
|
+
|
160
|
+
should "evaluate erb in current context" do
|
161
|
+
assert_equal Author.first, @projects[1].author
|
162
|
+
end
|
163
|
+
end
|
150
164
|
|
151
165
|
context "find" do
|
152
166
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Quint
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.
|
33
|
+
version: 1.8.0
|
34
34
|
version:
|
35
35
|
description: ActiveRecord like functionalities for reading from YAML with a simple class implementation
|
36
36
|
email:
|
@@ -43,6 +43,7 @@ extra_rdoc_files:
|
|
43
43
|
- History.txt
|
44
44
|
- License.txt
|
45
45
|
- Manifest.txt
|
46
|
+
- README.rdoc
|
46
47
|
files:
|
47
48
|
- History.txt
|
48
49
|
- License.txt
|
@@ -66,7 +67,7 @@ homepage: http://quirkey.rubyforge.org
|
|
66
67
|
post_install_message: ""
|
67
68
|
rdoc_options:
|
68
69
|
- --main
|
69
|
-
- README.
|
70
|
+
- README.rdoc
|
70
71
|
require_paths:
|
71
72
|
- lib
|
72
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
requirements: []
|
85
86
|
|
86
87
|
rubyforge_project: quirkey
|
87
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.3.1
|
88
89
|
signing_key:
|
89
90
|
specification_version: 2
|
90
91
|
summary: ActiveRecord like functionalities for reading from YAML with a simple class implementation
|