datashift 0.8.0 → 0.9.0

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.
Files changed (37) hide show
  1. data/README.markdown +12 -0
  2. data/Rakefile +4 -2
  3. data/VERSION +1 -1
  4. data/datashift.gemspec +13 -12
  5. data/lib/datashift/delimiters.rb +87 -0
  6. data/lib/datashift/method_detail.rb +5 -0
  7. data/lib/datashift/method_details_manager.rb +5 -1
  8. data/lib/datashift/method_dictionary.rb +3 -1
  9. data/lib/exporters/csv_exporter.rb +158 -10
  10. data/lib/exporters/excel_exporter.rb +6 -2
  11. data/lib/exporters/exporter_base.rb +6 -0
  12. data/lib/helpers/spree_helper.rb +2 -1
  13. data/lib/loaders/paperclip/image_loader.rb +32 -2
  14. data/lib/loaders/spree/product_loader.rb +3 -2
  15. data/lib/thor/export.thor +111 -0
  16. data/lib/thor/{import_excel.thor → import.thor} +40 -2
  17. data/lib/thor/spree/bootstrap_cleanup.thor +7 -4
  18. data/lib/thor/spree/products_images.thor +26 -17
  19. data/lib/thor/spree/reports.thor +30 -40
  20. data/lib/thor/tools.thor +63 -0
  21. data/spec/Gemfile +3 -2
  22. data/spec/csv_exporter_spec.rb +101 -0
  23. data/spec/excel_exporter_spec.rb +1 -1
  24. data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
  25. data/spec/fixtures/datashift_test_models_db.sqlite +0 -0
  26. data/spec/fixtures/test_model_defs.rb +5 -0
  27. data/spec/spree_loader_spec.rb +28 -131
  28. data/spec/spree_method_mapping_spec.rb +1 -1
  29. data/spec/spree_variants_loader_spec.rb +189 -0
  30. metadata +193 -167
  31. data/lib/thor/export_excel.thor +0 -74
  32. data/sandbox/app/controllers/application_controller.rb +0 -3
  33. data/sandbox/config/application.rb +0 -59
  34. data/sandbox/config/database.yml +0 -20
  35. data/sandbox/config/environment.rb +0 -5
  36. data/sandbox/config/environments/development.rb +0 -37
  37. data/tasks/import/csv.rake +0 -51
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- if defined?(Bundler)
6
- # If you precompile assets before deploying to production, use this line
7
- Bundler.require(*Rails.groups(:assets => %w(development test)))
8
- # If you want your assets lazily compiled in production, use this line
9
- # Bundler.require(:default, :assets, Rails.env)
10
- end
11
-
12
- module Sandbox
13
- class Application < Rails::Application
14
- # Settings in config/environments/* take precedence over those specified here.
15
- # Application configuration should go into files in config/initializers
16
- # -- all .rb files in that directory are automatically loaded.
17
-
18
- # Custom directories with classes and modules you want to be autoloadable.
19
- # config.autoload_paths += %W(#{config.root}/extras)
20
-
21
- # Only load the plugins named here, in the order given (default is alphabetical).
22
- # :all can be used as a placeholder for all plugins not explicitly named.
23
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
-
25
- # Activate observers that should always be running.
26
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
-
28
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
- # config.time_zone = 'Central Time (US & Canada)'
31
-
32
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
- # config.i18n.default_locale = :de
35
-
36
- # Configure the default encoding used in templates for Ruby 1.9.
37
- config.encoding = "utf-8"
38
-
39
- # Configure sensitive parameters which will be filtered from the log file.
40
- config.filter_parameters += [:password]
41
-
42
- # Use SQL instead of Active Record's schema dumper when creating the database.
43
- # This is necessary if your schema can't be completely dumped by the schema dumper,
44
- # like if you have constraints or database-specific column types
45
- # config.active_record.schema_format = :sql
46
-
47
- # Enforce whitelist mode for mass assignment.
48
- # This will create an empty whitelist of attributes available for mass-assignment for all models
49
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
50
- # parameters by using an attr_accessible or attr_protected declaration.
51
- config.active_record.whitelist_attributes = true
52
-
53
- # Enable the asset pipeline
54
- config.assets.enabled = true
55
-
56
- # Version of your assets, change this if you want to expire all your assets
57
- config.assets.version = '1.0'
58
- end
59
- end
@@ -1,20 +0,0 @@
1
- # SQLite version 3.x
2
- # gem 'activerecord-jdbcsqlite3-adapter'
3
- #
4
- # Configure Using Gemfile
5
- # gem 'activerecord-jdbcsqlite3-adapter'
6
- #
7
- development:
8
- adapter: sqlite3
9
- database: db/development.sqlite3
10
-
11
- # Warning: The database defined as "test" will be erased and
12
- # re-generated from your development database when you run "rake".
13
- # Do not set this db to the same as development or production.
14
- test:
15
- adapter: sqlite3
16
- database: db/test.sqlite3
17
-
18
- production:
19
- adapter: sqlite3
20
- database: db/production.sqlite3
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Sandbox::Application.initialize!
@@ -1,37 +0,0 @@
1
- Sandbox::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
37
- end
@@ -1,51 +0,0 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- # Usage::
7
- #
8
- # In Rakefile:
9
- #
10
- # require 'datashift'
11
- #
12
- # DataShift::load_tasks
13
- #
14
- # Cmd Line:
15
- #
16
- # => jruby -S rake datashift:import:csv model=<active record class> input=<file.csv>
17
- #
18
- namespace :datashift do
19
-
20
- namespace :import do
21
-
22
- desc "Populate a model's table in db with data from CSV file"
23
- task :csv, [:model, :loader, :input, :verbose] => [:environment] do |t, args|
24
-
25
- # in familiar ruby style args seems to have been become empty with rake 0.9.2 whatever i try
26
- # so had to revert back to ENV
27
- model = ENV['model']
28
- input = ENV['input']
29
-
30
- raise "USAGE: rake datashift:import:csv input=file.csv model=<Class>" unless(input)
31
- raise "ERROR: Cannot process without AR Model - please supply model=<Class>" unless(model)
32
- raise "ERROR: Could not find csv file #{args[:input]}" unless File.exists?(input)
33
-
34
- require 'csv_loader'
35
-
36
- begin
37
- # support modules e.g "Spree::Property")
38
- klass = ModelMapper::class_from_string(model) #Kernel.const_get(model)
39
- rescue NameError
40
- raise "ERROR: No such AR Model found - check valid model supplied via model=<Class>"
41
- end
42
-
43
- puts "INFO: Using CSV loader"
44
-
45
- loader = DataShift::CsvLoader.new(klass)
46
-
47
- loader.perform_load(input)
48
- end
49
- end
50
-
51
- end