rails-csv-fixtures 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe53d2c2fe70fa4b4d64a573a8edfd57b49941fa30861b89a5349eef67719f05
4
+ data.tar.gz: c9799f8c4fd423199fcfe5350c38597308050a6bab3451de8e4de8a0bc1e0b6e
5
+ SHA512:
6
+ metadata.gz: 3580a543e539c238e882c41abfd9acf945e80f4a9f02ab72e136dcae1ab142e67e56db0328e695b81efc5c73ff1dfac7b0a2fa5c204aa82e39fba28e81870d44
7
+ data.tar.gz: e3b817e64cc48f31a523d92519e268836fa1f8f904eba515dc5e368e5acee45fa43d7e35493a6bea340f502f3e99d170d0c2cedc63e23afc691e3fd8dccfead2
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ RailsCsvFixtures
2
+ ================
3
+ [![Build Status](https://travis-ci.org/bfolkens/rails-csv-fixtures.png)](https://travis-ci.org/bfolkens/rails-csv-fixtures)
4
+
5
+ This plugin restores the functionality of CSV based fixtures that was removed from Rails 3.2.
6
+ It's currently compatible with Rails 3.2/4.0/4.1/4.2/5.0/5.1.
@@ -6,32 +6,36 @@ module RailsCsvFixtures
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- alias_method_chain :read_fixture_files, :csv_support
9
+ alias_method :read_fixture_files_without_csv_support, :read_fixture_files
10
+ alias_method :read_fixture_files, :read_fixture_files_with_csv_support
10
11
  end
11
12
 
12
- def read_fixture_files_with_csv_support
13
- if ::File.file?(csv_file_path)
14
- read_csv_fixture_files
13
+ def read_fixture_files_with_csv_support(*args)
14
+ if ::File.file?(csv_file_path(*args))
15
+ read_csv_fixture_files(*args)
15
16
  else
16
- read_fixture_files_without_csv_support
17
+ read_fixture_files_without_csv_support(*args)
17
18
  end
18
19
  end
19
20
 
20
- def read_csv_fixture_files
21
- reader = CSV.parse(erb_render(IO.read(csv_file_path)))
21
+ def read_csv_fixture_files(*args)
22
+ fixtures = fixtures() || {}
23
+ reader = CSV.parse(erb_render(IO.read(csv_file_path(*args))))
22
24
  header = reader.shift
23
25
  i = 0
24
26
  reader.each do |row|
25
27
  data = {}
26
- row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip }
27
- fixtures["#{@class_name.to_s.underscore}_#{i+=1}"] = ActiveRecord::Fixture.new(data, model_class)
28
+ row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.nil? ? nil : cell.to_s.strip }
29
+ class_name = (args.second || model_class && model_class.name)
30
+ fixtures["#{class_name.to_s.underscore}_#{i+=1}"] = ActiveRecord::Fixture.new(data, model_class)
28
31
  end
32
+ fixtures
33
+ end
34
+
35
+ def csv_file_path(*args)
36
+ (args.first || @path || @fixture_path) + '.csv'
29
37
  end
30
38
 
31
- def csv_file_path
32
- @fixture_path + ".csv"
33
- end
34
-
35
39
  def erb_render(fixture_content)
36
40
  ERB.new(fixture_content).result
37
41
  end
@@ -39,4 +43,8 @@ module RailsCsvFixtures
39
43
  end
40
44
 
41
45
  require 'active_record/fixtures'
42
- ::ActiveRecord::Fixtures.send :include, RailsCsvFixtures::CsvFixtures
46
+ if ::ActiveRecord::VERSION::MAJOR < 4
47
+ ::ActiveRecord::Fixtures.send :include, RailsCsvFixtures::CsvFixtures
48
+ else
49
+ ::ActiveRecord::FixtureSet.send :include, RailsCsvFixtures::CsvFixtures
50
+ end
@@ -4,7 +4,8 @@ module RailsCsvFixtures
4
4
 
5
5
  included do
6
6
  class << self
7
- alias_method_chain :fixtures, :csv_support
7
+ alias_method :fixtures_without_csv_support, :fixtures
8
+ alias_method :fixtures, :fixtures_with_csv_support
8
9
  end
9
10
  end
10
11
 
@@ -1,3 +1,3 @@
1
1
  module RailsCsvFixtures
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,6 +4,4 @@
4
4
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
5
  // the compiled file.
6
6
  //
7
- //= require jquery
8
- //= require jquery_ujs
9
7
  //= require_tree .
@@ -5,9 +5,8 @@ Dummy::Application.configure do
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
8
+
9
+ config.eager_load = false
11
10
 
12
11
  # Show full error reports and disable caching
13
12
  config.consider_all_requests_local = true
@@ -9,7 +9,15 @@ Dummy::Application.configure do
9
9
  config.action_controller.perform_caching = true
10
10
 
11
11
  # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
12
+ if Rails::VERSION::MAJOR >= 5
13
+ config.public_file_server.enabled = false
14
+ elsif Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2
15
+ config.serve_static_files = false
16
+ else
17
+ config.serve_static_assets = false
18
+ end
19
+
20
+ config.eager_load = true
13
21
 
14
22
  # Compress JavaScripts and CSS
15
23
  config.assets.compress = true
@@ -7,12 +7,19 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ config.eager_load = false
13
11
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
12
+ # Configure static asset server for tests with Cache-Control for performance
13
+ if Rails::VERSION::MAJOR >= 5
14
+ config.public_file_server.enabled = true
15
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
16
+ elsif Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2
17
+ config.serve_static_files = true
18
+ config.static_cache_control = "public, max-age=3600"
19
+ else
20
+ config.serve_static_assets = true
21
+ config.static_cache_control = "public, max-age=3600"
22
+ end
16
23
 
17
24
  # Show full error reports and disable caching
18
25
  config.consider_all_requests_local = true
@@ -36,4 +43,6 @@ Dummy::Application.configure do
36
43
 
37
44
  # Print deprecation notices to the stderr
38
45
  config.active_support.deprecation = :stderr
46
+
47
+ config.active_support.test_order = :random
39
48
  end
Binary file
Binary file
@@ -2,16 +2,20 @@ require 'test_helper'
2
2
 
3
3
  class RailsCsvFixturesTest < ActiveSupport::TestCase
4
4
  test 'should read csv fixtures' do
5
- _fixtures = ActiveRecord::Fixtures.new(Account.connection, 'accounts', 'Account', File.join(fixture_path, 'accounts'))
6
-
5
+ if ::ActiveRecord::VERSION::MAJOR < 4
6
+ _fixtures = ActiveRecord::Fixtures.new(Account.connection, 'accounts', 'Account', File.join(fixture_path, 'accounts'))
7
+ else
8
+ _fixtures = ActiveRecord::FixtureSet.new(Account.connection, 'accounts', Account, File.join(fixture_path, 'accounts'))
9
+ end
10
+
7
11
  assert_not_nil _fixtures
8
12
  assert _fixtures.fixtures.any?
9
13
  end
10
-
14
+
11
15
  test 'should load fixtures in test case' do
12
16
  assert_nothing_raised do
13
17
  ActiveSupport::TestCase.fixtures(:all)
14
18
  ActiveSupport::TestCase.fixtures(:accounts)
15
19
  end
16
20
  end
17
- end
21
+ end
metadata CHANGED
@@ -1,167 +1,147 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails-csv-fixtures
3
- version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Brad Folkens
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-05-11 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 3
32
- - 2
33
- - 0
34
- version: 3.2.0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
35
20
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: sqlite3
39
21
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
43
24
  - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
49
34
  type: :development
50
- version_requirements: *id002
51
- description: This plugin restores the functionality of CSV based fixtures that was removed from Rails 3.2+
52
- email:
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This plugin restores the functionality of CSV based fixtures that was
42
+ removed from Rails 3.2+
43
+ email:
53
44
  - bfolkens@gmail.com
54
45
  executables: []
55
-
56
46
  extensions: []
57
-
58
47
  extra_rdoc_files: []
59
-
60
- files:
61
- - lib/rails-csv-fixtures/version.rb
62
- - lib/rails-csv-fixtures/active_record_csv_fixtures.rb
63
- - lib/rails-csv-fixtures/railtie.rb
64
- - lib/rails-csv-fixtures/active_support_test_case_patch.rb
65
- - lib/rails-csv-fixtures.rb
48
+ files:
66
49
  - MIT-LICENSE
50
+ - README.md
67
51
  - Rakefile
68
- - README.rdoc
69
- - test/dummy/public/404.html
70
- - test/dummy/public/422.html
71
- - test/dummy/public/500.html
72
- - test/dummy/public/favicon.ico
73
- - test/dummy/db/schema.rb
74
- - test/dummy/test/fixtures/accounts.csv
75
- - test/dummy/app/controllers/application_controller.rb
52
+ - lib/rails-csv-fixtures.rb
53
+ - lib/rails-csv-fixtures/active_record_csv_fixtures.rb
54
+ - lib/rails-csv-fixtures/active_support_test_case_patch.rb
55
+ - lib/rails-csv-fixtures/railtie.rb
56
+ - lib/rails-csv-fixtures/version.rb
57
+ - test/dummy/Rakefile
76
58
  - test/dummy/app/assets/javascripts/application.js
77
59
  - test/dummy/app/assets/stylesheets/application.css
78
- - test/dummy/app/models/account.rb
60
+ - test/dummy/app/controllers/application_controller.rb
79
61
  - test/dummy/app/helpers/application_helper.rb
62
+ - test/dummy/app/models/account.rb
80
63
  - test/dummy/app/views/layouts/application.html.erb
81
- - test/dummy/script/rails
82
- - test/dummy/config/initializers/secret_token.rb
64
+ - test/dummy/config.ru
65
+ - test/dummy/config/application.rb
66
+ - test/dummy/config/boot.rb
67
+ - test/dummy/config/database.yml
68
+ - test/dummy/config/environment.rb
69
+ - test/dummy/config/environments/development.rb
70
+ - test/dummy/config/environments/production.rb
71
+ - test/dummy/config/environments/test.rb
72
+ - test/dummy/config/initializers/backtrace_silencers.rb
73
+ - test/dummy/config/initializers/inflections.rb
83
74
  - test/dummy/config/initializers/mime_types.rb
75
+ - test/dummy/config/initializers/secret_token.rb
84
76
  - test/dummy/config/initializers/session_store.rb
85
- - test/dummy/config/initializers/inflections.rb
86
77
  - test/dummy/config/initializers/wrap_parameters.rb
87
- - test/dummy/config/initializers/backtrace_silencers.rb
88
- - test/dummy/config/environments/test.rb
89
- - test/dummy/config/environments/development.rb
90
- - test/dummy/config/environments/production.rb
91
78
  - test/dummy/config/locales/en.yml
92
- - test/dummy/config/boot.rb
93
- - test/dummy/config/environment.rb
94
79
  - test/dummy/config/routes.rb
95
- - test/dummy/config/database.yml
96
- - test/dummy/config/application.rb
97
- - test/dummy/config.ru
98
- - test/dummy/Rakefile
80
+ - test/dummy/db/development.sqlite3
81
+ - test/dummy/db/schema.rb
82
+ - test/dummy/db/test.sqlite3
83
+ - test/dummy/public/404.html
84
+ - test/dummy/public/422.html
85
+ - test/dummy/public/500.html
86
+ - test/dummy/public/favicon.ico
87
+ - test/dummy/script/rails
88
+ - test/dummy/test/fixtures/accounts.csv
99
89
  - test/rails-csv-fixtures_test.rb
100
90
  - test/test_helper.rb
101
- has_rdoc: true
102
91
  homepage: http://github.com/bfolkens/rails-csv-fixtures
103
92
  licenses: []
104
-
93
+ metadata: {}
105
94
  post_install_message:
106
95
  rdoc_options: []
107
-
108
- require_paths:
96
+ require_paths:
109
97
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
- requirements:
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
113
100
  - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
- requirements:
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
122
105
  - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
128
108
  requirements: []
129
-
130
- rubyforge_project:
131
- rubygems_version: 1.6.2
109
+ rubygems_version: 3.1.4
132
110
  signing_key:
133
- specification_version: 3
111
+ specification_version: 4
134
112
  summary: Restores functionality of CSV based fixtures in Rails 3.2+
135
- test_files:
136
- - test/dummy/public/404.html
137
- - test/dummy/public/422.html
138
- - test/dummy/public/500.html
139
- - test/dummy/public/favicon.ico
140
- - test/dummy/db/schema.rb
141
- - test/dummy/test/fixtures/accounts.csv
113
+ test_files:
114
+ - test/dummy/app/models/account.rb
142
115
  - test/dummy/app/controllers/application_controller.rb
116
+ - test/dummy/app/views/layouts/application.html.erb
143
117
  - test/dummy/app/assets/javascripts/application.js
144
118
  - test/dummy/app/assets/stylesheets/application.css
145
- - test/dummy/app/models/account.rb
146
119
  - test/dummy/app/helpers/application_helper.rb
147
- - test/dummy/app/views/layouts/application.html.erb
148
- - test/dummy/script/rails
149
- - test/dummy/config/initializers/secret_token.rb
150
- - test/dummy/config/initializers/mime_types.rb
151
- - test/dummy/config/initializers/session_store.rb
152
- - test/dummy/config/initializers/inflections.rb
153
- - test/dummy/config/initializers/wrap_parameters.rb
154
- - test/dummy/config/initializers/backtrace_silencers.rb
155
- - test/dummy/config/environments/test.rb
156
- - test/dummy/config/environments/development.rb
157
- - test/dummy/config/environments/production.rb
120
+ - test/dummy/test/fixtures/accounts.csv
121
+ - test/dummy/config/routes.rb
158
122
  - test/dummy/config/locales/en.yml
159
- - test/dummy/config/boot.rb
123
+ - test/dummy/config/environments/production.rb
124
+ - test/dummy/config/environments/development.rb
125
+ - test/dummy/config/environments/test.rb
160
126
  - test/dummy/config/environment.rb
161
- - test/dummy/config/routes.rb
162
- - test/dummy/config/database.yml
163
127
  - test/dummy/config/application.rb
128
+ - test/dummy/config/database.yml
129
+ - test/dummy/config/boot.rb
130
+ - test/dummy/config/initializers/backtrace_silencers.rb
131
+ - test/dummy/config/initializers/mime_types.rb
132
+ - test/dummy/config/initializers/session_store.rb
133
+ - test/dummy/config/initializers/wrap_parameters.rb
134
+ - test/dummy/config/initializers/secret_token.rb
135
+ - test/dummy/config/initializers/inflections.rb
164
136
  - test/dummy/config.ru
137
+ - test/dummy/script/rails
165
138
  - test/dummy/Rakefile
166
- - test/rails-csv-fixtures_test.rb
139
+ - test/dummy/public/favicon.ico
140
+ - test/dummy/public/422.html
141
+ - test/dummy/public/500.html
142
+ - test/dummy/public/404.html
143
+ - test/dummy/db/schema.rb
144
+ - test/dummy/db/test.sqlite3
145
+ - test/dummy/db/development.sqlite3
167
146
  - test/test_helper.rb
147
+ - test/rails-csv-fixtures_test.rb
data/README.rdoc DELETED
@@ -1,5 +0,0 @@
1
- = RailsCsvFixtures
2
-
3
- This plugin restores the functionality of CSV based fixtures that was removed from Rails 3.2+
4
-
5
- {<img src="https://secure.travis-ci.org/bfolkens/rails-csv-fixtures.png" />}[http://travis-ci.org/bfolkens/rails-csv-fixtures]