tallty_import_export 1.0.3 → 1.0.5

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
2
  SHA256:
3
- metadata.gz: 4a9e60e31f0ac0c3d979739c50f9631e4a678e61aa86325cd655bd40b45bc7d1
4
- data.tar.gz: a75eb5bb8b865c3d1edd470a5704d1bdc0fda9002411dde9816ea1cd3ab44e98
3
+ metadata.gz: 01a93e8f64b1aac7a0795ef697fe6fe27f084edc4570805e0bc8000750f3c611
4
+ data.tar.gz: 7ee6334bd719ec319f25f64a07c38d88a9073926de5c379cf75483655195aa8a
5
5
  SHA512:
6
- metadata.gz: 1d7adcd134a5ead8f4c0eefa8812f5f5578bf2f01dfd396c02c4ce45544e94f97b5397d8e81da5c320117b7034534c65cc0c54569fc66c884d7e4e03bad5e380
7
- data.tar.gz: 3c36721ef2be7db0df34064fa5b02abd55b3b808644ea8f53f3e982ed90d58a60326ab62ceee365ed351faf0440180bf9d68d637b0a442cc31e4215245dab7ba
6
+ metadata.gz: b70babba1dcec1b39c0ec311f44b51bf5a41268fc301f365099b960d292e4b6812cf6917acee757c24744db671e66494ced0f2eea457c5f8e8d7e934deff0b60
7
+ data.tar.gz: 6ecac3c336068b4331e9fb3525c902f38f70bd0f0a1bfd73209ced1b357a1ad076a660349cdacf51492e5be07e909df77996a2e78435afec0751cee82ad8068c
@@ -6,14 +6,14 @@ module TalltyImportExport
6
6
  end
7
7
 
8
8
  module ClassMethods
9
- def model_headers
9
+ def model_headers **args
10
10
  columns.map do |column|
11
11
  {
12
12
  key: column.name,
13
13
  name: column.comment || column.name,
14
14
  attr_type: column.type,
15
15
  format: column.type == :string ? :string : nil,
16
- primary_key: column.name == 'id' ? true : false
16
+ primary_key: column.name == 'id' ? true : false
17
17
  }
18
18
  end
19
19
  end
@@ -26,6 +26,7 @@ module TalltyImportExport
26
26
  # chain: 导出时对象属性通过链式调用
27
27
  # index: 数组方式,需要嵌套拿到里面的
28
28
  # merge: true/false,默认false,某一列,如果上下行的内容相同,则直接合并单元格
29
+ # json: model_payload,代表存储在某一个列中
29
30
 
30
31
  def export_xlsx records, **options
31
32
  records = with_scope records
@@ -138,7 +139,7 @@ module TalltyImportExport
138
139
  @headers || export_headers
139
140
  end
140
141
 
141
- def export_headers
142
+ def export_headers **args
142
143
  @headers || klass.try(:headers) || klass.try(:model_headers)
143
144
  end
144
145
 
@@ -1,11 +1,10 @@
1
1
  module TalltyImportExport
2
2
  class Import
3
3
  require 'roo'
4
- attr_reader :klass, :context, :headers, :primary_keys, :associations
4
+ attr_reader :klass, :context, :primary_keys, :associations
5
5
 
6
6
  def initialize klass
7
7
  @klass = klass
8
- @headers = import_headers_result.map { |header| header.with_indifferent_access }
9
8
  @context = Context.new({})
10
9
  end
11
10
 
@@ -15,6 +14,7 @@ module TalltyImportExport
15
14
  # format: excel是否需要特定的格式,目前主要是类似于身份证号,可以用string
16
15
  # convert: 导入时候,把excel的内容转换成导入时候代码逻辑需要的内容
17
16
  # primary_key: 是否是主键
17
+ # json: model_payload,代表存储在某一个列中
18
18
 
19
19
  # xlsx_file 为 file path or file object or TalltyImportExport::Excel.new
20
20
  def import_xlsx xlsx_file, associations, **options
@@ -100,8 +100,8 @@ module TalltyImportExport
100
100
  @headers || import_headers
101
101
  end
102
102
 
103
- def import_headers
104
- @headers || klass.try(:import_headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers'))
103
+ def import_headers **args
104
+ @headers || klass.try(:headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers'))
105
105
  end
106
106
 
107
107
  # 只保留 key, name, json, 合并到 import_header
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.5"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tallty_import_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - liyijie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-23 00:00:00.000000000 Z
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip-zip
@@ -149,6 +149,7 @@ files:
149
149
  - lib/tallty_import_export/import.rb
150
150
  - lib/tallty_import_export/importable.rb
151
151
  - lib/tallty_import_export/version.rb
152
+ - tallty_import_export-1.0.3.gem
152
153
  - tallty_import_export.gemspec
153
154
  homepage: https://git.tallty.com/open-source/tallty_import_export
154
155
  licenses: