kirico 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11278a08f4962c88c18f859a5cf9daddc36aab19
4
- data.tar.gz: 84a22bef5d2bd17da7e46795fae2519fe9202426
3
+ metadata.gz: b8dbe4cd6dfa085f207852e7431ba7b2aa5dffcd
4
+ data.tar.gz: c094454efe621dc43b18a6c45c530f64a8900bda
5
5
  SHA512:
6
- metadata.gz: 9a62c56c52fe852eb286108e56b7b7243e973381f0313bbf51a74457e649c7f214023cfb3e1d025ba84ba623ab4984599a7802fd5c292685e91a3a6d24ca45a7
7
- data.tar.gz: dc24d98d2e5e99b4fe6b93518139c7e760b8793505e9875cff5f29b7458d10f652d215d70aee9f1ed62b259c31e57df05c4067a58037a70da70e2f41e4865dce
6
+ metadata.gz: f7ba0f28942b2d12f89a4d389a73498b5907b9bbb3d19f01027d1796bc0df8650ce3b82cfe6f0ddc0b0e0f6a3ff4ad7750fbec70bce2cc4cbea3ee2bcbf25231
7
+ data.tar.gz: 75f57b616bf35e1be655a877b2ad585973ece84792e1fb10855f2de248f632f480728f6711919c08ebf24cba07b6dc9dd7802e3b22e4b13bd480b2901880a9eb
@@ -45,4 +45,5 @@ Gem::Specification.new do |spec|
45
45
  spec.add_development_dependency 'guard-rubocop'
46
46
  spec.add_development_dependency 'pry'
47
47
  spec.add_development_dependency 'pry-byebug'
48
+ spec.add_development_dependency 'shoulda-matchers'
48
49
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'kirico/version'
3
+ require 'kirico/models/application_record'
3
4
  require 'kirico/models/changing_address_record'
4
5
  require 'kirico/models/company_count'
5
6
  require 'kirico/models/company_identifier'
@@ -7,6 +8,7 @@ require 'kirico/models/company'
7
8
  require 'kirico/models/data_identifier'
8
9
  require 'kirico/models/fd_management_record'
9
10
  require 'kirico/models/helper'
11
+ require 'kirico/models/form'
10
12
  require 'kirico/csv_generator'
11
13
 
12
14
  module Kirico
@@ -57,3 +57,7 @@ ja:
57
57
  fd_seq_number: FD通番
58
58
  created_at: 作成年月日
59
59
  main_doc_code: 代表届書コード
60
+ kirico/form:
61
+ records: 届書情報
62
+ company: 事業所情報
63
+ fd: FD管理情報
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'virtus'
3
+ require 'active_model'
4
+ require 'kirico/models/helper'
5
+ require 'validates_timeliness'
6
+
7
+ module Kirico
8
+ class ApplicationRecord
9
+ include Virtus.model
10
+ include ActiveModel::Validations
11
+ extend Kirico::Helper
12
+
13
+ def initialize
14
+ yield(self) if block_given?
15
+ end
16
+
17
+ def to_csv
18
+ raise NoMethodError
19
+ end
20
+ end
21
+ end
@@ -1,15 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'virtus'
3
- require 'active_model'
4
- require 'kirico/models/helper'
5
- require 'validates_timeliness'
6
-
7
2
  module Kirico
8
- class ChangingAddressRecord
9
- include Virtus.model
10
- include ActiveModel::Validations
11
- extend Kirico::Helper
12
-
3
+ class ChangingAddressRecord < ApplicationRecord
13
4
  DOC_CODE = '22187041'
14
5
 
15
6
  attribute :area_code, String
@@ -25,7 +25,7 @@ module Kirico
25
25
  validates :address, charset: { accept: [:all] }, sjis_bytesize: { in: 1..75 }
26
26
  validates :name, charset: { accept: [:katakana, :kanji] }, sjis_bytesize: { in: 1..50 }
27
27
  validates :owner_name, charset: { accept: [:katakana, :kanji] }, sjis_bytesize: { in: 1..25 }
28
- validates :tel_number, charset: { accept: [:latin, :number] }, sjis_bytesize: { in: 1..12 }
28
+ validates :tel_number, charset: { accept: [:latin, :numeric] }, sjis_bytesize: { in: 1..12 }
29
29
 
30
30
  def initialize
31
31
  yield(self) if block_given?
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ require 'virtus'
3
+ require 'active_model'
4
+
5
+ module Kirico
6
+ class Form
7
+ include Virtus.model
8
+ include ActiveModel::Validations
9
+
10
+ FILE_NAME = 'SHFD0006.CSV'
11
+
12
+ attribute :fd, Kirico::FDManagementRecord
13
+ attribute :company, Kirico::Company
14
+ attribute :records, Array[Kirico::ApplicationRecord]
15
+
16
+ validates :fd, :company, :records, presence: true
17
+ validate :validate_children
18
+
19
+ def initialize(fd:, company:, records: [])
20
+ @fd = fd
21
+ @company = company
22
+ @records = records
23
+ end
24
+
25
+ def to_csv
26
+ [
27
+ @fd.to_csv,
28
+ Kirico::CompanyIdentifier.new.to_csv,
29
+ Kirico::CompanyCount.new.to_csv,
30
+ @company.to_csv,
31
+ Kirico::DataIdentifier.new.to_csv,
32
+ @records.map(&:to_csv).join("\n")
33
+ ].join("\n")
34
+ end
35
+
36
+ private
37
+
38
+ # 子のエラーを自身のエラーとして設定する
39
+ def validate_children
40
+ [:fd, :company, :records].each do |attribute|
41
+ records = [send(attribute)].flatten.compact
42
+ records.each do |rec|
43
+ next if rec.valid?
44
+ rec.errors.full_messages.each do |msg|
45
+ errors.add(attribute, msg)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kirico
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kirico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kakipo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: shoulda-matchers
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  description: Write a longer description or delete this line.
224
238
  email:
225
239
  - kakipo@gmail.com
@@ -245,12 +259,14 @@ files:
245
259
  - lib/kirico/config/locales/en.yml
246
260
  - lib/kirico/config/locales/ja.yml
247
261
  - lib/kirico/csv_generator.rb
262
+ - lib/kirico/models/application_record.rb
248
263
  - lib/kirico/models/changing_address_record.rb
249
264
  - lib/kirico/models/company.rb
250
265
  - lib/kirico/models/company_count.rb
251
266
  - lib/kirico/models/company_identifier.rb
252
267
  - lib/kirico/models/data_identifier.rb
253
268
  - lib/kirico/models/fd_management_record.rb
269
+ - lib/kirico/models/form.rb
254
270
  - lib/kirico/models/helper.rb
255
271
  - lib/kirico/models/mappers.yml
256
272
  - lib/kirico/validators/charset_validator.rb