super_tools 0.0.25 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +21 -0
  3. data/.gitignore +5 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +161 -150
  7. data/README.md +2 -1
  8. data/dependabot.yml +7 -0
  9. data/lib/super_form/basic.rb +2 -7
  10. data/lib/super_form/concerns/atomic_save.rb +3 -3
  11. data/lib/super_form/reform.rb +28 -6
  12. data/lib/super_formatter/ecan/head.rb +4 -4
  13. data/lib/super_formatter/ecan/import.rb +4 -3
  14. data/lib/super_formatter/ecan/row.rb +3 -2
  15. data/lib/super_formatter/hct/head.rb +5 -5
  16. data/lib/super_formatter/hct/import.rb +4 -3
  17. data/lib/super_formatter/hct/row.rb +4 -3
  18. data/lib/super_formatter/shopline/head.rb +16 -16
  19. data/lib/super_formatter/shopline/import.rb +5 -6
  20. data/lib/super_formatter/shopline/order.rb +9 -8
  21. data/lib/super_formatter/shopline/row.rb +2 -2
  22. data/lib/super_formatter/tcat/head.rb +4 -4
  23. data/lib/super_formatter/tcat/import.rb +4 -4
  24. data/lib/super_formatter/tcat/row.rb +5 -4
  25. data/lib/super_interaction/beyond.rb +77 -0
  26. data/lib/super_interaction/beyond_helper.rb +13 -0
  27. data/lib/super_interaction/{command.rb → bootstrap.rb} +2 -2
  28. data/lib/super_interaction/{controller_helper.rb → bootstrap_helper.rb} +2 -2
  29. data/lib/super_interaction/engine.rb +6 -0
  30. data/lib/super_interaction/views/layouts/beyond.haml +27 -0
  31. data/lib/super_interaction/views/layouts/modal_bs3.haml +2 -2
  32. data/lib/super_interaction/views/layouts/modal_bs4.haml +2 -2
  33. data/lib/super_process/basic.rb +12 -0
  34. data/lib/super_process/core.rb +26 -25
  35. data/lib/super_search/scroll.rb +11 -8
  36. data/lib/super_spreadsheet/loader.rb +14 -14
  37. data/lib/super_table/action_view.rb +4 -4
  38. data/lib/super_table/builder.rb +5 -4
  39. data/lib/super_table/record.rb +1 -1
  40. data/lib/super_tools/version.rb +2 -2
  41. data/lib/super_tools.rb +42 -28
  42. data/lib/super_zipcode/taiwan.rb +131 -102
  43. data/super_tools.gemspec +17 -23
  44. metadata +92 -67
  45. data/lib/super_logger/formatter.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: af3ee2961bfd642dbdefa9f348ac6170641954b3
4
- data.tar.gz: 4b4138e6842c4579768b7f2025989c07b1a6ab23
2
+ SHA256:
3
+ metadata.gz: 4e679f4b41ffa1f04baee132e45b854efa2317e03b6300d747968f858caab6a6
4
+ data.tar.gz: 4e635e119e9dfd2bcf058be7db40418e0874eaef755b3892048ec7c54bda3011
5
5
  SHA512:
6
- metadata.gz: 3ce3520f560f7f10d557b2cd96cbcf3670b29149d806f810547bfcc496049adbf67f2b5c6f689bc4a67b44ac89a45d82f5ce749e1fa4278eeb7501e220a6781f
7
- data.tar.gz: 797bf949ca35a2bf9d7aa63cfea0194ae7b22317f0791c535b22f057d5ec20162d7d03cfcfe31930f28a16e0f2c8ad5ab0086140b6db560be43da30a1ecf129c
6
+ metadata.gz: 32a411a0cd5e85fb222c5d1224e6e67b22fabdc2a3918ff757a4f816ff3c1e705ac79d8d83f753eb6256852f9286e6c7debb20a260e598bdb6ec5719dc5020be
7
+ data.tar.gz: d7c222e501cd6d8877cadaf6b2524428b5c478d02f61572fc6ec063a0d5243db1b36fee4181050e4dd68628c44447023af68995616b497dca71d35cd72241f84
@@ -0,0 +1,21 @@
1
+ name: Test
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'fix-**'
6
+ - 'feat-**'
7
+ - develop
8
+ - master
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ with:
16
+ fetch-depth: 1
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ bundler-cache: true
20
+ - run: bundle
21
+ - run: bundle exec rake t
data/.gitignore CHANGED
@@ -6,3 +6,8 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ vendor
10
+ *.*.sw?
11
+ .DS_Store
12
+ db/
13
+ log/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.4
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in super_tools.gemspec
6
6
  gemspec
7
+
8
+ gem "reform-rails", github: "superlanding/reform-rails", branch: "fix-infinite-parent-loop"
data/Gemfile.lock CHANGED
@@ -1,18 +1,26 @@
1
+ GIT
2
+ remote: https://github.com/superlanding/reform-rails
3
+ revision: 66240539260e6969dc01a77cf181b39109ebb941
4
+ branch: fix-infinite-parent-loop
5
+ specs:
6
+ reform-rails (0.2.2)
7
+ activemodel (>= 5.0)
8
+ reform (>= 2.3.1, < 3.0.0)
9
+
1
10
  PATH
2
11
  remote: .
3
12
  specs:
4
- super_tools (0.0.8)
5
- dry-logic (~> 0.4.2)
6
- dry-types (~> 0.13.2)
13
+ super_tools (3.0.0)
14
+ dry-logic (= 1.2.0)
15
+ dry-types (= 1.5.1)
7
16
  fast_excel
8
17
  forwardable
9
- iconv
10
- nokogiri (>= 1.6, <= 1.9.1)
11
- rails (>= 4)
12
- reform (~> 2.2.4)
18
+ nokogiri (>= 1.6)
19
+ rails (> 6, < 7)
20
+ reform (= 2.6.2)
13
21
  reform-rails
14
22
  roo
15
- roo-xls
23
+ roo-xls (= 1.2.0)
16
24
  searchkick
17
25
  spreadsheet
18
26
  virtus (~> 1.0.5)
@@ -21,194 +29,191 @@ PATH
21
29
  GEM
22
30
  remote: https://rubygems.org/
23
31
  specs:
24
- actioncable (5.2.3)
25
- actionpack (= 5.2.3)
32
+ actioncable (6.1.6)
33
+ actionpack (= 6.1.6)
34
+ activesupport (= 6.1.6)
26
35
  nio4r (~> 2.0)
27
36
  websocket-driver (>= 0.6.1)
28
- actionmailer (5.2.3)
29
- actionpack (= 5.2.3)
30
- actionview (= 5.2.3)
31
- activejob (= 5.2.3)
37
+ actionmailbox (6.1.6)
38
+ actionpack (= 6.1.6)
39
+ activejob (= 6.1.6)
40
+ activerecord (= 6.1.6)
41
+ activestorage (= 6.1.6)
42
+ activesupport (= 6.1.6)
43
+ mail (>= 2.7.1)
44
+ actionmailer (6.1.6)
45
+ actionpack (= 6.1.6)
46
+ actionview (= 6.1.6)
47
+ activejob (= 6.1.6)
48
+ activesupport (= 6.1.6)
32
49
  mail (~> 2.5, >= 2.5.4)
33
50
  rails-dom-testing (~> 2.0)
34
- actionpack (5.2.3)
35
- actionview (= 5.2.3)
36
- activesupport (= 5.2.3)
37
- rack (~> 2.0)
51
+ actionpack (6.1.6)
52
+ actionview (= 6.1.6)
53
+ activesupport (= 6.1.6)
54
+ rack (~> 2.0, >= 2.0.9)
38
55
  rack-test (>= 0.6.3)
39
56
  rails-dom-testing (~> 2.0)
40
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
41
- actionview (5.2.3)
42
- activesupport (= 5.2.3)
57
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
58
+ actiontext (6.1.6)
59
+ actionpack (= 6.1.6)
60
+ activerecord (= 6.1.6)
61
+ activestorage (= 6.1.6)
62
+ activesupport (= 6.1.6)
63
+ nokogiri (>= 1.8.5)
64
+ actionview (6.1.6)
65
+ activesupport (= 6.1.6)
43
66
  builder (~> 3.1)
44
67
  erubi (~> 1.4)
45
68
  rails-dom-testing (~> 2.0)
46
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
47
- activejob (5.2.3)
48
- activesupport (= 5.2.3)
69
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
70
+ activejob (6.1.6)
71
+ activesupport (= 6.1.6)
49
72
  globalid (>= 0.3.6)
50
- activemodel (5.2.3)
51
- activesupport (= 5.2.3)
52
- activerecord (5.2.3)
53
- activemodel (= 5.2.3)
54
- activesupport (= 5.2.3)
55
- arel (>= 9.0)
56
- activestorage (5.2.3)
57
- actionpack (= 5.2.3)
58
- activerecord (= 5.2.3)
59
- marcel (~> 0.3.1)
60
- activesupport (5.2.3)
73
+ activemodel (6.1.6)
74
+ activesupport (= 6.1.6)
75
+ activerecord (6.1.6)
76
+ activemodel (= 6.1.6)
77
+ activesupport (= 6.1.6)
78
+ activestorage (6.1.6)
79
+ actionpack (= 6.1.6)
80
+ activejob (= 6.1.6)
81
+ activerecord (= 6.1.6)
82
+ activesupport (= 6.1.6)
83
+ marcel (~> 1.0)
84
+ mini_mime (>= 1.1.0)
85
+ activesupport (6.1.6)
61
86
  concurrent-ruby (~> 1.0, >= 1.0.2)
62
- i18n (>= 0.7, < 2)
63
- minitest (~> 5.1)
64
- tzinfo (~> 1.1)
65
- arel (9.0.0)
87
+ i18n (>= 1.6, < 2)
88
+ minitest (>= 5.1)
89
+ tzinfo (~> 2.0)
90
+ zeitwerk (~> 2.3)
66
91
  axiom-types (0.1.1)
67
92
  descendants_tracker (~> 0.0.4)
68
93
  ice_nine (~> 0.11.0)
69
94
  thread_safe (~> 0.3, >= 0.3.1)
70
- builder (3.2.3)
95
+ builder (3.2.4)
71
96
  coercible (1.0.0)
72
97
  descendants_tracker (~> 0.0.1)
73
- concurrent-ruby (1.1.5)
74
- crass (1.0.4)
75
- declarative (0.0.10)
76
- declarative-builder (0.1.0)
77
- declarative-option (< 0.2.0)
78
- declarative-option (0.1.0)
98
+ concurrent-ruby (1.1.10)
99
+ crass (1.0.6)
100
+ declarative (0.0.20)
79
101
  descendants_tracker (0.0.4)
80
102
  thread_safe (~> 0.3, >= 0.3.1)
81
- disposable (0.4.5)
103
+ disposable (0.6.3)
82
104
  declarative (>= 0.0.9, < 1.0.0)
83
- declarative-builder (< 0.2.0)
84
- declarative-option (< 0.2.0)
85
- representable (>= 2.4.0, <= 3.1.0)
86
- uber (< 0.2.0)
87
- dry-configurable (0.7.0)
105
+ representable (>= 3.1.1, < 4)
106
+ dry-configurable (0.15.0)
88
107
  concurrent-ruby (~> 1.0)
89
- dry-container (0.6.0)
108
+ dry-core (~> 0.6)
109
+ dry-container (0.9.0)
90
110
  concurrent-ruby (~> 1.0)
91
- dry-configurable (~> 0.1, >= 0.1.3)
92
- dry-core (0.4.7)
111
+ dry-configurable (~> 0.13, >= 0.13.0)
112
+ dry-core (0.7.1)
93
113
  concurrent-ruby (~> 1.0)
94
- dry-equalizer (0.2.2)
95
- dry-inflector (0.1.2)
96
- dry-logic (0.4.2)
97
- dry-container (~> 0.2, >= 0.2.6)
98
- dry-core (~> 0.2)
99
- dry-equalizer (~> 0.2)
100
- dry-types (0.13.4)
114
+ dry-inflector (0.2.1)
115
+ dry-logic (1.2.0)
116
+ concurrent-ruby (~> 1.0)
117
+ dry-core (~> 0.5, >= 0.5)
118
+ dry-types (1.5.1)
101
119
  concurrent-ruby (~> 1.0)
102
120
  dry-container (~> 0.3)
103
- dry-core (~> 0.4, >= 0.4.4)
104
- dry-equalizer (~> 0.2)
121
+ dry-core (~> 0.5, >= 0.5)
105
122
  dry-inflector (~> 0.1, >= 0.1.2)
106
- dry-logic (~> 0.4, >= 0.4.2)
107
- elasticsearch (7.0.0)
108
- elasticsearch-api (= 7.0.0)
109
- elasticsearch-transport (= 7.0.0)
110
- elasticsearch-api (7.0.0)
111
- multi_json
112
- elasticsearch-transport (7.0.0)
113
- faraday
114
- multi_json
123
+ dry-logic (~> 1.0, >= 1.0.2)
115
124
  equalizer (0.0.11)
116
- erubi (1.8.0)
117
- faraday (0.15.4)
118
- multipart-post (>= 1.2, < 3)
119
- fast_excel (0.2.6)
125
+ erubi (1.10.0)
126
+ fast_excel (0.4.0)
120
127
  ffi (> 1.9, < 2)
121
- ffi (1.10.0)
122
- forwardable (1.2.0)
123
- globalid (0.4.2)
124
- activesupport (>= 4.2.0)
125
- hashie (3.6.0)
126
- i18n (1.5.1)
128
+ ffi (1.15.5)
129
+ forwardable (1.3.2)
130
+ globalid (1.0.0)
131
+ activesupport (>= 5.0)
132
+ hashie (5.0.0)
133
+ i18n (1.10.0)
127
134
  concurrent-ruby (~> 1.0)
128
135
  ice_nine (0.11.2)
129
- iconv (1.0.8)
130
- loofah (2.2.3)
136
+ loofah (2.18.0)
131
137
  crass (~> 1.0.2)
132
138
  nokogiri (>= 1.5.9)
133
139
  mail (2.7.1)
134
140
  mini_mime (>= 0.1.1)
135
- marcel (0.3.3)
136
- mimemagic (~> 0.3.2)
137
- method_source (0.9.2)
138
- mimemagic (0.3.3)
139
- mini_mime (1.0.1)
140
- mini_portile2 (2.4.0)
141
- minitest (5.11.3)
142
- multi_json (1.13.1)
143
- multipart-post (2.0.0)
144
- nio4r (2.3.1)
145
- nokogiri (1.9.1)
146
- mini_portile2 (~> 2.4.0)
147
- rack (2.0.8)
148
- rack-test (1.1.0)
149
- rack (>= 1.0, < 3)
150
- rails (5.2.3)
151
- actioncable (= 5.2.3)
152
- actionmailer (= 5.2.3)
153
- actionpack (= 5.2.3)
154
- actionview (= 5.2.3)
155
- activejob (= 5.2.3)
156
- activemodel (= 5.2.3)
157
- activerecord (= 5.2.3)
158
- activestorage (= 5.2.3)
159
- activesupport (= 5.2.3)
160
- bundler (>= 1.3.0)
161
- railties (= 5.2.3)
141
+ marcel (1.0.2)
142
+ method_source (1.0.0)
143
+ mini_mime (1.1.2)
144
+ minitest (5.16.2)
145
+ nio4r (2.5.8)
146
+ nokogiri (1.13.6-arm64-darwin)
147
+ racc (~> 1.4)
148
+ nokogiri (1.13.6-x86_64-linux)
149
+ racc (~> 1.4)
150
+ racc (1.6.0)
151
+ rack (2.2.4)
152
+ rack-test (2.0.2)
153
+ rack (>= 1.3)
154
+ rails (6.1.6)
155
+ actioncable (= 6.1.6)
156
+ actionmailbox (= 6.1.6)
157
+ actionmailer (= 6.1.6)
158
+ actionpack (= 6.1.6)
159
+ actiontext (= 6.1.6)
160
+ actionview (= 6.1.6)
161
+ activejob (= 6.1.6)
162
+ activemodel (= 6.1.6)
163
+ activerecord (= 6.1.6)
164
+ activestorage (= 6.1.6)
165
+ activesupport (= 6.1.6)
166
+ bundler (>= 1.15.0)
167
+ railties (= 6.1.6)
162
168
  sprockets-rails (>= 2.0.0)
163
169
  rails-dom-testing (2.0.3)
164
170
  activesupport (>= 4.2.0)
165
171
  nokogiri (>= 1.6)
166
- rails-html-sanitizer (1.0.4)
167
- loofah (~> 2.2, >= 2.2.2)
168
- railties (5.2.3)
169
- actionpack (= 5.2.3)
170
- activesupport (= 5.2.3)
172
+ rails-html-sanitizer (1.4.3)
173
+ loofah (~> 2.3)
174
+ railties (6.1.6)
175
+ actionpack (= 6.1.6)
176
+ activesupport (= 6.1.6)
171
177
  method_source
172
- rake (>= 0.8.7)
173
- thor (>= 0.19.0, < 2.0)
174
- rake (10.5.0)
175
- reform (2.2.4)
176
- disposable (>= 0.4.1)
177
- representable (>= 2.4.0, < 3.1.0)
178
- reform-rails (0.1.7)
179
- activemodel (>= 3.2)
180
- reform (>= 2.2.0)
181
- representable (3.0.4)
178
+ rake (>= 12.2)
179
+ thor (~> 1.0)
180
+ rake (13.0.6)
181
+ reform (2.6.2)
182
+ disposable (>= 0.5.0, < 1.0.0)
183
+ representable (>= 3.1.1, < 4)
184
+ uber (< 0.2.0)
185
+ representable (3.2.0)
182
186
  declarative (< 0.1.0)
183
- declarative-option (< 0.2.0)
187
+ trailblazer-option (>= 0.1.1, < 0.2.0)
184
188
  uber (< 0.2.0)
185
- roo (2.7.1)
189
+ roo (2.9.0)
186
190
  nokogiri (~> 1)
187
- rubyzip (~> 1.1, < 2.0.0)
191
+ rubyzip (>= 1.3.0, < 3.0.0)
188
192
  roo-xls (1.2.0)
189
193
  nokogiri
190
194
  roo (>= 2.0.0, < 3)
191
195
  spreadsheet (> 0.9.0)
192
196
  ruby-ole (1.2.12.2)
193
- rubyzip (1.2.2)
194
- searchkick (3.1.3)
195
- activemodel (>= 4.2)
196
- elasticsearch (>= 5)
197
+ rubyzip (2.3.2)
198
+ searchkick (5.0.4)
199
+ activemodel (>= 5.2)
197
200
  hashie
198
- shoulda-context (1.2.2)
199
- spreadsheet (1.2.3)
200
- ruby-ole (>= 1.0)
201
- sprockets (3.7.2)
201
+ shoulda-context (2.0.0)
202
+ spreadsheet (1.3.0)
203
+ ruby-ole
204
+ sprockets (4.1.1)
202
205
  concurrent-ruby (~> 1.0)
203
206
  rack (> 1, < 3)
204
- sprockets-rails (3.2.1)
205
- actionpack (>= 4.0)
206
- activesupport (>= 4.0)
207
+ sprockets-rails (3.4.2)
208
+ actionpack (>= 5.2)
209
+ activesupport (>= 5.2)
207
210
  sprockets (>= 3.0.0)
208
- thor (0.20.3)
211
+ sqlite3 (1.4.4)
212
+ thor (1.2.1)
209
213
  thread_safe (0.3.6)
210
- tzinfo (1.2.5)
211
- thread_safe (~> 0.1)
214
+ trailblazer-option (0.1.2)
215
+ tzinfo (2.0.4)
216
+ concurrent-ruby (~> 1.0)
212
217
  uber (0.1.0)
213
218
  virtus (1.0.5)
214
219
  axiom-types (~> 0.1)
@@ -217,19 +222,25 @@ GEM
217
222
  equalizer (~> 0.0, >= 0.0.9)
218
223
  warehouse_items (0.3.0)
219
224
  activesupport
220
- websocket-driver (0.7.0)
225
+ warning (1.2.1)
226
+ websocket-driver (0.7.5)
221
227
  websocket-extensions (>= 0.1.0)
222
- websocket-extensions (0.1.3)
228
+ websocket-extensions (0.1.5)
229
+ zeitwerk (2.6.0)
223
230
 
224
231
  PLATFORMS
225
- ruby
232
+ arm64-darwin-21
233
+ x86_64-linux
226
234
 
227
235
  DEPENDENCIES
228
- bundler (~> 1.16)
236
+ bundler (>= 2, < 3)
229
237
  minitest (~> 5.0)
230
- rake (~> 10.0)
238
+ rake (>= 12.2)
239
+ reform-rails!
231
240
  shoulda-context
241
+ sqlite3 (= 1.4.4)
232
242
  super_tools!
243
+ warning
233
244
 
234
245
  BUNDLED WITH
235
- 1.17.1
246
+ 2.3.16
data/README.md CHANGED
@@ -84,7 +84,8 @@ SuperTable::Tableable.send(:include, ::Rails.application.routes.url_helpers)
84
84
 
85
85
  ```ruby
86
86
  class ApplicationController < ActionController::Base
87
- include SuperInteraction::ControllerHelper
87
+ include SuperInteraction::BootstrapHelper
88
+ include SuperInteraction::BeyondrHelper
88
89
  end
89
90
  ```
90
91
 
data/dependabot.yml ADDED
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ target-branch: "feat-rails-6.1.6"
6
+ schedule:
7
+ interval: "daily"
@@ -1,4 +1,5 @@
1
- require 'virtus'
1
+ require "virtus"
2
+
2
3
  module SuperForm
3
4
  class Basic
4
5
  include ActiveModel::Model
@@ -7,12 +8,6 @@ module SuperForm
7
8
  include ActiveModel::Validations
8
9
  include Virtus.model
9
10
 
10
- def sync_params(params)
11
- params.each do |attr, value|
12
- public_send("#{attr}=", value) if respond_to?("#{attr}=")
13
- end
14
- end
15
-
16
11
  class << self
17
12
  def form_name(name)
18
13
  # 定義 form name (給 form 用的)
@@ -60,17 +60,17 @@ module SuperForm
60
60
  # 1. do validate data
61
61
  run_callbacks :validations do
62
62
  if validate(params) == false
63
- raise ReformAtomicSaveError, "Not Validate => #{self.errors.full_messages.inspect}"
63
+ raise ReformAtomicSaveError, "Not Validate => #{self.errors.full_messages}"
64
64
  end
65
65
  end
66
66
 
67
67
  # 2. sync to model
68
68
  sync
69
69
 
70
- # 2. define how to store data in block
70
+ # 3. define how to store data in block
71
71
  yield if block_given?
72
72
 
73
- # 3. save all data
73
+ # 4. save all data
74
74
  save!
75
75
  end
76
76
  end
@@ -1,10 +1,11 @@
1
- require 'super_form/concerns/atomic_save'
2
- require 'reform'
3
- require 'reform/form'
4
- require 'reform/active_record'
1
+ require "super_form/concerns/atomic_save"
2
+ require "reform"
3
+ require "reform/rails"
4
+ require "reform/form"
5
+ require "reform/active_record"
5
6
  require "reform/form/coercion"
6
- require 'disposable'
7
- require 'disposable/twin/parent'
7
+ require "disposable"
8
+ require "disposable/twin/parent"
8
9
 
9
10
  class SuperForm::Reform < Reform::Form
10
11
  include SuperForm::AtomicSave
@@ -25,6 +26,27 @@ class SuperForm::Reform < Reform::Form
25
26
  define_singleton_method :model_name do
26
27
  active_model_name_for(name.to_s.camelize) # Reform::Form::ActiveModel
27
28
  end
29
+ # NOTE: 這行很可能沒有作用
28
30
  model(name)
29
31
  end
30
32
  end
33
+
34
+ # Hack Dry::Type 升級 0.15 以後
35
+ # 變成強制型別,會造成 params input 空字串時的錯誤
36
+ # 這裡是 hack
37
+ # https://github.com/apotonick/disposable/blob/master/lib/disposable/twin/coercion.rb
38
+ # https://github.com/dry-rb/dry-types/blob/a4983c88299b6f323a769f783cf956629e61f8ed/lib/dry/types/coercions/params.rb#L86
39
+
40
+ Dry::Types::Coercions::Params.module_eval do
41
+ def self.to_int(input, &block)
42
+ if input.is_a? String
43
+ Integer(input, 10)
44
+ else
45
+ Integer(input)
46
+ end
47
+ rescue ArgumentError, TypeError => e
48
+ return input.to_i if input.respond_to?(:to_i)
49
+
50
+ CoercionError.handle(e, &block)
51
+ end
52
+ end
@@ -3,11 +3,11 @@ module SuperFormatter
3
3
  Head = Struct.new(:data) do
4
4
  def indexes
5
5
  @indexes ||= {
6
- global_order_id: data.index('客戶單號'),
7
- recipient: data.index('收件人'),
8
- tracking_code: data.index('宅配單號')
6
+ global_order_id: data.index("客戶單號"),
7
+ recipient: data.index("收件人"),
8
+ tracking_code: data.index("宅配單號")
9
9
  }
10
10
  end
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -1,6 +1,7 @@
1
- require 'super_formatter/import'
2
- require 'super_formatter/hct/head'
3
- require 'super_formatter/hct/row'
1
+ require "super_formatter/import"
2
+ require "super_formatter/hct/head"
3
+ require "super_formatter/hct/row"
4
+
4
5
  module SuperFormatter
5
6
  module Ecan
6
7
  class Import < SuperFormatter::Import
@@ -1,11 +1,12 @@
1
- require 'super_formatter/row'
1
+ require "super_formatter/row"
2
+
2
3
  module SuperFormatter
3
4
  module Ecan
4
5
  class Row < ::SuperFormatter::Row
5
6
 
6
7
  def global_order_id
7
8
  order_id = (find(:global_order_id) || "")
8
- if order_id[0] == 'C'
9
+ if order_id[0] == "C"
9
10
  order_id[1, order_id.length - 1]
10
11
  else
11
12
  order_id
@@ -3,12 +3,12 @@ module SuperFormatter
3
3
  Head = Struct.new(:data) do
4
4
  def indexes
5
5
  @indexes ||= {
6
- global_order_id: data.index('訂單號碼') || data.index('清單編號'),
7
- mobile: data.index('收貨人電話') || data.index('收貨人電話1'),
8
- recipient: data.index('收貨人') || data.index('收貨人名稱'),
9
- tracking_code: data.index('查貨號碼') || data.index('十碼貨號')
6
+ global_order_id: data.index("訂單號碼") || data.index("清單編號"),
7
+ mobile: data.index("收貨人電話") || data.index("收貨人電話1"),
8
+ recipient: data.index("收貨人") || data.index("收貨人名稱"),
9
+ tracking_code: data.index("查貨號碼") || data.index("十碼貨號")
10
10
  }
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -1,6 +1,7 @@
1
- require 'super_formatter/import'
2
- require 'super_formatter/hct/head'
3
- require 'super_formatter/hct/row'
1
+ require "super_formatter/import"
2
+ require "super_formatter/hct/head"
3
+ require "super_formatter/hct/row"
4
+
4
5
  module SuperFormatter
5
6
  module Hct
6
7
  class Import < ::SuperFormatter::Import
@@ -1,16 +1,17 @@
1
- require 'super_formatter/row'
1
+ require "super_formatter/row"
2
+
2
3
  module SuperFormatter
3
4
  module Hct
4
5
  class Row < ::SuperFormatter::Row
5
6
 
6
7
  def tracking_code
7
- (find(:tracking_code) || "").gsub("'", '')
8
+ (find(:tracking_code) || "").gsub("'", "")
8
9
  end
9
10
 
10
11
  def mobile
11
12
  @mobile ||= begin
12
13
  text = (find(:mobile) || "").gsub("'", "")
13
- if text[0] == '9' && text.length == 9
14
+ if text[0] == "9" && text.length == 9
14
15
  "0#{text}"
15
16
  else
16
17
  text