activerecord-simpledb-adapter 0.4.9 → 0.4.10
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.
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-simpledb-adapter}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.10"
|
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."]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-09}
|
13
13
|
s.email = %q{ilia@flamefork.ru}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -171,6 +171,7 @@ module ActiveRecord
|
|
171
171
|
response = @connection.select(sql, nil, true)
|
172
172
|
end
|
173
173
|
collection_name = get_collection_column_and_name(sql)
|
174
|
+
collection_column_name = collection_column_name(collection_name)
|
174
175
|
columns = columns_definition(collection_name)
|
175
176
|
|
176
177
|
response[:items].each do |item|
|
@@ -178,11 +179,14 @@ module ActiveRecord
|
|
178
179
|
ritem = {}
|
179
180
|
ritem['id'] = id unless id == 'Domain' && attrs['Count'] # unless count(*) result
|
180
181
|
attrs.each {|k, vs|
|
181
|
-
column
|
182
|
-
if
|
183
|
-
|
184
|
-
|
185
|
-
|
182
|
+
# skip collection column (detect collection)
|
183
|
+
if k != collection_column_name
|
184
|
+
column = columns[k]
|
185
|
+
if column.present?
|
186
|
+
ritem[column.name] = column.unconvert(vs.first)
|
187
|
+
else
|
188
|
+
ritem[k] = vs.first
|
189
|
+
end
|
186
190
|
end
|
187
191
|
}
|
188
192
|
result << ritem
|
data/lib/tasks/simpledb.rake
CHANGED
@@ -30,7 +30,42 @@ namespace :db do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "Re-create the domain and initialize with the seed data"
|
33
|
-
task :setup => [:recreate, :seed]
|
33
|
+
task :setup => [:recreate, :import, :seed]
|
34
|
+
|
35
|
+
desc "Export collections from sdb to seeds.yml"
|
36
|
+
task :export, [:collections]=> :environment do |t, args|
|
37
|
+
collections = args[:collections].try(:split, ',')
|
38
|
+
data = ActiveSupport::OrderedHash.new
|
39
|
+
if collections
|
40
|
+
collections.each do |c|
|
41
|
+
data[c] = []
|
42
|
+
c.classify.constantize.all.each { |item| data[c] << item.attributes }
|
43
|
+
end
|
44
|
+
File.open(dump_file, "w") do |out|
|
45
|
+
YAML.dump(data, out)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
log "Please put collections name as \"collections=<first>,<second>...\""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Import collections from seeds.yml to sdb"
|
53
|
+
task :import => :environment do
|
54
|
+
if File.exists? dump_file
|
55
|
+
data = YAML.load_file(dump_file)
|
56
|
+
data.each_pair do |entity, values|
|
57
|
+
cls = entity.classify.constantize
|
58
|
+
cls.destroy_all
|
59
|
+
|
60
|
+
values.each { |val|
|
61
|
+
created_obj = cls.create! val
|
62
|
+
}
|
63
|
+
end
|
64
|
+
log "Data from seeds.yml file was pushed to domain"
|
65
|
+
else
|
66
|
+
log "File seeds.yml not found. Import skipped."
|
67
|
+
end
|
68
|
+
end
|
34
69
|
|
35
70
|
namespace :collection do
|
36
71
|
desc "Clear all data for collection by name"
|
@@ -65,4 +100,8 @@ namespace :db do
|
|
65
100
|
def log text
|
66
101
|
puts text
|
67
102
|
end
|
103
|
+
|
104
|
+
def dump_file
|
105
|
+
@dump_file ||= File.join(Rails.root, 'db', 'seeds.yml')
|
106
|
+
end
|
68
107
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 10
|
10
|
+
version: 0.4.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ilia Ablamonov
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-07-
|
20
|
+
date: 2011-07-09 00:00:00 +04:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|