active_admin_import 3.0.0 → 3.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1a7b928539df8bb150300b72b8b2a0971a31a2a9
4
- data.tar.gz: 8144a8f48472cce96498a3fd5ce1a5b4c1b530ce
2
+ SHA256:
3
+ metadata.gz: 0752ed26da2e640bbef43504a32bb98550d230d4f3c8cab9c1ff3fc6cd8f8eee
4
+ data.tar.gz: 441866fbf6ba23fdf49f1232f56ca5545f9ee1c1f1f71402be42261d8c2df72d
5
5
  SHA512:
6
- metadata.gz: e04cb45397a7b3540d2c5302d99e154172cc08055dfb0a4f9d1311f48f56133c8928b5b85fe3d50a4d14f0c280f844e4e1b05c7f600b670c0e7dba7813ea0883
7
- data.tar.gz: 175dc4931d433f53aedba0ec57d7a004c6e0c18f268ed1f8af711d70350e2e20e8e3e9cafa4c3c97a1df349036d3f54ecdb9b4fda964fd046376a8406e366a25
6
+ metadata.gz: 5ca717644add0b286d26eb6f97f4be627954576cd9cb4153f5f97e9e849719495c266add21a033ca906636e2373c42b2452350586c52af95ee1dbb8acc1a7696
7
+ data.tar.gz: 00e6d0d6c689254eadd789a987d7aec3d6742f1988aec2f3373b867af3ac5bdf6e2077f272ba80cbae847750cc996d1ac5b7e08fc7ed664991ffd38733779066
@@ -11,7 +11,3 @@ matrix:
11
11
  exclude:
12
12
  - rvm: 2.1.9
13
13
  env: RAILS=5.0.0 # Rails 5.0 requires Ruby 2.2.2 or newer
14
- before_install:
15
- - gem update --system # use the very latest Rubygems
16
- - rvm @global do gem uninstall bundler -a -x
17
- - rvm @global do gem install bundler -v 1.14.6 # latest version known to work
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.add_runtime_dependency 'activerecord-import', '~> 0.17.0'
19
19
  gem.add_runtime_dependency 'rchardet', '~> 1.6'
20
20
  gem.add_runtime_dependency 'rubyzip', '~> 1.2'
21
- gem.add_dependency 'activeadmin', '~> 1.0'
21
+ gem.add_dependency 'activeadmin', '>= 1.0.0.pre2'
22
22
  end
@@ -0,0 +1,23 @@
1
+ tr:
2
+ active_admin:
3
+ import: "İçe aktar"
4
+ active_admin_import:
5
+ file: 'Dosya'
6
+ file_error: "Hata: %{message}"
7
+ file_format_error: "Sadece geçerli csv dosyasını içe aktarabilirsiniz"
8
+ file_empty_error: "Boş dosyayı içe aktaramazsın"
9
+ no_file_error: "Lütfen, içe aktarmak için dosya seçin"
10
+ details: "Lütfen, içe aktarmak için dosya seçin"
11
+ imported:
12
+ one: "Başarıyla 1 %{model} içe aktarıldı."
13
+ other: "Başarıyla %{count} %{plural_model} içe aktarıldı."
14
+ failed:
15
+ one: "1 %{model} içe aktarılamadı: %{message}"
16
+ other: "%{count} %{plural_model} içe aktarılamadı: %{message}"
17
+ import_model: "İçe aktar %{plural_model}"
18
+ import_btn: "İçe aktar"
19
+ import_btn_disabled: "Bekleyin..."
20
+ csv_options: "CSV seçenekleri"
21
+ col_sep: 'Sutün ayracı'
22
+ row_sep: 'Satır ayracı'
23
+ quote_char: 'Alıntı karakteri'
@@ -60,6 +60,30 @@ module ActiveAdminImport
60
60
  end
61
61
  end
62
62
 
63
+ # Use it when CSV file contain redundant columns
64
+ #
65
+ # Example:
66
+ #
67
+ # ActiveAdmin.register Post
68
+ # active_admin_import before_batch_import: lambda { |importer|
69
+ # importer.batch_slice_columns(['name', 'birthday'])
70
+ # }
71
+ # end
72
+ #
73
+ def batch_slice_columns(slice_columns)
74
+ use_indexes = []
75
+ headers.values.each_with_index do |val, index|
76
+ use_indexes << index if val.in?(slice_columns)
77
+ end
78
+ return csv_lines if use_indexes.empty?
79
+ # slice CSV headers
80
+ @headers = headers.to_a.values_at(*use_indexes).to_h
81
+ # slice CSV values
82
+ csv_lines.map! do |line|
83
+ line.values_at(*use_indexes)
84
+ end
85
+ end
86
+
63
87
  def values_at(header_key)
64
88
  csv_lines.collect { |line| line[header_index(header_key)] }.uniq
65
89
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdminImport
3
- VERSION = '3.0.0'
3
+ VERSION = "3.1.0"
4
4
  end
@@ -433,6 +433,43 @@ describe 'import', type: :feature do
433
433
  end
434
434
  end
435
435
 
436
+ context "with slice_columns option" do
437
+ before do
438
+ add_author_resource template_object: ActiveAdminImport::Model.new,
439
+ before_batch_import: lambda { |importer|
440
+ importer.batch_slice_columns(slice_columns)
441
+ }
442
+ visit "/admin/authors/import"
443
+ upload_file!(:authors)
444
+ end
445
+
446
+ context "slice last column and superfluous column" do
447
+ let(:slice_columns) { %w(name last_name not_existing_column) }
448
+
449
+ it "should not fill `birthday` column" do
450
+ expect(Author.pluck(:name, :last_name, :birthday)).to match_array(
451
+ [
452
+ ["Jane", "Roe", nil],
453
+ ["John", "Doe", nil]
454
+ ]
455
+ )
456
+ end
457
+ end
458
+
459
+ context "slice column from the middle" do
460
+ let(:slice_columns) { %w(name birthday) }
461
+
462
+ it "should not fill `last_name` column" do
463
+ expect(Author.pluck(:name, :last_name, :birthday)).to match_array(
464
+ [
465
+ ["Jane", nil, "1988-11-16".to_date],
466
+ ["John", nil, "1986-05-01".to_date]
467
+ ]
468
+ )
469
+ end
470
+ end
471
+ end
472
+
436
473
  context 'with invalid options' do
437
474
  let(:options) { { invalid_option: :invalid_value } }
438
475
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Fedoronchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-import
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: activeadmin
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: 1.0.0.pre2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: 1.0.0.pre2
69
69
  description: The most efficient way to import for Active Admin
70
70
  email:
71
71
  - fedoronchuk@gmail.com
@@ -90,6 +90,7 @@ files:
90
90
  - config/locales/ko.yml
91
91
  - config/locales/pt-BR.yml
92
92
  - config/locales/ru.yml
93
+ - config/locales/tr.yml
93
94
  - config/locales/uk.yml
94
95
  - config/locales/zh-CN.yml
95
96
  - lib/active_admin_import.rb
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.6.10
150
+ rubygems_version: 2.7.6
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: ActiveAdmin import based on activerecord-import gem.