datashift 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.document +5 -5
  2. data/LICENSE.txt +26 -26
  3. data/README.markdown +305 -303
  4. data/README.rdoc +19 -19
  5. data/Rakefile +93 -93
  6. data/VERSION +1 -1
  7. data/datashift-0.1.0.gem +0 -0
  8. data/datashift.gemspec +152 -136
  9. data/lib/applications/jruby/jexcel_file.rb +408 -408
  10. data/lib/applications/jruby/word.rb +79 -79
  11. data/lib/datashift.rb +152 -152
  12. data/lib/datashift/exceptions.rb +11 -11
  13. data/lib/datashift/file_definitions.rb +353 -353
  14. data/lib/datashift/mapping_file_definitions.rb +87 -87
  15. data/lib/datashift/method_detail.rb +275 -275
  16. data/lib/datashift/method_dictionary.rb +209 -209
  17. data/lib/datashift/method_mapper.rb +90 -90
  18. data/lib/generators/csv_generator.rb +36 -36
  19. data/lib/generators/excel_generator.rb +122 -122
  20. data/lib/generators/generator_base.rb +13 -13
  21. data/lib/helpers/core_ext/to_b.rb +24 -24
  22. data/lib/helpers/spree_helper.rb +153 -155
  23. data/lib/java/poi-3.7/LICENSE +507 -507
  24. data/lib/java/poi-3.7/NOTICE +21 -21
  25. data/lib/java/poi-3.7/RELEASE_NOTES.txt +115 -115
  26. data/lib/loaders/csv_loader.rb +98 -98
  27. data/lib/loaders/excel_loader.rb +155 -155
  28. data/lib/loaders/loader_base.rb +420 -420
  29. data/lib/loaders/spreadsheet_loader.rb +136 -136
  30. data/lib/loaders/spree/image_loader.rb +63 -64
  31. data/lib/loaders/spree/product_loader.rb +248 -250
  32. data/public/spree/products/large/DEMO_001_ror_bag.jpeg +0 -0
  33. data/public/spree/products/large/DEMO_002_Powerstation.jpg +0 -0
  34. data/public/spree/products/large/DEMO_003_ror_mug.jpeg +0 -0
  35. data/public/spree/products/mini/DEMO_001_ror_bag.jpeg +0 -0
  36. data/public/spree/products/mini/DEMO_002_Powerstation.jpg +0 -0
  37. data/public/spree/products/mini/DEMO_003_ror_mug.jpeg +0 -0
  38. data/public/spree/products/original/DEMO_001_ror_bag.jpeg +0 -0
  39. data/public/spree/products/original/DEMO_002_Powerstation.jpg +0 -0
  40. data/public/spree/products/original/DEMO_003_ror_mug.jpeg +0 -0
  41. data/public/spree/products/product/DEMO_001_ror_bag.jpeg +0 -0
  42. data/public/spree/products/product/DEMO_002_Powerstation.jpg +0 -0
  43. data/public/spree/products/product/DEMO_003_ror_mug.jpeg +0 -0
  44. data/public/spree/products/small/DEMO_001_ror_bag.jpeg +0 -0
  45. data/public/spree/products/small/DEMO_002_Powerstation.jpg +0 -0
  46. data/public/spree/products/small/DEMO_003_ror_mug.jpeg +0 -0
  47. data/spec/csv_loader_spec.rb +30 -30
  48. data/spec/datashift_spec.rb +26 -26
  49. data/spec/db/migrate/20110803201325_create_test_bed.rb +85 -85
  50. data/spec/excel_exporter_spec.rb +78 -78
  51. data/spec/excel_generator_spec.rb +78 -78
  52. data/spec/excel_loader_spec.rb +223 -223
  53. data/spec/file_definitions.rb +141 -141
  54. data/spec/fixtures/ProjectsDefaults.yml +29 -29
  55. data/spec/fixtures/config/database.yml +27 -24
  56. data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
  57. data/spec/fixtures/interact_models_db.sqlite +0 -0
  58. data/spec/fixtures/negative/SpreeProdMiss1Mandatory.csv +4 -4
  59. data/spec/fixtures/negative/SpreeProdMissManyMandatory.csv +4 -4
  60. data/spec/fixtures/spree/SpreeProducts.csv +4 -4
  61. data/spec/fixtures/spree/SpreeProductsMultiColumn.csv +4 -4
  62. data/spec/fixtures/spree/SpreeProductsSimple.csv +4 -4
  63. data/spec/fixtures/spree/SpreeProductsWithImages.csv +4 -0
  64. data/spec/fixtures/spree/SpreeZoneExample.csv +5 -5
  65. data/spec/fixtures/test_model_defs.rb +57 -57
  66. data/spec/loader_spec.rb +120 -120
  67. data/spec/method_dictionary_spec.rb +242 -242
  68. data/spec/method_mapper_spec.rb +41 -41
  69. data/spec/spec_helper.rb +116 -116
  70. data/spec/spree_generator_spec.rb +64 -64
  71. data/spec/spree_loader_spec.rb +324 -327
  72. data/spec/spree_method_mapping_spec.rb +214 -214
  73. data/tasks/config/seed_fu_product_template.erb +15 -15
  74. data/tasks/config/tidy_config.txt +12 -12
  75. data/tasks/db_tasks.rake +65 -65
  76. data/tasks/excel_generator.rake +78 -78
  77. data/tasks/file_tasks.rake +36 -36
  78. data/tasks/import/csv.rake +49 -49
  79. data/tasks/import/excel.rake +71 -71
  80. data/tasks/spree/image_load.rake +108 -108
  81. data/tasks/spree/product_loader.rake +43 -43
  82. data/tasks/word_to_seedfu.rake +166 -166
  83. data/test/helper.rb +18 -18
  84. data/test/test_interact.rb +7 -7
  85. metadata +22 -3
  86. data/spec/fixtures/interact_spree_db.sqlite +0 -0
@@ -1,36 +1,36 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- # Details:: Export a model to CSV
7
- #
8
- #
9
- require 'generator_base'
10
-
11
- module DataShift
12
-
13
- class CsvGenerator < GeneratorBase
14
-
15
- attr_accessor :excel, :filename
16
-
17
- def initialize(filename)
18
- @excel = nil
19
- @filename = filename
20
- end
21
-
22
- # Create CSV file representing supplied Model
23
-
24
- def generate(model, options = {})
25
-
26
- @filename = options[:filename] if options[:filename]
27
- end
28
-
29
-
30
- # Create an Csv file representing supplied Model
31
-
32
- def export(items, options = {})
33
- end
34
-
35
- end
36
- end
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2011
4
+ # License:: MIT
5
+ #
6
+ # Details:: Export a model to CSV
7
+ #
8
+ #
9
+ require 'generator_base'
10
+
11
+ module DataShift
12
+
13
+ class CsvGenerator < GeneratorBase
14
+
15
+ attr_accessor :excel, :filename
16
+
17
+ def initialize(filename)
18
+ @excel = nil
19
+ @filename = filename
20
+ end
21
+
22
+ # Create CSV file representing supplied Model
23
+
24
+ def generate(model, options = {})
25
+
26
+ @filename = options[:filename] if options[:filename]
27
+ end
28
+
29
+
30
+ # Create an Csv file representing supplied Model
31
+
32
+ def export(items, options = {})
33
+ end
34
+
35
+ end
36
+ end
@@ -1,123 +1,123 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- # Details:: Export a model to Excel '97(-2007) file format.
7
- #
8
- # TOD : Can we switch between .xls and XSSF (POI implementation of Excel 2007 OOXML (.xlsx) file format.)
9
- #
10
- #
11
- module DataShift
12
-
13
- require 'generator_base'
14
-
15
- if(Guards::jruby?)
16
-
17
- require 'jruby/jexcel_file'
18
-
19
- class ExcelGenerator < GeneratorBase
20
-
21
- attr_accessor :filename
22
-
23
- def initialize(filename)
24
- @filename = filename
25
- end
26
-
27
- # Create an Excel file template (header row) representing supplied Model
28
-
29
- def generate(model, options = {})
30
- MethodDictionary.find_operators( model )
31
-
32
- @filename = options[:filename] if options[:filename]
33
-
34
- excel = JExcelFile.new()
35
-
36
- if(options[:sheet_name] )
37
- excel.create_sheet( options[:sheet_name] )
38
- else
39
- excel.create_sheet( model.name )
40
- end
41
-
42
- raise "Failed to create Excel WorkSheet for #{model.name}" unless excel.sheet
43
-
44
- excel.set_headers(MethodDictionary.assignments[model])
45
-
46
- excel.save( @filename )
47
- end
48
-
49
-
50
- # Create an Excel file from list of ActiveRecord objects
51
- def export(records, options = {})
52
-
53
- excel = JExcelFile.new()
54
-
55
- if(options[:sheet_name] )
56
- excel.create_sheet( options[:sheet_name] )
57
- else
58
- excel.create_sheet( records.first.class.name )
59
- end
60
-
61
- excel.ar_to_headers(records)
62
-
63
- excel.ar_to_xls(records)
64
-
65
- excel.save( filename() )
66
- end
67
-
68
- # Create an Excel file from list of ActiveRecord objects
69
- # Specify which associations to export via :with or :exclude
70
- # Possible values are : [:assignment, :belongs_to, :has_one, :has_many]
71
- #
72
- def export_with_associations(klass, items, options = {})
73
-
74
- excel = JExcelFile.new()
75
-
76
- if(options[:sheet_name] )
77
- excel.create_sheet( options[:sheet_name] )
78
- else
79
- excel.create_sheet( items.first.class.name )
80
- end
81
-
82
- MethodDictionary.find_operators( klass )
83
-
84
- MethodDictionary.build_method_details( klass )
85
-
86
- work_list = (options[:with]) ? options[:with] : [:assignments, :belongs_to, :has_one, :has_many]
87
-
88
- headers = []
89
-
90
- work_list.each do |mdtype|
91
- method_details = MethodDictionary.send("#{mdtype}_for", klass)
92
-
93
- method_details.each {|md| headers << "#{md.operator}" }
94
- end
95
-
96
- excel.set_headers( headers )
97
-
98
- data = []
99
-
100
- items.each do |record|
101
-
102
- MethodMapper.method_details[klass].each do |method_detail|
103
- if(method_detail.operator_type == :assignment)
104
- data << record.send( method_detail.operator )
105
- end
106
- end
107
- end
108
-
109
- excel.set_row(2,1,items)
110
-
111
- excel.save( filename() )
112
- end
113
- end # ExcelGenerator
114
-
115
- else
116
- class ExcelGenerator < GeneratorBase
117
- def initialize
118
- raise DataShift::BadRuby, "Please install and use JRuby for working with .xls files"
119
- end
120
- end
121
- end # jruby
122
-
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2011
4
+ # License:: MIT
5
+ #
6
+ # Details:: Export a model to Excel '97(-2007) file format.
7
+ #
8
+ # TOD : Can we switch between .xls and XSSF (POI implementation of Excel 2007 OOXML (.xlsx) file format.)
9
+ #
10
+ #
11
+ module DataShift
12
+
13
+ require 'generator_base'
14
+
15
+ if(Guards::jruby?)
16
+
17
+ require 'jruby/jexcel_file'
18
+
19
+ class ExcelGenerator < GeneratorBase
20
+
21
+ attr_accessor :filename
22
+
23
+ def initialize(filename)
24
+ @filename = filename
25
+ end
26
+
27
+ # Create an Excel file template (header row) representing supplied Model
28
+
29
+ def generate(model, options = {})
30
+ MethodDictionary.find_operators( model )
31
+
32
+ @filename = options[:filename] if options[:filename]
33
+
34
+ excel = JExcelFile.new()
35
+
36
+ if(options[:sheet_name] )
37
+ excel.create_sheet( options[:sheet_name] )
38
+ else
39
+ excel.create_sheet( model.name )
40
+ end
41
+
42
+ raise "Failed to create Excel WorkSheet for #{model.name}" unless excel.sheet
43
+
44
+ excel.set_headers(MethodDictionary.assignments[model])
45
+
46
+ excel.save( @filename )
47
+ end
48
+
49
+
50
+ # Create an Excel file from list of ActiveRecord objects
51
+ def export(records, options = {})
52
+
53
+ excel = JExcelFile.new()
54
+
55
+ if(options[:sheet_name] )
56
+ excel.create_sheet( options[:sheet_name] )
57
+ else
58
+ excel.create_sheet( records.first.class.name )
59
+ end
60
+
61
+ excel.ar_to_headers(records)
62
+
63
+ excel.ar_to_xls(records)
64
+
65
+ excel.save( filename() )
66
+ end
67
+
68
+ # Create an Excel file from list of ActiveRecord objects
69
+ # Specify which associations to export via :with or :exclude
70
+ # Possible values are : [:assignment, :belongs_to, :has_one, :has_many]
71
+ #
72
+ def export_with_associations(klass, items, options = {})
73
+
74
+ excel = JExcelFile.new()
75
+
76
+ if(options[:sheet_name] )
77
+ excel.create_sheet( options[:sheet_name] )
78
+ else
79
+ excel.create_sheet( items.first.class.name )
80
+ end
81
+
82
+ MethodDictionary.find_operators( klass )
83
+
84
+ MethodDictionary.build_method_details( klass )
85
+
86
+ work_list = (options[:with]) ? options[:with] : [:assignments, :belongs_to, :has_one, :has_many]
87
+
88
+ headers = []
89
+
90
+ work_list.each do |mdtype|
91
+ method_details = MethodDictionary.send("#{mdtype}_for", klass)
92
+
93
+ method_details.each {|md| headers << "#{md.operator}" }
94
+ end
95
+
96
+ excel.set_headers( headers )
97
+
98
+ data = []
99
+
100
+ items.each do |record|
101
+
102
+ MethodMapper.method_details[klass].each do |method_detail|
103
+ if(method_detail.operator_type == :assignment)
104
+ data << record.send( method_detail.operator )
105
+ end
106
+ end
107
+ end
108
+
109
+ excel.set_row(2,1,items)
110
+
111
+ excel.save( filename() )
112
+ end
113
+ end # ExcelGenerator
114
+
115
+ else
116
+ class ExcelGenerator < GeneratorBase
117
+ def initialize
118
+ raise DataShift::BadRuby, "Please install and use JRuby for working with .xls files"
119
+ end
120
+ end
121
+ end # jruby
122
+
123
123
  end # DataShift
@@ -1,14 +1,14 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2010
4
- # License:: MIT
5
- #
6
- # Details:: Base class for generators, which provide serivrs to describe a Model in an external format
7
- #
8
- module DataShift
9
-
10
- class GeneratorBase
11
-
12
- end
13
-
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2010
4
+ # License:: MIT
5
+ #
6
+ # Details:: Base class for generators, which provide serivrs to describe a Model in an external format
7
+ #
8
+ module DataShift
9
+
10
+ class GeneratorBase
11
+
12
+ end
13
+
14
14
  end
@@ -1,24 +1,24 @@
1
- class Object
2
- def to_b
3
- case self
4
- when true, false then self
5
- when nil then false
6
- else
7
- to_i != 0
8
- end
9
- end
10
- end
11
-
12
- class String
13
- TRUE_REGEXP = /^(yes|true|on|t|1|\-1)$/i.freeze
14
- FALSE_REGEXP = /^(no|false|off|f|0)$/i.freeze
15
-
16
- def to_b
17
- case self
18
- when TRUE_REGEXP then true
19
- when FALSE_REGEXP then false
20
- else
21
- to_i != 0
22
- end
23
- end
24
- end
1
+ class Object
2
+ def to_b
3
+ case self
4
+ when true, false then self
5
+ when nil then false
6
+ else
7
+ to_i != 0
8
+ end
9
+ end
10
+ end
11
+
12
+ class String
13
+ TRUE_REGEXP = /^(yes|true|on|t|1|\-1)$/i.freeze
14
+ FALSE_REGEXP = /^(no|false|off|f|0)$/i.freeze
15
+
16
+ def to_b
17
+ case self
18
+ when TRUE_REGEXP then true
19
+ when FALSE_REGEXP then false
20
+ else
21
+ to_i != 0
22
+ end
23
+ end
24
+ end
@@ -1,155 +1,153 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- # Details:: Spree Helper mixing in Support for testing or loading Rails Spree e-commerce.
7
- #
8
- # The Spree version you want to test should be picked up from the Gemfile
9
- #
10
- # Since datashift gem is not a Rails app or a Spree App, provides utilities to internally
11
- # create a Spree Database, and to load Spree components, enabling standalone testing.
12
- #
13
- # => Has been tested with
14
- #
15
- # # => TODO - Can we move to a Gemfile/bunlder
16
- # require 'rubygems'
17
- # gemfile = File.expand_path("<%= gemfile_path %>", __FILE__)
18
- #
19
- # ENV['BUNDLE_GEMFILE'] = gemfile
20
- # require 'bundler'
21
- # Bundler.setup
22
- #
23
- # => TODO - See if we can improve DB creation/migration ....
24
- # N.B Some or all of Spree Tests may fail very first time run,
25
- # as the database is auto generated
26
- # =>
27
- module Spree
28
-
29
- def self.root
30
- Gem.loaded_specs['spree_core'] ? Gem.loaded_specs['spree_core'].full_gem_path : ""
31
- end
32
-
33
- def self.lib_root
34
- File.join(root, 'lib')
35
- end
36
-
37
- def self.app_root
38
- File.join(root, 'app')
39
- end
40
-
41
- def self.load()
42
- gem 'spree'
43
- end
44
-
45
- def self.boot
46
-
47
- require 'spree'
48
- require 'spree_core'
49
-
50
- #require 'rake'
51
- #require 'rubygems/package_task'
52
- #require 'thor/group'
53
- require File.expand_path( lib_root + '/generators/spree/install/install_generator')
54
- require 'spree/core/testing_support/common_rake'
55
-
56
-
57
- Spree::SandboxGenerator.start ["--lib_name=spree", "--database=#{ENV['DB_NAME']}"]
58
- Spree::InstallGenerator.start ["--auto-accept"]
59
-
60
- cmd = "bundle exec rake assets:precompile:nondigest";
61
- puts cmd; system cmd
62
-
63
-
64
- return
65
-
66
-
67
- # TODO how to check gem version actually loaded and do conditional
68
- #
69
- #if(PRE 1)
70
- #require 'spree_core/preferences/model_hooks'
71
- #
72
- ## Initialize preference system
73
- # ActiveRecord::Base.class_eval do
74
- # include Spree::Preferences
75
- # include Spree::Preferences::ModelHooks
76
- # end
77
- #end
78
-
79
- gem 'paperclip'
80
- gem 'nested_set'
81
-
82
- require 'nested_set'
83
- require 'paperclip'
84
- require 'acts_as_list'
85
-
86
- CollectiveIdea::Acts::NestedSet::Railtie.extend_active_record
87
- ActiveRecord::Base.send(:include, Paperclip::Glue)
88
-
89
- gem 'activemerchant'
90
- require 'active_merchant'
91
- require 'active_merchant/billing/gateway'
92
-
93
- ActiveRecord::Base.send(:include, ActiveMerchant::Billing)
94
-
95
-
96
- #require 'scopes'
97
-
98
- # Not sure how Rails manages this seems lots of circular dependencies so
99
- # keep trying stuff till no more errors
100
-
101
- Dir[lib_root + '/*.rb'].each do |r|
102
- begin
103
- require r if File.file?(r)
104
- rescue => e
105
- end
106
- end
107
-
108
- Dir[lib_root + '/**/*.rb'].each do |r|
109
- begin
110
- require r if File.file?(r) && ! r.include?('testing') && ! r.include?('generators')
111
- rescue => e
112
- end
113
- end
114
-
115
- load_models( true )
116
-
117
- Dir[lib_root + '/*.rb'].each do |r|
118
- begin
119
- require r if File.file?(r)
120
- rescue => e
121
- end
122
- end
123
-
124
- Dir[lib_root + '/**/*.rb'].each do |r|
125
- begin
126
- require r if File.file?(r) && ! r.include?('testing') && ! r.include?('generators')
127
- rescue => e
128
- end
129
- end
130
-
131
- #if(PRE 1)require 'product'
132
- #require 'lib/product_filters'
133
-
134
-
135
- load_models( true )
136
-
137
- end
138
-
139
- def self.load_models( report_errors = nil )
140
- puts 'Loading Spree models from', root
141
- Dir[root + '/app/models/**/*.rb'].each {|r|
142
- begin
143
- require r if File.file?(r)
144
- rescue => e
145
- puts("WARNING failed to load #{r}", e.inspect) if(report_errors == true)
146
- end
147
- }
148
- end
149
-
150
- def self.migrate_up
151
- load
152
- ActiveRecord::Migrator.up( File.join(root, 'db/migrate') )
153
- end
154
-
155
- end
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2011
4
+ # License:: MIT
5
+ #
6
+ # Details:: Spree Helper mixing in Support for testing or loading Rails Spree e-commerce.
7
+ #
8
+ # The Spree version you want to test should be picked up from the Gemfile
9
+ #
10
+ # Since datashift gem is not a Rails app or a Spree App, provides utilities to internally
11
+ # create a Spree Database, and to load Spree components, enabling standalone testing.
12
+ #
13
+ # => Has been tested with 0.7
14
+ #
15
+ # # => TODO - Can we move to a Gemfile/bunlder
16
+ # require 'rubygems'
17
+ # gemfile = File.expand_path("<%= gemfile_path %>", __FILE__)
18
+ #
19
+ # ENV['BUNDLE_GEMFILE'] = gemfile
20
+ # require 'bundler'
21
+ # Bundler.setup
22
+ #
23
+ # => TODO - See if we can improve DB creation/migration ....
24
+ # N.B Some or all of Spree Tests may fail very first time run,
25
+ # as the database is auto generated
26
+ # =>
27
+ module Spree
28
+
29
+ def self.root
30
+ Gem.loaded_specs['spree_core'] ? Gem.loaded_specs['spree_core'].full_gem_path : ""
31
+ end
32
+
33
+ def self.lib_root
34
+ File.join(root, 'lib')
35
+ end
36
+
37
+ def self.app_root
38
+ File.join(root, 'app')
39
+ end
40
+
41
+ def self.load()
42
+ gem 'spree'
43
+ end
44
+
45
+ def self.boot
46
+
47
+ require 'spree'
48
+ require 'spree_core'
49
+
50
+ if(Gem.loaded_specs['spree'].version.version.to_f < 1)
51
+ boot_pre_1
52
+ else
53
+ require File.expand_path( lib_root + '/generators/spree/install/install_generator')
54
+ require 'spree/core/testing_support/common_rake'
55
+
56
+
57
+ Spree::SandboxGenerator.start ["--lib_name=spree", "--database=#{ENV['DB_NAME']}"]
58
+ Spree::InstallGenerator.start ["--auto-accept"]
59
+
60
+ cmd = "bundle exec rake assets:precompile:nondigest";
61
+ puts cmd; system cmd
62
+ end
63
+ end
64
+
65
+ def self.boot_pre_1
66
+
67
+ require 'rake'
68
+ require 'rubygems/package_task'
69
+ require 'thor/group'
70
+
71
+ require 'spree_core/preferences/model_hooks'
72
+ #
73
+ # Initialize preference system
74
+ ActiveRecord::Base.class_eval do
75
+ include Spree::Preferences
76
+ include Spree::Preferences::ModelHooks
77
+ end
78
+
79
+ gem 'paperclip'
80
+ gem 'nested_set'
81
+
82
+ require 'nested_set'
83
+ require 'paperclip'
84
+ require 'acts_as_list'
85
+
86
+ CollectiveIdea::Acts::NestedSet::Railtie.extend_active_record
87
+ ActiveRecord::Base.send(:include, Paperclip::Glue)
88
+
89
+ gem 'activemerchant'
90
+ require 'active_merchant'
91
+ require 'active_merchant/billing/gateway'
92
+
93
+ ActiveRecord::Base.send(:include, ActiveMerchant::Billing)
94
+
95
+ require 'scopes'
96
+
97
+ # Not sure how Rails manages this seems lots of circular dependencies so
98
+ # keep trying stuff till no more errors
99
+
100
+ Dir[lib_root + '/*.rb'].each do |r|
101
+ begin
102
+ require r if File.file?(r)
103
+ rescue => e
104
+ end
105
+ end
106
+
107
+ Dir[lib_root + '/**/*.rb'].each do |r|
108
+ begin
109
+ require r if File.file?(r) && ! r.include?('testing') && ! r.include?('generators')
110
+ rescue => e
111
+ end
112
+ end
113
+
114
+ load_models( true )
115
+
116
+ Dir[lib_root + '/*.rb'].each do |r|
117
+ begin
118
+ require r if File.file?(r)
119
+ rescue => e
120
+ end
121
+ end
122
+
123
+ Dir[lib_root + '/**/*.rb'].each do |r|
124
+ begin
125
+ require r if File.file?(r) && ! r.include?('testing') && ! r.include?('generators')
126
+ rescue => e
127
+ end
128
+ end
129
+
130
+ # require 'lib/product_filters'
131
+
132
+ load_models( true )
133
+
134
+ end
135
+
136
+ def self.load_models( report_errors = nil )
137
+ puts 'Loading Spree models from', root
138
+ Dir[root + '/app/models/**/*.rb'].each {|r|
139
+ begin
140
+ require r if File.file?(r)
141
+ rescue => e
142
+ puts("WARNING failed to load #{r}", e.inspect) if(report_errors == true)
143
+ end
144
+ }
145
+ end
146
+
147
+ def self.migrate_up
148
+ load
149
+ boot
150
+ ActiveRecord::Migrator.up( File.join(root, 'db/migrate') )
151
+ end
152
+
153
+ end