strapless 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -48,6 +48,10 @@ fixture, any existing data will be deleted from the related table.</span>
48
48
 
49
49
  Now you have some data!
50
50
 
51
+ You can also specify individual table names, or a list of names, as the arg to load and dump:
52
+
53
+ $ rake db:bootstrap:load[pages,users,auths,animals]
54
+
51
55
  Installation
52
56
  ------------
53
57
 
@@ -1,3 +1,3 @@
1
1
  module Strapless
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -33,7 +33,8 @@ namespace :db do
33
33
  data = File.join(Rails.root, 'db', 'data')
34
34
  Dir.mkdir(data) unless File.exists?(data)
35
35
  Dir['app/models/*'].each {|f| require f }
36
- ActiveRecord::Base.descendants.select{|m| m.table_exists? && (m.table_name == args[:table] || args[:table] == 'all') }.each do |klass|
36
+ args[:table] = args[:table].split(/,/) unless args[:table] == 'all'
37
+ ActiveRecord::Base.descendants.select{|m| m.table_exists? && (args[:table] == 'all' || args[:table].include?(m.table_name))}.each do |klass|
37
38
  klass.dump_fixtures(data)
38
39
  end
39
40
  end
@@ -46,10 +47,11 @@ namespace :db do
46
47
  puts "You must indicate the table name for the fixtures that you want to load into your database. The fixture data will overwrite all current data in the table. If you want to load all fixtures, use db:bootstrap:load[all]"
47
48
  exit
48
49
  end
50
+ args[:table] = args[:table].split(/,/) unless args[:table] == 'all'
49
51
  Dir.glob(File.join(Rails.root, 'db', 'data', '*.yml')).each do |fixture_file|
50
- if File.basename(fixture_file, '.*') == args[:table] || args[:table] == 'all'
52
+ if args[:table] == 'all' || args[:table].include?(File.basename(fixture_file, '.*'))
51
53
  puts 'Loading fixture: ' + fixture_file
52
- Fixtures.create_fixtures("db/data", File.basename(fixture_file, '.*'))
54
+ ActiveRecord::Fixtures.create_fixtures("db/data", File.basename(fixture_file, '.*'))
53
55
  end
54
56
  end
55
57
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strapless
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Rafter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-21 00:00:00 -07:00
18
+ date: 2012-03-09 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements: []
69
69
 
70
70
  rubyforge_project: strapless
71
- rubygems_version: 1.4.1
71
+ rubygems_version: 1.3.9.2
72
72
  signing_key:
73
73
  specification_version: 3
74
74
  summary: Simple tasks for bootstrapping the data in your rails application