ar_loader 0.0.4 → 0.0.6

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.
@@ -1,138 +1,99 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe 'ExcelLoader' do
4
-
5
- before do
6
- @klazz = Product
7
- MethodMapper.clear
8
- end
9
-
10
- it "should populate operators for a given AR model" do
11
- MethodMapper.find_operators( @klazz )
12
-
13
- MethodMapper.has_many.should_not be_empty
14
- MethodMapper.assignments.should_not be_empty
15
-
16
- hmf = MethodMapper.has_many_for(@klazz)
17
- arf = MethodMapper.assignments_for(@klazz)
18
-
19
- (hmf & arf).should_not be_empty # Associations provide << or =
20
-
21
- hmf.should include('properties')
22
- arf.should include('count_on_hand') # example of a column
23
- arf.should include('cost_price') # example of delegated assignment (available through Variant)
24
-
25
- MethodMapper.column_types.should be_is_a(Hash)
26
- MethodMapper.column_types.should_not be_empty
27
-
28
- MethodMapper.column_type_for(@klazz, 'count_on_hand').should_not be_nil
29
- end
30
-
31
- it "should populate operators respecting unique option" do
32
- MethodMapper.find_operators( @klazz, :unique => true )
33
-
34
- hmf = MethodMapper.has_many_for(@klazz)
35
- arf = MethodMapper.assignments_for(@klazz)
36
-
37
- (hmf & arf).should be_empty
38
- end
39
-
40
- it "should populate assignment method and col type for different forms of a column name" do
41
-
42
- MethodMapper.find_operators( @klazz )
43
-
44
- ["Count On hand", 'count_on_hand', "Count OnHand", "COUNT ONHand"].each do |format|
45
- mmap = MethodMapper.determine_calls( @klazz, format )
46
-
47
- mmap.class.should == MethodDetail
48
-
49
- mmap.assignment.should == 'count_on_hand='
50
- mmap.has_many.should be_nil
51
-
52
- mmap.col_type.should_not be_nil
53
- mmap.col_type.name.should == 'count_on_hand'
54
- mmap.col_type.default.should == 0
55
- mmap.col_type.sql_type.should == 'int(10)'
56
- mmap.col_type.type.should == :integer
57
- end
58
- end
59
-
60
- it "should populate both methods for different forms of an association name" do
61
-
62
- MethodMapper.find_operators( @klazz )
63
- ["product_option_types", "product option types", 'product Option_types', "ProductOptionTypes", "Product_Option_Types"].each do |format|
64
- mmap = MethodMapper.determine_calls( @klazz, format )
65
-
66
- mmap.assignment.should == 'product_option_types='
67
- mmap.has_many.should == 'product_option_types'
68
-
69
- mmap.col_type.should be_nil
70
- end
71
- end
72
-
73
-
74
- it "should not populate anything when non existent column name" do
75
- ["On sale", 'on_sale'].each do |format|
76
- mmap = MethodMapper.determine_calls( @klazz, format )
77
-
78
- mmap.class.should == MethodDetail
79
- mmap.assignment.should be_nil
80
- mmap.has_many.should be_nil
81
- mmap.col_type.should be_nil
82
- end
83
- end
84
-
85
- it "should enable correct assignment and sending of a value to AR model" do
86
-
87
- MethodMapper.find_operators( @klazz )
88
-
89
- mmap = MethodMapper.determine_calls( @klazz, 'count on hand' )
90
- mmap.assignment.should == 'count_on_hand='
91
-
92
- x = @klazz.new
93
-
94
- x.should be_new_record
95
-
96
- x.send( mmap.assignment, 2 )
97
- x.count_on_hand.should == 2
98
- x.on_hand.should == 2 # helper method I know looks at same thing
99
-
100
- mmap = MethodMapper.determine_calls( @klazz, 'SKU' )
101
- mmap.assignment.should == 'sku='
102
- x.send( mmap.assignment, 'TEST_SK 001' )
103
- x.sku.should == 'TEST_SK 001'
104
- end
105
-
106
- it "should enable correct assignment and sending of association to AR model" do
107
-
108
- MethodMapper.find_operators( @klazz )
109
-
110
- mmap = MethodMapper.determine_calls( @klazz, 'taxons' )
111
- mmap.has_many.should == 'taxons'
112
-
113
- x = @klazz.new
114
-
115
- # NEW ASSOCIATION ASSIGNMENT v.,mn
116
- x.send( mmap.has_many ) << Taxon.new
117
- x.taxons.size.should == 1
118
-
119
- x.send( mmap.has_many ) << [Taxon.new, Taxon.new]
120
- x.taxons.size.should == 3
121
-
122
- # EXISTING ASSOCIATIONS
123
- x = Product.find :first
124
-
125
- t = Taxonomy.find_or_create_by_name( 'BlahSpecTest' )
126
-
127
- if x
128
- sz = x.taxons.size
129
- x.send(mmap.has_many) << t.root
130
- x.taxons.size.should == sz + 1
131
- else
132
- puts "WARNING : Test not run could not find any Test Products"
133
- end
134
-
135
- end
136
-
137
-
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ require 'erb'
4
+ require File.dirname(__FILE__) + '/../lib/ar_loader'
5
+
6
+ # We are not setup as a Rails project so need to mimic an active record database setup so
7
+ # we have some AR models top test against. Create an in memory database from scratch.
8
+ #
9
+ def db_connect( env = 'test')
10
+
11
+ configuration = {:rails_env => env }
12
+
13
+ # Some active record stuff seems to rely on the RAILS_ENV being set ?
14
+
15
+ ENV['RAILS_ENV'] = configuration[:rails_env]
16
+
17
+ configuration[:database_configuration] = YAML::load(ERB.new(IO.read( File.dirname(__FILE__) + '/database.yml')).result)
18
+ db = configuration[:database_configuration][ configuration[:rails_env] ]
19
+
20
+ puts "Setting DB Config - #{db.inspect}"
21
+ ActiveRecord::Base.configurations = db
22
+
23
+ puts "Connecting to DB"
24
+ ActiveRecord::Base.establish_connection( db )
25
+
26
+ puts "Connected to DB Config - #{configuration[:rails_env]}"
27
+ end
28
+
29
+ def create_in_memory_database
30
+ ActiveRecord::Migrator.up('db/migrate')
31
+ end
32
+
33
+
34
+ class TestModel < ActiveRecord::Base
35
+ has_many :TestAssociationModel
36
+ end
37
+
38
+ class TestAssociationModel < ActiveRecord::Base
39
+ belongs_to :test_model
40
+ end
41
+
42
+ describe 'ExcelLoader' do
43
+
44
+ before do
45
+ db_connect
46
+ create_in_memory_database
47
+ @klazz = TestModel
48
+ MethodMapper.clear
49
+ end
50
+
51
+ it "should populate operators for a given AR model" do
52
+ MethodMapper.find_operators( @klazz )
53
+
54
+ MethodMapper.has_many.should_not be_empty
55
+ MethodMapper.assignments.should_not be_empty
56
+
57
+ hmf = MethodMapper.has_many_for(@klazz)
58
+ arf = MethodMapper.assignments_for(@klazz)
59
+
60
+ (hmf & arf).should_not be_empty # Associations provide << or =
61
+
62
+ MethodMapper.column_types.should be_is_a(Hash)
63
+ MethodMapper.column_types.should_not be_empty
64
+
65
+ end
66
+
67
+ it "should populate operators respecting unique option" do
68
+ MethodMapper.find_operators( @klazz, :unique => true )
69
+
70
+ hmf = MethodMapper.has_many_for(@klazz)
71
+ arf = MethodMapper.assignments_for(@klazz)
72
+
73
+ (hmf & arf).should be_empty
74
+ end
75
+
76
+ it "should populate assignment method and col type for different forms of a column name" do
77
+
78
+ MethodMapper.find_operators( @klazz )
79
+ end
80
+
81
+ it "should populate both methods for different forms of an association name" do
82
+
83
+ MethodMapper.find_operators( @klazz )
84
+ end
85
+
86
+ it "should not populate anything when non existent column name" do
87
+ MethodMapper.find_operators( @klazz )
88
+ end
89
+
90
+ it "should enable correct assignment and sending of a value to AR model" do
91
+ MethodMapper.find_operators( @klazz )
92
+ end
93
+
94
+ it "should enable correct assignment and sending of association to AR model" do
95
+ MethodMapper.find_operators( @klazz )
96
+ end
97
+
98
+
138
99
  end
data/spec/spec_helper.rb CHANGED
@@ -1,37 +1,19 @@
1
- unless defined? SPREE_ROOT
2
- ENV["RAILS_ENV"] = "test"
3
- case
4
- when ENV["SPREE_ENV_FILE"]
5
- require ENV["SPREE_ENV_FILE"]
6
- when File.dirname(__FILE__) =~ %r{vendor/SPREE/vendor/extensions}
7
- require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
- else
9
- require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
- end
11
- end
12
- require "#{SPREE_ROOT}/spec/spec_helper"
13
-
14
- if File.directory?(File.dirname(__FILE__) + "/scenarios")
15
- Scenario.load_paths.unshift File.dirname(__FILE__) + "/scenarios"
16
- end
17
- if File.directory?(File.dirname(__FILE__) + "/matchers")
18
- Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
19
- end
20
-
21
- Spec::Runner.configure do |config|
22
- # config.use_transactional_fixtures = true
23
- # config.use_instantiated_fixtures = false
24
- # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
25
-
26
- # You can declare fixtures for each behaviour like this:
27
- # describe "...." do
28
- # fixtures :table_a, :table_b
29
- #
30
- # Alternatively, if you prefer to declare them only once, you can
31
- # do so here, like so ...
32
- #
33
- # config.global_fixtures = :table_a, :table_b
34
- #
35
- # If you declare global fixtures, be aware that they will be declared
36
- # for all of your examples, even those that don't use them.
1
+
2
+
3
+ RSpec::Runner.configure do |config|
4
+ # config.use_transactional_fixtures = true
5
+ # config.use_instantiated_fixtures = false
6
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
7
+
8
+ # You can declare fixtures for each behaviour like this:
9
+ # describe "...." do
10
+ # fixtures :table_a, :table_b
11
+ #
12
+ # Alternatively, if you prefer to declare them only once, you can
13
+ # do so here, like so ...
14
+ #
15
+ # config.global_fixtures = :table_a, :table_b
16
+ #
17
+ # If you declare global fixtures, be aware that they will be declared
18
+ # for all of your examples, even those that don't use them.
37
19
  end
@@ -0,0 +1,158 @@
1
+ unless defined? SPREE_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["SPREE_ENV_FILE"]
5
+ require ENV["SPREE_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/SPREE/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{SPREE_ROOT}/spec/spec_helper"
13
+
14
+ if File.directory?(File.dirname(__FILE__) + "/scenarios")
15
+ Scenario.load_paths.unshift File.dirname(__FILE__) + "/scenarios"
16
+ end
17
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
18
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
19
+ end
20
+
21
+ require File.dirname(__FILE__) + '/spec_helper'
22
+
23
+ describe 'ExcelLoader' do
24
+
25
+ before do
26
+ @klazz = Product
27
+ MethodMapper.clear
28
+ end
29
+
30
+ it "should populate operators for a given AR model" do
31
+ MethodMapper.find_operators( @klazz )
32
+
33
+ MethodMapper.has_many.should_not be_empty
34
+ MethodMapper.assignments.should_not be_empty
35
+
36
+ hmf = MethodMapper.has_many_for(@klazz)
37
+ arf = MethodMapper.assignments_for(@klazz)
38
+
39
+ (hmf & arf).should_not be_empty # Associations provide << or =
40
+
41
+ hmf.should include('properties')
42
+ arf.should include('count_on_hand') # example of a column
43
+ arf.should include('cost_price') # example of delegated assignment (available through Variant)
44
+
45
+ MethodMapper.column_types.should be_is_a(Hash)
46
+ MethodMapper.column_types.should_not be_empty
47
+
48
+ MethodMapper.column_type_for(@klazz, 'count_on_hand').should_not be_nil
49
+ end
50
+
51
+ it "should populate operators respecting unique option" do
52
+ MethodMapper.find_operators( @klazz, :unique => true )
53
+
54
+ hmf = MethodMapper.has_many_for(@klazz)
55
+ arf = MethodMapper.assignments_for(@klazz)
56
+
57
+ (hmf & arf).should be_empty
58
+ end
59
+
60
+ it "should populate assignment method and col type for different forms of a column name" do
61
+
62
+ MethodMapper.find_operators( @klazz )
63
+
64
+ ["Count On hand", 'count_on_hand', "Count OnHand", "COUNT ONHand"].each do |format|
65
+ mmap = MethodMapper.determine_calls( @klazz, format )
66
+
67
+ mmap.class.should == MethodDetail
68
+
69
+ mmap.assignment.should == 'count_on_hand='
70
+ mmap.has_many.should be_nil
71
+
72
+ mmap.col_type.should_not be_nil
73
+ mmap.col_type.name.should == 'count_on_hand'
74
+ mmap.col_type.default.should == 0
75
+ mmap.col_type.sql_type.should == 'int(10)'
76
+ mmap.col_type.type.should == :integer
77
+ end
78
+ end
79
+
80
+ it "should populate both methods for different forms of an association name" do
81
+
82
+ MethodMapper.find_operators( @klazz )
83
+ ["product_option_types", "product option types", 'product Option_types', "ProductOptionTypes", "Product_Option_Types"].each do |format|
84
+ mmap = MethodMapper.determine_calls( @klazz, format )
85
+
86
+ mmap.assignment.should == 'product_option_types='
87
+ mmap.has_many.should == 'product_option_types'
88
+
89
+ mmap.col_type.should be_nil
90
+ end
91
+ end
92
+
93
+
94
+ it "should not populate anything when non existent column name" do
95
+ ["On sale", 'on_sale'].each do |format|
96
+ mmap = MethodMapper.determine_calls( @klazz, format )
97
+
98
+ mmap.class.should == MethodDetail
99
+ mmap.assignment.should be_nil
100
+ mmap.has_many.should be_nil
101
+ mmap.col_type.should be_nil
102
+ end
103
+ end
104
+
105
+ it "should enable correct assignment and sending of a value to AR model" do
106
+
107
+ MethodMapper.find_operators( @klazz )
108
+
109
+ mmap = MethodMapper.determine_calls( @klazz, 'count on hand' )
110
+ mmap.assignment.should == 'count_on_hand='
111
+
112
+ x = @klazz.new
113
+
114
+ x.should be_new_record
115
+
116
+ x.send( mmap.assignment, 2 )
117
+ x.count_on_hand.should == 2
118
+ x.on_hand.should == 2 # helper method I know looks at same thing
119
+
120
+ mmap = MethodMapper.determine_calls( @klazz, 'SKU' )
121
+ mmap.assignment.should == 'sku='
122
+ x.send( mmap.assignment, 'TEST_SK 001' )
123
+ x.sku.should == 'TEST_SK 001'
124
+ end
125
+
126
+ it "should enable correct assignment and sending of association to AR model" do
127
+
128
+ MethodMapper.find_operators( @klazz )
129
+
130
+ mmap = MethodMapper.determine_calls( @klazz, 'taxons' )
131
+ mmap.has_many.should == 'taxons'
132
+
133
+ x = @klazz.new
134
+
135
+ # NEW ASSOCIATION ASSIGNMENT v.,mn
136
+ x.send( mmap.has_many ) << Taxon.new
137
+ x.taxons.size.should == 1
138
+
139
+ x.send( mmap.has_many ) << [Taxon.new, Taxon.new]
140
+ x.taxons.size.should == 3
141
+
142
+ # EXISTING ASSOCIATIONS
143
+ x = Product.find :first
144
+
145
+ t = Taxonomy.find_or_create_by_name( 'BlahSpecTest' )
146
+
147
+ if x
148
+ sz = x.taxons.size
149
+ x.send(mmap.has_many) << t.root
150
+ x.taxons.size.should == sz + 1
151
+ else
152
+ puts "WARNING : Test not run could not find any Test Products"
153
+ end
154
+
155
+ end
156
+
157
+
158
+ end
@@ -1,15 +1,15 @@
1
- p = Product.seed( :name ) do |s|
2
- s.name = <%= @name %>
3
- s.available_on = '2009-09-01 09:00:00.0'
4
- s.meta_keywords = ['training', 'training']
5
- s.meta_description = ""
6
- s.description = '<%= @description %>'
7
- s.price = 0.00
8
- s.sku = '<%= @sku %>'
9
-
10
- s.is_physical = false
11
- s.is_private = false
12
-
13
- s.append_association :taxons, Taxon.find_by_name( 'Training' )
14
-
15
- end
1
+ p = Product.seed( :name ) do |s|
2
+ s.name = <%= @name %>
3
+ s.available_on = '2009-09-01 09:00:00.0'
4
+ s.meta_keywords = ['training', 'training']
5
+ s.meta_description = ""
6
+ s.description = '<%= @description %>'
7
+ s.price = 0.00
8
+ s.sku = '<%= @sku %>'
9
+
10
+ s.is_physical = false
11
+ s.is_private = false
12
+
13
+ s.append_association :taxons, Taxon.find_by_name( 'Training' )
14
+
15
+ end
@@ -1,13 +1,13 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2010
4
- #
5
- # License:: Free, OpenSource... MIT ?
6
-
7
- # This is the best effort I've found so far to reduce the amount of MS cruft
8
- # to absolute minimum
9
- # ... but unfortunately these tags will NOT BE REMOVED completely - manual cleanup still required
10
-
11
- # TODO - add another ruby parse layer to strip these out completely
12
-
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2010
4
+ #
5
+ # License:: Free, OpenSource... MIT ?
6
+
7
+ # This is the best effort I've found so far to reduce the amount of MS cruft
8
+ # to absolute minimum
9
+ # ... but unfortunately these tags will NOT BE REMOVED completely - manual cleanup still required
10
+
11
+ # TODO - add another ruby parse layer to strip these out completely
12
+
13
13
  new-empty-tags: o:smarttagtype, st1:placename, st1:place, st1:placetype
data/tasks/db_tasks.rake CHANGED
@@ -1,65 +1,65 @@
1
- # Author :: Tom Statter
2
- # Date :: Mar 2011
3
- #
4
- # License:: The MIT License (Free and OpenSource)
5
- #
6
- # About:: Additional Rake tasks useful when testing seeding DB via ARLoader
7
- #
8
- namespace :autotelik do
9
-
10
- namespace :db do
11
-
12
- SYSTEM_TABLE_EXCLUSION_LIST = ['schema_migrations']
13
-
14
- desc "Purge the current database"
15
- task :purge, :exclude_system_tables, :needs => [:environment] do |t, args|
16
- require 'highline/import'
17
-
18
- if(RAILS_ENV == 'production')
19
- agree("WARNING: In Production database, REALLY PURGE ? [y]:")
20
- end
21
-
22
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
23
- case config['adapter']
24
- when "mysql", "jdbcmysql"
25
- ActiveRecord::Base.establish_connection(config)
26
- ActiveRecord::Base.connection.tables.each do |table|
27
- next if(args[:exclude_system_tables] && SYSTEM_TABLE_EXCLUSION_LIST.include?(table) )
28
- puts "purging table: #{table}"
29
- ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
30
- end
31
- when "sqlite","sqlite3"
32
- dbfile = config["database"] || config["dbfile"]
33
- File.delete(dbfile) if File.exist?(dbfile)
34
- when "sqlserver"
35
- dropfkscript = "#{config["host"]}.#{config["database"]}.DP1".gsub(/\\/,'-')
36
- `osql -E -S #{config["host"]} -d #{config["database"]} -i db\\#{dropfkscript}`
37
- `osql -E -S #{config["host"]} -d #{config["database"]} -i db\\#{RAILS_ENV}_structure.sql`
38
- when "oci", "oracle"
39
- ActiveRecord::Base.establish_connection(config)
40
- ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
41
- ActiveRecord::Base.connection.execute(ddl)
42
- end
43
- when "firebird"
44
- ActiveRecord::Base.establish_connection(config)
45
- ActiveRecord::Base.connection.recreate_database!
46
- else
47
- raise "Task not supported by '#{config["adapter"]}'"
48
- end
49
- end
50
-
51
- desc "Clear database and optional directories such as assets, then run db:seed"
52
- task :seed_again, :assets, :needs => [:environment] do |t, args|
53
-
54
- Rake::Task['autotelik:db:purge'].invoke( true ) # i.e ENV['exclude_system_tables'] = true
55
-
56
- if(args[:assets])
57
- assets = "#{Rails.root}/public/assets"
58
- FileUtils::rm_rf(assets) if(File.exists?(assets))
59
- end
60
-
61
- Rake::Task['db:seed'].invoke
62
- end
63
-
64
- end # db
1
+ # Author :: Tom Statter
2
+ # Date :: Mar 2011
3
+ #
4
+ # License:: The MIT License (Free and OpenSource)
5
+ #
6
+ # About:: Additional Rake tasks useful when testing seeding DB via ARLoader
7
+ #
8
+ namespace :autotelik do
9
+
10
+ namespace :db do
11
+
12
+ SYSTEM_TABLE_EXCLUSION_LIST = ['schema_migrations']
13
+
14
+ desc "Purge the current database"
15
+ task :purge, :exclude_system_tables, :needs => [:environment] do |t, args|
16
+ require 'highline/import'
17
+
18
+ if(RAILS_ENV == 'production')
19
+ agree("WARNING: In Production database, REALLY PURGE ? [y]:")
20
+ end
21
+
22
+ config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
23
+ case config['adapter']
24
+ when "mysql", "jdbcmysql"
25
+ ActiveRecord::Base.establish_connection(config)
26
+ ActiveRecord::Base.connection.tables.each do |table|
27
+ next if(args[:exclude_system_tables] && SYSTEM_TABLE_EXCLUSION_LIST.include?(table) )
28
+ puts "purging table: #{table}"
29
+ ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
30
+ end
31
+ when "sqlite","sqlite3"
32
+ dbfile = config["database"] || config["dbfile"]
33
+ File.delete(dbfile) if File.exist?(dbfile)
34
+ when "sqlserver"
35
+ dropfkscript = "#{config["host"]}.#{config["database"]}.DP1".gsub(/\\/,'-')
36
+ `osql -E -S #{config["host"]} -d #{config["database"]} -i db\\#{dropfkscript}`
37
+ `osql -E -S #{config["host"]} -d #{config["database"]} -i db\\#{RAILS_ENV}_structure.sql`
38
+ when "oci", "oracle"
39
+ ActiveRecord::Base.establish_connection(config)
40
+ ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
41
+ ActiveRecord::Base.connection.execute(ddl)
42
+ end
43
+ when "firebird"
44
+ ActiveRecord::Base.establish_connection(config)
45
+ ActiveRecord::Base.connection.recreate_database!
46
+ else
47
+ raise "Task not supported by '#{config["adapter"]}'"
48
+ end
49
+ end
50
+
51
+ desc "Clear database and optional directories such as assets, then run db:seed"
52
+ task :seed_again, :assets, :needs => [:environment] do |t, args|
53
+
54
+ Rake::Task['autotelik:db:purge'].invoke( true ) # i.e ENV['exclude_system_tables'] = true
55
+
56
+ if(args[:assets])
57
+ assets = "#{Rails.root}/public/assets"
58
+ FileUtils::rm_rf(assets) if(File.exists?(assets))
59
+ end
60
+
61
+ Rake::Task['db:seed'].invoke
62
+ end
63
+
64
+ end # db
65
65
  end # autotelik