pottery 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +1 -1
- data/lib/pottery.rb +19 -2
- data/pottery.gemspec +4 -4
- data/spec/pottery_spec.rb +4 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
m.rubyforge_name = "pottery"
|
13
13
|
m.rdoc_options << '--inline-source'
|
14
14
|
m.rdoc_pattern = ["README", "CHANGELOG", "LICENSE"]
|
15
|
-
m.dependencies = ["soup
|
15
|
+
m.dependencies = ["soup =0.2.1", "morph >=0.1.5"]
|
16
16
|
end
|
17
17
|
|
18
18
|
rescue LoadError
|
data/lib/pottery.rb
CHANGED
@@ -2,7 +2,7 @@ require 'morph'
|
|
2
2
|
require 'soup'
|
3
3
|
|
4
4
|
module Pottery
|
5
|
-
VERSION = "0.1.
|
5
|
+
VERSION = "0.1.2"
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
Soup.prepare
|
@@ -20,6 +20,12 @@ module Pottery
|
|
20
20
|
def restore name
|
21
21
|
snip = Soup[name]
|
22
22
|
if snip && snip != []
|
23
|
+
if snip.is_a? Array
|
24
|
+
last = snip.pop
|
25
|
+
puts 'deleting duplicates for id: ' + name
|
26
|
+
snip.each {|x| x.destroy}
|
27
|
+
snip = last
|
28
|
+
end
|
23
29
|
instance = self.new
|
24
30
|
attributes = snip.attributes
|
25
31
|
unless attributes.empty?
|
@@ -40,7 +46,18 @@ module Pottery
|
|
40
46
|
|
41
47
|
def save
|
42
48
|
if respond_to?('id_name') && !id_name.nil? && !(id_name.to_s.strip.size == 0)
|
43
|
-
|
49
|
+
existing = Soup[id_name]
|
50
|
+
if existing && existing != []
|
51
|
+
if existing.is_a? Array
|
52
|
+
last = existing.pop
|
53
|
+
puts 'deleting duplicates for id: ' + id_name
|
54
|
+
existing.each {|x| x.destroy}
|
55
|
+
existing = last
|
56
|
+
end
|
57
|
+
snip = Pottery::PotterySnip.new existing.attributes.merge({:__id => existing.id})
|
58
|
+
else
|
59
|
+
snip = Pottery::PotterySnip.new
|
60
|
+
end
|
44
61
|
morph_attributes.each_pair do |symbol, value|
|
45
62
|
symbol = convert_if_name_or_id_name(symbol)
|
46
63
|
snip.set_value(symbol.to_s, value)
|
data/pottery.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{pottery}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Rob McKinnon"]
|
@@ -24,16 +24,16 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.specification_version = 2
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<soup>, ["
|
27
|
+
s.add_runtime_dependency(%q<soup>, ["= 0.2.1"])
|
28
28
|
s.add_runtime_dependency(%q<morph>, [">= 0.1.5"])
|
29
29
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<soup>, ["
|
31
|
+
s.add_dependency(%q<soup>, ["= 0.2.1"])
|
32
32
|
s.add_dependency(%q<morph>, [">= 0.1.5"])
|
33
33
|
s.add_dependency(%q<echoe>, [">= 0"])
|
34
34
|
end
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<soup>, ["
|
36
|
+
s.add_dependency(%q<soup>, ["= 0.2.1"])
|
37
37
|
s.add_dependency(%q<morph>, [">= 0.1.5"])
|
38
38
|
s.add_dependency(%q<echoe>, [">= 0"])
|
39
39
|
end
|
data/spec/pottery_spec.rb
CHANGED
@@ -52,6 +52,7 @@ describe Pottery, "when save method is called after id_name has been set" do
|
|
52
52
|
initialize_pottery_and_snip
|
53
53
|
@pottery.id_name = 'red'
|
54
54
|
@snip.should_receive(:save)
|
55
|
+
Soup.should_receive('[]'.to_sym).with('red').and_return []
|
55
56
|
@pottery.save
|
56
57
|
end
|
57
58
|
|
@@ -61,6 +62,7 @@ describe Pottery, "when save method is called after id_name has been set" do
|
|
61
62
|
|
62
63
|
@snip.stub!(:save)
|
63
64
|
@snip.should_receive(:set_value).with('name', 'red')
|
65
|
+
Soup.should_receive('[]'.to_sym).with('red').and_return []
|
64
66
|
@pottery.save
|
65
67
|
end
|
66
68
|
end
|
@@ -76,6 +78,7 @@ describe Pottery, "when save method is called after name and id_name has been se
|
|
76
78
|
@pottery.id_name = 'red'
|
77
79
|
@pottery.name = 'blue'
|
78
80
|
@snip.should_receive(:save)
|
81
|
+
Soup.should_receive('[]'.to_sym).with('red').and_return []
|
79
82
|
@pottery.save
|
80
83
|
end
|
81
84
|
|
@@ -87,6 +90,7 @@ describe Pottery, "when save method is called after name and id_name has been se
|
|
87
90
|
@snip.stub!(:save)
|
88
91
|
@snip.should_receive(:set_value).with('name', 'red')
|
89
92
|
@snip.should_receive(:set_value).with('name_name', 'blue')
|
93
|
+
Soup.should_receive('[]'.to_sym).with('red').and_return []
|
90
94
|
@pottery.save
|
91
95
|
end
|
92
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pottery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob McKinnon
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.2.1
|
24
24
|
version:
|