activerecord-simpledb-adapter 0.2.0 → 0.2.1
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/activerecord-simpledb-adapter.gemspec +1 -1
- data/lib/tasks/simpledb.rake +12 -15
- data/spec/tasks/rake_spec.rb +1 -4
- metadata +3 -3
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-simpledb-adapter}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ilia Ablamonov", "Alex Gorkunov", "Cloud Castle Inc."]
|
data/lib/tasks/simpledb.rake
CHANGED
@@ -34,18 +34,15 @@ namespace :db do
|
|
34
34
|
|
35
35
|
namespace :collection do
|
36
36
|
desc "Clear all data for collection by name"
|
37
|
-
task :clear, [:name
|
38
|
-
ccn = args[:ccn] || 'collection'
|
37
|
+
task :clear, [:name] => :environment do |t, args|
|
39
38
|
name = args[:name]
|
40
39
|
if name.present?
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
:wheres => {:id => row['id']}
|
46
|
-
})
|
47
|
-
log "#{row.count} items was deleted."
|
40
|
+
count = 0
|
41
|
+
Kernel.const_get(name.capitalize).all.each do |item|
|
42
|
+
item.destroy
|
43
|
+
count += 1
|
48
44
|
end
|
45
|
+
log "#{count} items was deleted."
|
49
46
|
else
|
50
47
|
log "Please put collection name as \"name=<collection_name>\""
|
51
48
|
end
|
@@ -57,15 +54,15 @@ namespace :db do
|
|
57
54
|
log "Sdb domain \"#{domain_name}\" was created"
|
58
55
|
end
|
59
56
|
|
60
|
-
def config
|
61
|
-
@config ||= ActiveRecord::Base.configurations[Rails.env]
|
62
|
-
end
|
63
|
-
|
64
57
|
def domain_name
|
65
|
-
|
58
|
+
conf[:domain_name] || conf['domain_name']
|
59
|
+
end
|
60
|
+
|
61
|
+
def conf
|
62
|
+
@conf ||= ActiveRecord::Base.configurations[Rails.env]
|
66
63
|
end
|
67
64
|
|
68
65
|
def log text
|
69
|
-
|
66
|
+
puts text
|
70
67
|
end
|
71
68
|
end
|
data/spec/tasks/rake_spec.rb
CHANGED
@@ -71,11 +71,8 @@ describe "gem rake tasks" do
|
|
71
71
|
@rake[@task_name].arg_names.should include(:name)
|
72
72
|
end
|
73
73
|
|
74
|
-
it "should receive param with name \"ccn\"" do
|
75
|
-
@rake[@task_name].arg_names.should include(:ccn)
|
76
|
-
end
|
77
74
|
it "should clear collection by name" do
|
78
|
-
@rake[@task_name].invoke("
|
75
|
+
@rake[@task_name].invoke("person")
|
79
76
|
Person.count.should == 0
|
80
77
|
end
|
81
78
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-simpledb-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ilia Ablamonov
|