db_fixtures_dump 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTY1YmQxMTliMWQ4MWYxZDBjNGUwN2MyNjE5YTA4ZGQ5MDJjZTUyMA==
5
+ data.tar.gz: !binary |-
6
+ ODdhZWVkZDRlY2E2ODNhYWM3ZmJkMjVhYTE4ZmU0NDc4MjZiOGVlMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDQ3OGJmNDE2ZDZjN2VkMzVmZjY0MmUxOWViOWY0YzhlYjNjZTY4NjM0M2Fl
10
+ ZDM5YTUwYWQxMGIxZTg3YzcxYWIwYjkyNjM0NjdkYzA3NDdlYzc5OGYyMWVh
11
+ N2QyYzE0ZmJlMTk3NjM1NmQwMTk4NjdlMDhiMjhhOTA3ODlhNGM=
12
+ data.tar.gz: !binary |-
13
+ NjVmZWU1NDEwYmUxN2M2NDlmMWQwZGQ0ZWI3YTcwZmRjZTQ4ODhjNWFjYmM1
14
+ ODYyZjhmNmQyYWY4ZjI0OGNlODY0YmZmYjg4NTljZDc2ZTY2ZjRmOTc5Nzli
15
+ YTlmZTdmNDkzZjRiNDQwODIzOGJkYmMwOGU3YWZlOGJhNjlmNjY=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # DbFixturesDump
1
+ # db:fixtures:dump
2
2
 
3
3
  Adds db:fixtures:dump rake task to dump all tables into yaml fixtures
4
4
 
@@ -20,6 +20,12 @@ Or install it yourself as:
20
20
 
21
21
  $ rake db:fixtures:dump
22
22
 
23
+ ### Output directory
24
+
25
+ Just like for the db:fixtures:load , you may specify FIXTURES_PATH to be used as the output directory.
26
+
27
+ $ FIXTURES_PATH=db/backup rake db:fixtures:dump
28
+
23
29
  ## Contributing
24
30
 
25
31
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module DbFixturesDump
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -7,7 +7,7 @@
7
7
  # Then forked from https://gist.github.com/iiska/1527911
8
8
  #
9
9
  # fixed obsolete use of RAILS_ROOT, glob
10
- # put output in the spec/fixtures directory instead of test/fixtures
10
+ # allow to specify output directory by FIXTURES_PATH
11
11
 
12
12
  namespace :db do
13
13
  namespace :fixtures do
@@ -16,31 +16,34 @@ namespace :db do
16
16
  models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s|
17
17
  Pathname.new(s).basename.to_s.gsub(/\.rb$/,'').camelize
18
18
  end
19
-
19
+ # specify FIXTURES_PATH to test/fixtures if you do test:unit
20
+ dump_dir = ENV['FIXTURES_PATH'] || "spec/fixtures"
20
21
  puts "Found models: " + models.join(', ')
22
+ puts "Dumping to: " + dump_dir
21
23
 
22
24
  models.each do |m|
23
25
  model = m.constantize
24
26
  next unless model.ancestors.include?(ActiveRecord::Base)
25
27
 
26
- puts "Dumping model: " + m
27
- entries = model.find(:all, :order => 'id ASC')
28
+ entries = model.unscoped.all.order('id ASC')
29
+ puts "Dumping model: #{m} (#{entries.length} entries)"
28
30
 
29
31
  increment = 1
30
32
 
31
33
  # use test/fixtures if you do test:unit
32
- model_file = Rails.root + ('spec/fixtures/' + m.underscore.pluralize + '.yml')
33
- File.open(model_file, 'w') do |f|
34
- entries.each do |a|
35
- attrs = a.attributes
36
- attrs.delete_if{|k,v| v.blank?}
34
+ model_file = Rails.root + (dump_dir + m.underscore.pluralize + '.yml')
35
+ output = {}
36
+ entries.each do |a|
37
+ attrs = a.attributes
38
+ attrs.delete_if{|k,v| v.nil?}
37
39
 
38
- output = {m + '_' + increment.to_s => attrs}
39
- f << output.to_yaml.gsub(/^--- \n/,'') + "\n"
40
+ output["#{m}_#{increment}"] = attrs
40
41
 
41
- increment += 1
42
- end
42
+ increment += 1
43
43
  end
44
+ file = File.open(model_file, 'w')
45
+ file << output.to_yaml
46
+ file.close #better than relying on gc
44
47
  end
45
48
  end
46
49
  end
metadata CHANGED
@@ -1,62 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: db_fixtures_dump
3
- version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 9
10
- version: 0.0.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Kurt Thams
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-10-29 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: bundler
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
27
17
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 9
30
- segments:
31
- - 1
32
- - 3
33
- version: "1.3"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
34
20
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rake
38
21
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
48
34
  type: :development
49
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
50
41
  description: Rake task to dump all tables into yaml fixtures
51
- email:
42
+ email:
52
43
  - thams@thams.com
53
44
  executables: []
54
-
55
45
  extensions: []
56
-
57
46
  extra_rdoc_files: []
58
-
59
- files:
47
+ files:
60
48
  - Gemfile
61
49
  - LICENSE.txt
62
50
  - README.md
@@ -66,39 +54,29 @@ files:
66
54
  - lib/db_fixtures_dump/railtie.rb
67
55
  - lib/db_fixtures_dump/version.rb
68
56
  - lib/tasks/db_fixtures_dump.rake
69
- has_rdoc: true
70
57
  homepage: https://github.com/thams/db_fixtures_dump
71
- licenses:
58
+ licenses:
72
59
  - MIT
60
+ metadata: {}
73
61
  post_install_message:
74
62
  rdoc_options: []
75
-
76
- require_paths:
63
+ require_paths:
77
64
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
87
- required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
96
75
  requirements: []
97
-
98
76
  rubyforge_project:
99
- rubygems_version: 1.3.7
77
+ rubygems_version: 2.2.2
100
78
  signing_key:
101
- specification_version: 3
79
+ specification_version: 4
102
80
  summary: Rake task to dump all tables into yaml fixtures
103
81
  test_files: []
104
-
82
+ has_rdoc: