datashift 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +12 -0
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/datashift.gemspec +13 -12
- data/lib/datashift/delimiters.rb +87 -0
- data/lib/datashift/method_detail.rb +5 -0
- data/lib/datashift/method_details_manager.rb +5 -1
- data/lib/datashift/method_dictionary.rb +3 -1
- data/lib/exporters/csv_exporter.rb +158 -10
- data/lib/exporters/excel_exporter.rb +6 -2
- data/lib/exporters/exporter_base.rb +6 -0
- data/lib/helpers/spree_helper.rb +2 -1
- data/lib/loaders/paperclip/image_loader.rb +32 -2
- data/lib/loaders/spree/product_loader.rb +3 -2
- data/lib/thor/export.thor +111 -0
- data/lib/thor/{import_excel.thor → import.thor} +40 -2
- data/lib/thor/spree/bootstrap_cleanup.thor +7 -4
- data/lib/thor/spree/products_images.thor +26 -17
- data/lib/thor/spree/reports.thor +30 -40
- data/lib/thor/tools.thor +63 -0
- data/spec/Gemfile +3 -2
- data/spec/csv_exporter_spec.rb +101 -0
- data/spec/excel_exporter_spec.rb +1 -1
- data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
- data/spec/fixtures/datashift_test_models_db.sqlite +0 -0
- data/spec/fixtures/test_model_defs.rb +5 -0
- data/spec/spree_loader_spec.rb +28 -131
- data/spec/spree_method_mapping_spec.rb +1 -1
- data/spec/spree_variants_loader_spec.rb +189 -0
- metadata +193 -167
- data/lib/thor/export_excel.thor +0 -74
- data/sandbox/app/controllers/application_controller.rb +0 -3
- data/sandbox/config/application.rb +0 -59
- data/sandbox/config/database.yml +0 -20
- data/sandbox/config/environment.rb +0 -5
- data/sandbox/config/environments/development.rb +0 -37
- data/tasks/import/csv.rake +0 -51
metadata
CHANGED
@@ -1,203 +1,229 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datashift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 59
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
|
-
|
13
|
+
- Thomas Statter
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2012-
|
18
|
+
date: 2012-09-03 00:00:00 Z
|
14
19
|
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
requirement: *id001
|
31
|
+
prerelease: false
|
32
|
+
name: spreadsheet
|
33
|
+
type: :runtime
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
hash: 3
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
requirement: *id002
|
45
|
+
prerelease: false
|
46
|
+
name: rubyzip
|
47
|
+
type: :runtime
|
48
|
+
description: Comprehensive Excel and CSV import/export tools. Shift data between ActiveRecord databases, applications, and projects like Spree
|
27
49
|
email: rubygems@autotelik.co.uk
|
28
50
|
executables: []
|
29
51
|
|
30
52
|
extensions: []
|
31
53
|
|
32
54
|
extra_rdoc_files:
|
33
|
-
|
34
|
-
|
35
|
-
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.markdown
|
57
|
+
- README.rdoc
|
36
58
|
files:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
- test/helper.rb
|
176
|
-
- test/test_interact.rb
|
59
|
+
- .document
|
60
|
+
- LICENSE.txt
|
61
|
+
- README.markdown
|
62
|
+
- README.rdoc
|
63
|
+
- Rakefile
|
64
|
+
- VERSION
|
65
|
+
- datashift.gemspec
|
66
|
+
- lib/applications/jruby/jexcel_file.rb
|
67
|
+
- lib/applications/jruby/word.rb
|
68
|
+
- lib/datashift.rb
|
69
|
+
- lib/datashift/delimiters.rb
|
70
|
+
- lib/datashift/exceptions.rb
|
71
|
+
- lib/datashift/file_definitions.rb
|
72
|
+
- lib/datashift/logging.rb
|
73
|
+
- lib/datashift/mapping_file_definitions.rb
|
74
|
+
- lib/datashift/method_detail.rb
|
75
|
+
- lib/datashift/method_details_manager.rb
|
76
|
+
- lib/datashift/method_dictionary.rb
|
77
|
+
- lib/datashift/method_mapper.rb
|
78
|
+
- lib/datashift/model_mapper.rb
|
79
|
+
- lib/datashift/populator.rb
|
80
|
+
- lib/exporters/csv_exporter.rb
|
81
|
+
- lib/exporters/excel_exporter.rb
|
82
|
+
- lib/exporters/exporter_base.rb
|
83
|
+
- lib/generators/csv_generator.rb
|
84
|
+
- lib/generators/excel_generator.rb
|
85
|
+
- lib/generators/generator_base.rb
|
86
|
+
- lib/helpers/core_ext/to_b.rb
|
87
|
+
- lib/helpers/rake_utils.rb
|
88
|
+
- lib/helpers/spree_helper.rb
|
89
|
+
- lib/java/poi-3.7/._poi-3.7-20101029.jar5645100390082102460.tmp
|
90
|
+
- lib/java/poi-3.7/LICENSE
|
91
|
+
- lib/java/poi-3.7/NOTICE
|
92
|
+
- lib/java/poi-3.7/RELEASE_NOTES.txt
|
93
|
+
- lib/java/poi-3.7/lib/commons-logging-1.1.jar
|
94
|
+
- lib/java/poi-3.7/lib/junit-3.8.1.jar
|
95
|
+
- lib/java/poi-3.7/lib/log4j-1.2.13.jar
|
96
|
+
- lib/java/poi-3.7/ooxml-lib/dom4j-1.6.1.jar
|
97
|
+
- lib/java/poi-3.7/ooxml-lib/geronimo-stax-api_1.0_spec-1.0.jar
|
98
|
+
- lib/java/poi-3.7/ooxml-lib/xmlbeans-2.3.0.jar
|
99
|
+
- lib/java/poi-3.7/poi-3.7-20101029.jar
|
100
|
+
- lib/java/poi-3.7/poi-examples-3.7-20101029.jar
|
101
|
+
- lib/java/poi-3.7/poi-ooxml-3.7-20101029.jar
|
102
|
+
- lib/java/poi-3.7/poi-ooxml-schemas-3.7-20101029.jar
|
103
|
+
- lib/java/poi-3.7/poi-scratchpad-3.7-20101029.jar
|
104
|
+
- lib/loaders/csv_loader.rb
|
105
|
+
- lib/loaders/excel_loader.rb
|
106
|
+
- lib/loaders/loader_base.rb
|
107
|
+
- lib/loaders/paperclip/image_loader.rb
|
108
|
+
- lib/loaders/spreadsheet_loader.rb
|
109
|
+
- lib/loaders/spree/image_loader.rb
|
110
|
+
- lib/loaders/spree/product_loader.rb
|
111
|
+
- lib/thor/export.thor
|
112
|
+
- lib/thor/generate_excel.thor
|
113
|
+
- lib/thor/import.thor
|
114
|
+
- lib/thor/spree/bootstrap_cleanup.thor
|
115
|
+
- lib/thor/spree/products_images.thor
|
116
|
+
- lib/thor/spree/reports.thor
|
117
|
+
- lib/thor/tools.thor
|
118
|
+
- public/spree/products/large/DEMO_001_ror_bag.jpeg
|
119
|
+
- public/spree/products/large/DEMO_002_Powerstation.jpg
|
120
|
+
- public/spree/products/large/DEMO_003_ror_mug.jpeg
|
121
|
+
- public/spree/products/mini/DEMO_001_ror_bag.jpeg
|
122
|
+
- public/spree/products/mini/DEMO_002_Powerstation.jpg
|
123
|
+
- public/spree/products/mini/DEMO_003_ror_mug.jpeg
|
124
|
+
- public/spree/products/original/DEMO_001_ror_bag.jpeg
|
125
|
+
- public/spree/products/original/DEMO_002_Powerstation.jpg
|
126
|
+
- public/spree/products/original/DEMO_003_ror_mug.jpeg
|
127
|
+
- public/spree/products/product/DEMO_001_ror_bag.jpeg
|
128
|
+
- public/spree/products/product/DEMO_002_Powerstation.jpg
|
129
|
+
- public/spree/products/product/DEMO_003_ror_mug.jpeg
|
130
|
+
- public/spree/products/small/DEMO_001_ror_bag.jpeg
|
131
|
+
- public/spree/products/small/DEMO_002_Powerstation.jpg
|
132
|
+
- public/spree/products/small/DEMO_003_ror_mug.jpeg
|
133
|
+
- spec/Gemfile
|
134
|
+
- spec/csv_exporter_spec.rb
|
135
|
+
- spec/csv_loader_spec.rb
|
136
|
+
- spec/datashift_spec.rb
|
137
|
+
- spec/db/migrate/20110803201325_create_test_bed.rb
|
138
|
+
- spec/excel_exporter_spec.rb
|
139
|
+
- spec/excel_generator_spec.rb
|
140
|
+
- spec/excel_loader_spec.rb
|
141
|
+
- spec/file_definitions.rb
|
142
|
+
- spec/fixtures/BadAssociationName.xls
|
143
|
+
- spec/fixtures/DemoNegativeTesting.xls
|
144
|
+
- spec/fixtures/ProjectsDefaults.yml
|
145
|
+
- spec/fixtures/ProjectsMultiCategories.xls
|
146
|
+
- spec/fixtures/ProjectsMultiCategoriesHeaderLookup.xls
|
147
|
+
- spec/fixtures/ProjectsSingleCategories.xls
|
148
|
+
- spec/fixtures/SimpleProjects.xls
|
149
|
+
- spec/fixtures/config/database.yml
|
150
|
+
- spec/fixtures/datashift_Spree_db.sqlite
|
151
|
+
- spec/fixtures/datashift_test_models_db.sqlite
|
152
|
+
- spec/fixtures/images/DEMO_001_ror_bag.jpeg
|
153
|
+
- spec/fixtures/images/DEMO_002_Powerstation.jpg
|
154
|
+
- spec/fixtures/images/DEMO_003_ror_mug.jpeg
|
155
|
+
- spec/fixtures/images/DEMO_004_ror_ringer.jpeg
|
156
|
+
- spec/fixtures/negative/SpreeProdMiss1Mandatory.csv
|
157
|
+
- spec/fixtures/negative/SpreeProdMiss1Mandatory.xls
|
158
|
+
- spec/fixtures/negative/SpreeProdMissManyMandatory.csv
|
159
|
+
- spec/fixtures/negative/SpreeProdMissManyMandatory.xls
|
160
|
+
- spec/fixtures/simple_export_spec.xls
|
161
|
+
- spec/fixtures/simple_template_spec.xls
|
162
|
+
- spec/fixtures/spree/SpreeImages.xls
|
163
|
+
- spec/fixtures/spree/SpreeMultiVariant.csv
|
164
|
+
- spec/fixtures/spree/SpreeProducts.csv
|
165
|
+
- spec/fixtures/spree/SpreeProducts.xls
|
166
|
+
- spec/fixtures/spree/SpreeProductsDefaults.yml
|
167
|
+
- spec/fixtures/spree/SpreeProductsMandatoryOnly.xls
|
168
|
+
- spec/fixtures/spree/SpreeProductsMultiColumn.csv
|
169
|
+
- spec/fixtures/spree/SpreeProductsMultiColumn.xls
|
170
|
+
- spec/fixtures/spree/SpreeProductsSimple.csv
|
171
|
+
- spec/fixtures/spree/SpreeProductsSimple.xls
|
172
|
+
- spec/fixtures/spree/SpreeProductsWithImages.csv
|
173
|
+
- spec/fixtures/spree/SpreeProductsWithImages.xls
|
174
|
+
- spec/fixtures/spree/SpreeZoneExample.csv
|
175
|
+
- spec/fixtures/spree/SpreeZoneExample.xls
|
176
|
+
- spec/fixtures/test_model_defs.rb
|
177
|
+
- spec/loader_spec.rb
|
178
|
+
- spec/method_dictionary_spec.rb
|
179
|
+
- spec/method_mapper_spec.rb
|
180
|
+
- spec/spec_helper.rb
|
181
|
+
- spec/spree_exporter_spec.rb
|
182
|
+
- spec/spree_generator_spec.rb
|
183
|
+
- spec/spree_images_loader_spec.rb
|
184
|
+
- spec/spree_loader_spec.rb
|
185
|
+
- spec/spree_method_mapping_spec.rb
|
186
|
+
- spec/spree_variants_loader_spec.rb
|
187
|
+
- spec/thor_spec.rb
|
188
|
+
- tasks/config/seed_fu_product_template.erb
|
189
|
+
- tasks/config/tidy_config.txt
|
190
|
+
- tasks/db_tasks.rake
|
191
|
+
- tasks/export/excel_generator.rake
|
192
|
+
- tasks/file_tasks.rake
|
193
|
+
- tasks/import/excel.rake
|
194
|
+
- tasks/word_to_seedfu.rake
|
195
|
+
- test/helper.rb
|
196
|
+
- test/test_interact.rb
|
177
197
|
homepage: http://github.com/autotelik/datashift
|
178
198
|
licenses:
|
179
|
-
|
199
|
+
- MIT
|
180
200
|
post_install_message:
|
181
201
|
rdoc_options: []
|
182
202
|
|
183
203
|
require_paths:
|
184
|
-
|
204
|
+
- lib
|
185
205
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
206
|
none: false
|
187
207
|
requirements:
|
188
|
-
|
189
|
-
|
190
|
-
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
hash: 3
|
211
|
+
segments:
|
212
|
+
- 0
|
213
|
+
version: "0"
|
191
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
215
|
none: false
|
193
216
|
requirements:
|
194
|
-
|
195
|
-
|
196
|
-
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
hash: 3
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
version: "0"
|
197
223
|
requirements: []
|
198
224
|
|
199
225
|
rubyforge_project:
|
200
|
-
rubygems_version: 1.8.
|
226
|
+
rubygems_version: 1.8.24
|
201
227
|
signing_key:
|
202
228
|
specification_version: 3
|
203
229
|
summary: Shift data betwen applications and Active Record
|
data/lib/thor/export_excel.thor
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Copyright:: (c) Autotelik Media Ltd 2012
|
2
|
-
# Author :: Tom Statter
|
3
|
-
# Date :: April 2012
|
4
|
-
# License:: MIT.
|
5
|
-
#
|
6
|
-
# Usage::
|
7
|
-
#
|
8
|
-
# To pull Datashift commands into your main application :
|
9
|
-
#
|
10
|
-
# require 'datashift'
|
11
|
-
#
|
12
|
-
# DataShift::load_commands
|
13
|
-
#
|
14
|
-
# Cmd Line:
|
15
|
-
#
|
16
|
-
# => bundle exec thor datashift:export:excel -m <active record class> -r <output_template.xls> -a
|
17
|
-
#
|
18
|
-
require 'datashift'
|
19
|
-
|
20
|
-
# Note, not DataShift, case sensitive, create namespace for command line : datashift
|
21
|
-
module Datashift
|
22
|
-
|
23
|
-
|
24
|
-
class Export < Thor
|
25
|
-
|
26
|
-
include DataShift::Logging
|
27
|
-
|
28
|
-
desc "excel", "export any active record model (with optional associations)"
|
29
|
-
method_option :model, :aliases => '-m', :required => true, :desc => "The active record model to export"
|
30
|
-
method_option :result, :aliases => '-r', :required => true, :desc => "Create template of model in supplied file"
|
31
|
-
method_option :assoc, :aliases => '-a', :type => :boolean, :desc => "Include all associations in the template"
|
32
|
-
method_option :exclude, :aliases => '-e', :type => :array, :desc => "Use with -a : Exclude association types. Any from #{DataShift::MethodDetail::supported_types_enum.to_a.inspect}"
|
33
|
-
|
34
|
-
def excel()
|
35
|
-
|
36
|
-
# TODO - We're assuming run from a rails app/top level dir...
|
37
|
-
# ...can we make this more robust ? e.g what about when using active record but not in Rails app,
|
38
|
-
require File.expand_path('config/environment.rb')
|
39
|
-
|
40
|
-
require 'excel_exporter'
|
41
|
-
|
42
|
-
model = options[:model]
|
43
|
-
result = options[:result]
|
44
|
-
|
45
|
-
logger.info "Datashift: Start Excel export to #{result}"
|
46
|
-
|
47
|
-
begin
|
48
|
-
# support modules e.g "Spree::Property")
|
49
|
-
klass = ModelMapper::class_from_string(model) #Kernel.const_get(model)
|
50
|
-
rescue NameError => e
|
51
|
-
puts e
|
52
|
-
raise "ERROR: No such Model [#{model}] found - check valid model supplied via -model <Class>"
|
53
|
-
end
|
54
|
-
|
55
|
-
begin
|
56
|
-
gen = DataShift::ExcelExporter.new(result)
|
57
|
-
|
58
|
-
if(options[:assoc])
|
59
|
-
opts = (options[:exclude]) ? {:exclude => options[:exclude]} : {}
|
60
|
-
logger.info("Datashift: Exporting with associations")
|
61
|
-
gen.generate_with_associations(klass, opts)
|
62
|
-
else
|
63
|
-
gen.generate(klass)
|
64
|
-
end
|
65
|
-
rescue => e
|
66
|
-
puts e
|
67
|
-
puts e.backtrace
|
68
|
-
puts "Warning: Error during export, data may be incomplete"
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|