plain_record 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -3,6 +3,8 @@ bundler_args: --without development
3
3
  rvm:
4
4
  - 1.8.7
5
5
  - 1.9.3
6
+ - 2.0.0
6
7
  - jruby-18mode
8
+ - jruby-19mode
7
9
  - rbx-18mode
8
10
  - rbx-19mode
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.4.1 (Diphosgene)
2
+ * Add Psych support to work with Ruby 2.0.
3
+
1
4
  == 0.4 (Phosgene)
2
5
  * Allow to store images.
3
6
  * Allow to store field in separated file.
data/Gemfile.lock CHANGED
@@ -6,7 +6,7 @@ GEM
6
6
  r18n-core (1.1.3)
7
7
  rake (10.0.3)
8
8
  redcarpet (2.2.2)
9
- rmagick (2.13.1)
9
+ rmagick (2.13.2)
10
10
  rspec (2.12.0)
11
11
  rspec-core (~> 2.12.0)
12
12
  rspec-expectations (~> 2.12.0)
@@ -14,8 +14,8 @@ GEM
14
14
  rspec-core (2.12.2)
15
15
  rspec-expectations (2.12.1)
16
16
  diff-lcs (~> 1.1.3)
17
- rspec-mocks (2.12.1)
18
- yard (0.8.3)
17
+ rspec-mocks (2.12.2)
18
+ yard (0.8.4.1)
19
19
 
20
20
  PLATFORMS
21
21
  ruby
data/lib/plain_record.rb CHANGED
@@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
  require 'pathname'
22
22
  require 'yaml'
23
23
 
24
- YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
25
-
26
24
  dir = Pathname(__FILE__).dirname.expand_path + 'plain_record'
27
25
  require dir + 'version'
28
26
  require dir + 'callbacks'
@@ -86,7 +86,7 @@ module PlainRecord
86
86
  def save_file(file)
87
87
  if @loaded.has_key? file
88
88
  ::File.open(file, 'w') do |io|
89
- io << entries_string(@loaded[file]).slice(5..-1)
89
+ io << entries_string(@loaded[file]).sub(/^---\s+/, '')
90
90
  end
91
91
  end
92
92
  end
@@ -57,7 +57,8 @@ module PlainRecord
57
57
  end
58
58
 
59
59
  def entries_string(entry)
60
- entry.to_yaml + entry.texts.map{ |i| "---\n" + i }.join("\n")
60
+ entry.data_recursive.to_yaml +
61
+ entry.texts.map { |i| "---\n" + i }.join("\n")
61
62
  end
62
63
  end
63
64
  end
@@ -68,7 +68,7 @@ module PlainRecord
68
68
  end
69
69
 
70
70
  def entries_string(entries)
71
- entries.to_yaml
71
+ entries.map { |i| i.data_recursive }.to_yaml
72
72
  end
73
73
  end
74
74
  end
@@ -119,9 +119,17 @@ module PlainRecord
119
119
  end
120
120
  end
121
121
 
122
- # Return string of YAML representation of entry +data+.
123
- def to_yaml(opts = { })
124
- @data.to_yaml(opts)
122
+ # Return model data with plain hash of all child data
123
+ def data_recursive
124
+ hash = { }
125
+ @data.each_pair do |key, value|
126
+ hash[key] = if value.respond_to? :data_recursive
127
+ value.data_recursive
128
+ else
129
+ value
130
+ end
131
+ end
132
+ hash
125
133
  end
126
134
 
127
135
  # Compare if its fields and texts are equal.
@@ -1,3 +1,3 @@
1
1
  module PlainRecord
2
- VERSION = '0.4' unless defined? PlainRecord::VERSION
2
+ VERSION = '0.4.1' unless defined? PlainRecord::VERSION
3
3
  end
data/spec/image_spec.rb CHANGED
@@ -72,6 +72,8 @@ describe PlainRecord::Extra::Image do
72
72
  File.should_receive(:exists?).
73
73
  with(PlainRecord.root('a/photo.png')).and_return(true)
74
74
 
75
+ FileUtils.stub!(:mkpath)
76
+ FileUtils.should_receive(:mkpath).with('images/data')
75
77
  FileUtils.stub!(:cp)
76
78
  FileUtils.should_receive(:cp).
77
79
  with(PlainRecord.root('a/photo.png'), 'images/data/photo..png')
@@ -84,6 +86,9 @@ describe PlainRecord::Extra::Image do
84
86
  File.should_receive(:exists?).
85
87
  with(PlainRecord.root('a/logo.png')).and_return(true)
86
88
 
89
+ FileUtils.stub!(:mkpath)
90
+ FileUtils.should_receive(:mkpath).with('images/data')
91
+
87
92
  thumb = double('thumb')
88
93
  thumb.stub!(:write)
89
94
  thumb.should_receive(:write).with('images/data/logo.small.png')
@@ -28,14 +28,13 @@ describe PlainRecord::Resource do
28
28
  first = Post.first(:title => 'First')
29
29
  first.save
30
30
 
31
- file.rewind
32
- file.read.should == "title: First\n" +
33
- "---\n" +
34
- "first --- content\n" +
35
- "---\n" +
36
- "big\n" +
37
- "---\n" +
38
- "content\n"
31
+ file.string.should == "title: First\n" +
32
+ "---\n" +
33
+ "first --- content\n" +
34
+ "---\n" +
35
+ "big\n" +
36
+ "---\n" +
37
+ "content\n"
39
38
  end
40
39
 
41
40
  it "should save list entry" do
data/spec/spec_helper.rb CHANGED
@@ -55,10 +55,13 @@ RSpec::Matchers.define :has_methods do |*methods|
55
55
  end
56
56
  end
57
57
 
58
- RSpec::Matchers.define :has_yaml do |data|
59
- match do |file|
60
- file.rewind
61
- YAML.load(file.read).should == data
58
+ RSpec::Matchers.define :has_yaml do |expected|
59
+ match do |actual|
60
+ YAML.load(actual.string).should == expected
61
+ end
62
+
63
+ failure_message_for_should do |actual|
64
+ "expected #{expected.inspect} to equal #{YAML.load(actual.string)}"
62
65
  end
63
66
  end
64
67
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: plain_record
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: '0.4'
5
+ version: 0.4.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrey "A.I." Sitnik
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-22 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  - !ruby/object:Gem::Version
229
229
  segments:
230
230
  - 0
231
- hash: -1633277468961939816
231
+ hash: -3581892843472371509
232
232
  version: '0'
233
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  none: false