frozen_record 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adb5e89145c00c13f76483285346371896a49c1f
4
- data.tar.gz: dbaa591c9cd948b6d4a63a41b742af908dbf0f9f
3
+ metadata.gz: 5ad19f85347f51987f1a255fe74a2a4916eb5142
4
+ data.tar.gz: dc414922b4275665bf3b8e17bf7a2cf3421e6072
5
5
  SHA512:
6
- metadata.gz: baacf19c3123b119826cf461249f880c55816c21125565e819f065d4b854bffd492f726ae5abf1a799f4de581e412266f207fce25cef30df784c164685f88518
7
- data.tar.gz: 5f4cc8959474d1fc41674537d09c786ec96c4098545a4e8a603fa4b9f04b4f8b215c8ab0775d04cceb3ed830b4e1e8197dee7501c5b14b34e88132f6cf259014
6
+ metadata.gz: ba5c169a4137855ca8e7c2c11e103c7a6063e5eea198ce3b32a9d1fa93323a359a6fe7d064a9783b2a65fc3ab5a550f585cb533910c196a98912c86083b7daf9
7
+ data.tar.gz: ce52b5baa783a5e515ca7692e5d786e1cc61d3443d294d55a5cca7856d6852d98fb7bd16f79350959fb6f06872c6159611e75bd3c97c4de68f645fbb6f9581fd
data/.travis.yml CHANGED
@@ -1,4 +1,8 @@
1
+ sudo: false
2
+ before_install:
3
+ - gem install bundler
1
4
  rvm:
2
5
  - 1.9.3
3
6
  - 2.0.0
4
7
  - 2.1.0
8
+ - 2.2.0
@@ -51,7 +51,7 @@ module FrozenRecord
51
51
  :minimum, :maximum, :average, :sum, to: :current_scope
52
52
 
53
53
  def file_path
54
- raise "You must define `#{name}.base_path`" unless base_path
54
+ fail ArgumentError, "You must define `#{name}.base_path`" unless base_path
55
55
  File.join(base_path, "#{name.underscore.pluralize}.yml")
56
56
  end
57
57
 
@@ -85,7 +85,10 @@ module FrozenRecord
85
85
 
86
86
  def load_records
87
87
  @records ||= begin
88
- records = YAML.load_file(file_path) || []
88
+ yml_erb_data = File.read(file_path)
89
+ yml_data = ERB.new(yml_erb_data).result
90
+
91
+ records = YAML.load(yml_data) || []
89
92
  define_attributes!(list_attributes(records))
90
93
  records.map(&method(:new)).freeze
91
94
  end
@@ -1,3 +1,3 @@
1
1
  module FrozenRecord
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  - id: 1
3
3
  name: Canada
4
- capital: Ottawa
4
+ capital: <%= 'Ottawa' %>
5
5
  density: 3.5
6
6
  population: 33.88
7
7
  founded_on: 1867-07-01
@@ -11,7 +11,7 @@
11
11
 
12
12
  - id: 2
13
13
  name: France
14
- capital: Paris
14
+ capital: <%= 'Paris' %>
15
15
  density: 116
16
16
  population: 65.7
17
17
  founded_on: 486-01-01
@@ -19,7 +19,7 @@
19
19
 
20
20
  - id: 3
21
21
  name: Austria
22
- capital: Vienna
22
+ capital: <%= 'Vienna' %>
23
23
  density: 100.3
24
24
  population: 8.462
25
25
  founded_on: 1156-01-01
@@ -5,10 +5,19 @@ describe FrozenRecord::Base do
5
5
  describe '.base_path' do
6
6
 
7
7
  it 'raise a RuntimeError on first query attempt if not set' do
8
- Country.stub(:base_path).and_return(nil)
8
+ allow(Country).to receive_message_chain(:base_path).and_return(nil)
9
9
  expect {
10
10
  Country.file_path
11
- }.to raise_error
11
+ }.to raise_error(ArgumentError)
12
+ end
13
+
14
+ end
15
+
16
+ describe '#load_records' do
17
+
18
+ it 'processes erb' do
19
+ country = Country.first
20
+ expect(country.capital).to be == 'Ottawa'
12
21
  end
13
22
 
14
23
  end
data/spec/spec_helper.rb CHANGED
@@ -17,7 +17,6 @@ FrozenRecord::Base.base_path = File.join(File.dirname(__FILE__), 'fixtures')
17
17
  Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
18
18
 
19
19
  RSpec.configure do |config|
20
- config.treat_symbols_as_metadata_keys_with_true_values = true
21
20
  config.run_all_when_everything_filtered = true
22
21
  config.filter_run :focus
23
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frozen_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -152,4 +152,3 @@ test_files:
152
152
  - spec/spec_helper.rb
153
153
  - spec/support/car.rb
154
154
  - spec/support/country.rb
155
- has_rdoc: