kamome 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -2
- data/Gemfile.lock +1 -1
- data/README.md +1 -7
- data/lib/kamome/csv_handler.rb +13 -5
- data/lib/kamome/loader.rb +6 -1
- data/lib/kamome/models/address.rb +8 -1
- data/lib/kamome/operation.rb +0 -5
- data/lib/kamome/transformations/general_csv.rb +2 -1
- data/lib/kamome/transformations/jigyosho_csv.rb +2 -1
- data/lib/kamome/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35ffe91d4c66bc1f179e7db9980ecbf6800633de1af8f3de76645dffb926d423
|
4
|
+
data.tar.gz: 5e373d056502af1d4f6b1ca51d0ca44d2adf26daaef07d706e79ca115472fd9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b41f5d5424612e149377fd3deff5b29e5cfe5e88addca51f89c49deeabe3a0e50111686a429f1ce0b314239fe5508222fc06f8277fd5adb10095961c8bc9c52
|
7
|
+
data.tar.gz: 759139eb2ce52cd217b576f814fae768e78af52f330a6d78bafee4502270157a34e1a058e438411a227bfd8035276b16ac9a2ce1ee80f6540a67bb8faa6d6c5d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelogs
|
2
2
|
|
3
|
-
##
|
3
|
+
## v0.9.0
|
4
4
|
|
5
|
-
|
5
|
+
* Fixed [Unexpected town value](https://github.com/kengos/kamome/issues/1)
|
6
|
+
* Skip `block.call` in the case of `#ambisous_town` is true and is not a first appearance model
|
7
|
+
* Drop support `type: :hash`
|
8
|
+
* Support `throw :break` in passed block
|
9
|
+
```rb
|
10
|
+
Kamome::import_general_all do |model, lineno|
|
11
|
+
throw :break if lineno > 10
|
12
|
+
# Do not use `break` without `throw`
|
13
|
+
# break if lineno > 10
|
14
|
+
end
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
* 全国一括 (全件, 差分)
|
18
18
|
* 事業所(全件, 差分)
|
19
19
|
|
20
|
-
各CSVは共通のモデルにマッピングされます(type
|
20
|
+
各CSVは共通のモデルにマッピングされます(type オプションで詳細なモデルに変更可能)
|
21
21
|
|
22
22
|
詳細は [Kamome::Models::Address](https://github.com/kengos/kamome/blob/master/lib/kamome/models/address.rb) を参照してください
|
23
23
|
|
@@ -85,12 +85,6 @@ end
|
|
85
85
|
|
86
86
|
### `Kamome.import_xxx` の model の型を変換したい
|
87
87
|
|
88
|
-
#### Hash にする場合
|
89
|
-
|
90
|
-
```rb
|
91
|
-
Kamome.import_general_all(type: :hash or Kamome::Operation::TYPE_HASH)
|
92
|
-
```
|
93
|
-
|
94
88
|
#### DetailModel にする場合
|
95
89
|
|
96
90
|
```rb
|
data/lib/kamome/csv_handler.rb
CHANGED
@@ -11,9 +11,13 @@ module Kamome
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(csv_path)
|
14
|
+
prev = nil
|
14
15
|
::CSV.foreach(csv_path) do |row|
|
15
16
|
obj = transform(row)
|
16
|
-
|
17
|
+
next if skip?(prev, obj)
|
18
|
+
|
19
|
+
yield(obj, $INPUT_LINE_NUMBER)
|
20
|
+
prev = obj
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
@@ -24,10 +28,7 @@ module Kamome
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def transformed_method
|
27
|
-
|
28
|
-
return :generate_detail_model if @operation.type_detail?
|
29
|
-
|
30
|
-
:generate_model
|
31
|
+
@operation.type_detail? ? :generate_detail_model : :generate_model
|
31
32
|
end
|
32
33
|
|
33
34
|
def transformer
|
@@ -41,5 +42,12 @@ module Kamome
|
|
41
42
|
def general_transformer
|
42
43
|
::Kamome::Transformations::GeneralCsv.new
|
43
44
|
end
|
45
|
+
|
46
|
+
def skip?(previous, current)
|
47
|
+
return false unless previous.respond_to?(:ambiguous_town)
|
48
|
+
return false unless previous.ambiguous_town
|
49
|
+
|
50
|
+
previous.zipcode == current.zipcode
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/kamome/loader.rb
CHANGED
@@ -10,6 +10,9 @@ module Kamome
|
|
10
10
|
@config = config
|
11
11
|
end
|
12
12
|
|
13
|
+
# @params [Operation] Kamome::Operation
|
14
|
+
# @yield [model, lineno] Any logic you want to execute
|
15
|
+
# Don't pass `-> { break }`, use `-> { throw :break }
|
13
16
|
# @return [Array] csv digest
|
14
17
|
def call(operation:, &block)
|
15
18
|
operation.urls.map do |url|
|
@@ -29,7 +32,9 @@ module Kamome
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def call_csv_handler(operation, csv_path, &block)
|
32
|
-
|
35
|
+
catch(:break) do
|
36
|
+
::Kamome::CsvHandler.new(operation).call(csv_path, &block)
|
37
|
+
end
|
33
38
|
::Digest::SHA256.file(csv_path).to_s
|
34
39
|
ensure
|
35
40
|
csv_path.delete if @config.cleanup
|
@@ -51,6 +51,12 @@ module Kamome
|
|
51
51
|
# @return [Integer]
|
52
52
|
attr_accessor :state
|
53
53
|
|
54
|
+
# @!attribute [rw] ambiguous_town
|
55
|
+
# 一町域が二以上の郵便番号で表される場合 true
|
56
|
+
# genre: :general のみ
|
57
|
+
# @return [Boolean]
|
58
|
+
attr_accessor :ambiguous_town
|
59
|
+
|
54
60
|
STATE_NOT_CHANGE = 0
|
55
61
|
STATE_UPDATE = 1
|
56
62
|
STATE_DELETE = 2
|
@@ -73,7 +79,8 @@ module Kamome
|
|
73
79
|
street: street,
|
74
80
|
company_name: company_name,
|
75
81
|
post_office_box: post_office_box,
|
76
|
-
state: state
|
82
|
+
state: state,
|
83
|
+
ambiguous_town: ambiguous_town
|
77
84
|
}
|
78
85
|
end
|
79
86
|
|
data/lib/kamome/operation.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Kamome
|
4
4
|
class Operation
|
5
|
-
TYPE_HASH = :hash
|
6
5
|
TYPE_DETAIL = :detail
|
7
6
|
TYPE_DEFAULT = :default
|
8
7
|
|
@@ -56,10 +55,6 @@ module Kamome
|
|
56
55
|
@urls = urls
|
57
56
|
end
|
58
57
|
|
59
|
-
def type_hash?
|
60
|
-
type == TYPE_HASH
|
61
|
-
end
|
62
|
-
|
63
58
|
def type_detail?
|
64
59
|
type == TYPE_DETAIL
|
65
60
|
end
|
@@ -69,7 +69,8 @@ module Kamome
|
|
69
69
|
street: attributes[:street],
|
70
70
|
company_name: attributes[:company_name],
|
71
71
|
post_office_box: attributes[:post_office_box],
|
72
|
-
state: convert_state(attributes[:state])
|
72
|
+
state: convert_state(attributes[:state]),
|
73
|
+
ambiguous_town: false
|
73
74
|
}
|
74
75
|
end
|
75
76
|
|
data/lib/kamome/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kengos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,5 +184,5 @@ rubyforge_project:
|
|
184
184
|
rubygems_version: 2.7.6
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
|
-
summary: kamome-0.
|
187
|
+
summary: kamome-0.9.0
|
188
188
|
test_files: []
|