recite_csv 1.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: ef71d0d0cb4c4a24e91f11642751e533417d81d7886f19a68a7224e472f9014a
4
- data.tar.gz: 067c533aef4872eeea47fe649c4e8378a66c81978589fbb3daa299c0a258f982
3
+ metadata.gz: 90a7dbd617f57a71f28be00e86a5f492010cb042175f78f1b9ba9dcf024d8f56
4
+ data.tar.gz: bc47489c30d200d851751ad170012d44029e10ef45c9143fccd57985f5c7b6c5
5
5
  SHA512:
6
- metadata.gz: 1142035d29d3b657f67cee1758b39bbb34cc65ad9e7e01e69e8b7cf1ddeef113c5cc7ef42e5b559e1dad3aa874b838d976f8d4ad2603a2e3ebe469120478e71b
7
- data.tar.gz: ffe518f0b2006053eb89cb143410996fc3b8fe68fa327dfe7ce7a2d3a00bdd45916de08228f23091cbcfba31406f7cfe87092b172657f41b710e44e1e6a148d2
6
+ metadata.gz: 5750c6e702e8af1b8272a8583a4913a1929ebad5527fae173281b3c7253336cef264a76e33dbac9a3b5fddc14384c5a2aaa80f72586b673db48f6711ca57a0c2
7
+ data.tar.gz: 97de737c90a8daf462ab0ba3944628bab5de081e9b7e404319f7b38859db453aa23c4348e4bdcde05add4cd917664c073d6ebb7eb7cf5a0de3da3422c4a6a43c
@@ -0,0 +1,19 @@
1
+ name: Build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: ['3.0', '3.1', '3.2', '3.3']
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby }}
17
+ bundler-cache: true
18
+ - name: Run tests
19
+ run: bundle exec rake spec
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  require: rubocop-performance
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.4
4
+ TargetRubyVersion: 3.0
5
+ NewCops: enable
5
6
 
6
7
  Style/AsciiComments:
7
8
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,38 @@
1
1
  ## Unreleased
2
2
 
3
3
 
4
+ ## 2.1.0 (2023-12-25)
5
+
6
+ ### Changes
7
+
8
+ * Add csv gem to runtime dependencies
9
+ * Drop Ruby 2.x support
10
+
11
+ ### Misc
12
+
13
+ * Migrate CI from Travis CI to GitHub Actions
14
+ * CI against for Ruby 3.0, 3.1, 3.2, and 3.3
15
+ * Require MFA to release gem
16
+ * Change the default branch from master to main
17
+ * Correct RuboCop offenses
18
+ * Update dev dependencies
19
+
20
+
21
+ ## 2.0.0 (2020-01-09)
22
+
23
+ ### Breaking changes
24
+
25
+ * Chagne `Reader::Core#each` to return a receiver itself
26
+
27
+ ### Changes
28
+
29
+ * Suppress warnings of keyword arguments in Ruby 2.7
30
+
31
+ ### Misc
32
+
33
+ * Update gem metadata
34
+
35
+
4
36
  ## 1.0.0 (2019-05-29)
5
37
 
6
38
  ### Changes
data/Gemfile CHANGED
@@ -2,5 +2,11 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in recite_csv.gemspec
6
5
  gemspec
6
+
7
+ gem "bundler", ">= 2.2.3"
8
+ gem "pry", ">= 0.14.2"
9
+ gem "rake", ">= 13.1"
10
+ gem "rspec", "~> 3.12"
11
+ gem "rubocop", ">= 1.59.0"
12
+ gem "rubocop-performance", ">= 1.20.1"
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2019 Yuji Hanamura
3
+ Copyright (c) 2017-2023 Yuji Hanamura
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # ReciteCSV
2
2
 
3
- ReciteCSV helps to build a class for CSV reader.
3
+ ReciteCSV assists to implement a class for CSV reader.
4
+ A reader class implemented by ReciteCSV iterate each row as PORO(Plain Old Ruby Object).
4
5
 
5
6
  [![Gem Version](https://badge.fury.io/rb/recite_csv.svg)](https://badge.fury.io/rb/recite_csv)
6
- [![Build Status](https://travis-ci.org/yujideveloper/recite_csv.svg?branch=master)](https://travis-ci.org/yujideveloper/recite_csv)
7
+ [![Build](https://github.com/yujideveloper/recite_csv/actions/workflows/ruby.yml/badge.svg)](https://github.com/yujideveloper/recite_csv/actions/workflows/ruby.yml)
7
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/eb04cab6d55b0c7a1f7f/maintainability)](https://codeclimate.com/github/yujideveloper/recite_csv/maintainability)
8
9
 
9
10
  ## Installation
data/Rakefile CHANGED
File without changes
@@ -32,6 +32,8 @@ module ReciteCSV
32
32
 
33
33
  class ColumnMethodsBuilder < ::Module
34
34
  def initialize(raw_definition)
35
+ super()
36
+
35
37
  raw_definition.each_pair do |method_name, header_name|
36
38
  define_method method_name do
37
39
  self[header_name]
@@ -48,6 +50,8 @@ module ReciteCSV
48
50
  class Array < Base
49
51
  class ColumnMethodsBuilder < ::Module
50
52
  def initialize(raw_definition)
53
+ super()
54
+
51
55
  raw_definition.each.with_index do |name, idx|
52
56
  next if name.nil? || name.empty?
53
57
 
@@ -70,9 +74,7 @@ module ReciteCSV
70
74
  _, definition_class = DEFINITIONS.find do |klass, _|
71
75
  header_definition.is_a? klass
72
76
  end
73
- unless definition_class
74
- raise ::ArgumentError, "Unexpected header definition type"
75
- end
77
+ raise ::ArgumentError, "Unexpected header definition type" unless definition_class
76
78
 
77
79
  definition_class.new(header_definition)
78
80
  end
File without changes
File without changes
@@ -9,11 +9,13 @@ module ReciteCSV
9
9
  module Reader
10
10
  class Builder < ::Module
11
11
  def initialize(header_definition, &block)
12
+ super()
13
+
12
14
  definition = Header::Definition.dispatch(header_definition)
13
15
  @definition = definition
14
16
  @row_class = ::Class.new(Row::Base) do |klass|
15
17
  klass.include definition.build_column_methods_module
16
- klass.class_exec(&block) if block_given?
18
+ klass.class_exec(&block) if block
17
19
  end
18
20
  end
19
21
 
@@ -9,15 +9,14 @@ module ReciteCSV
9
9
 
10
10
  attr_reader :file, :file_options, :csv_options
11
11
 
12
- def initialize(file, options = {})
12
+ def initialize(file, file_options: {}, **options)
13
13
  @file = file
14
- @file_options = options.delete(:file_options) || {}
15
- @csv_options =
16
- (options || {}).merge(self.class::DEFAULT_CSV_OPTIONS)
14
+ @file_options = file_options
15
+ @csv_options = options.merge(self.class::DEFAULT_CSV_OPTIONS)
17
16
  end
18
17
 
19
18
  def each(&block)
20
- if block_given?
19
+ if block
21
20
  _each(&block)
22
21
  else
23
22
  self.to_enum
@@ -27,11 +26,7 @@ module ReciteCSV
27
26
  private
28
27
 
29
28
  def _each(&block)
30
- f = if self.file.is_a?(::String)
31
- ::File.open(self.file, *Array(self.file_options))
32
- else
33
- self.file
34
- end
29
+ f = _open
35
30
  begin
36
31
  _foreach(f, &block)
37
32
  ensure
@@ -39,10 +34,24 @@ module ReciteCSV
39
34
  end
40
35
  end
41
36
 
37
+ def _open
38
+ return self.file unless self.file.is_a?(::String)
39
+
40
+ args = Array(self.file_options)
41
+ if args.last.is_a?(::Hash)
42
+ args = args.dup
43
+ kw_args = args.pop
44
+ ::File.open(self.file, *args, **kw_args)
45
+ else
46
+ ::File.open(self.file, *args)
47
+ end
48
+ end
49
+
42
50
  def _foreach(file)
43
- ::CSV.new(file, self.csv_options).each do |raw_row|
51
+ ::CSV.new(file, **self.csv_options).each do |raw_row|
44
52
  yield self.class::Row.new(raw_row)
45
53
  end
54
+ self
46
55
  end
47
56
  end
48
57
  end
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReciteCSV
4
- VERSION = "1.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
data/lib/recite_csv.rb CHANGED
File without changes
data/recite_csv.gemspec CHANGED
@@ -10,24 +10,31 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Yuji Hanamura"]
11
11
  spec.email = ["yuji.developer@gmail.com"]
12
12
 
13
- spec.summary = "ReciteCSV helps to build a class for CSV reader."
14
- spec.description = "ReciteCSV helps to build a class for CSV reader."
13
+ spec.summary = "ReciteCSV assists to implement a class for CSV reader."
14
+ spec.description = <<~DESCRIPTION
15
+ ReciteCSV assists to implement a class for CSV reader. A reader class implemented by ReciteCSV iterate each row as PORO(Plain Old Ruby Object).
16
+ DESCRIPTION
15
17
  spec.homepage = "https://github.com/yujideveloper/recite_csv"
16
18
  spec.license = "MIT"
17
19
 
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata["changelog_uri"] = "https://github.com/yujideveloper/recite_csv/tree/main/CHANGELOG.md"
25
+
26
+ spec.metadata["rubygems_mfa_required"] = "true"
27
+
28
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`
30
+ .split("\x0")
31
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
20
32
  end
21
33
  spec.bindir = "exe"
22
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
35
  spec.require_paths = ["lib"]
24
36
 
25
- spec.required_ruby_version = ">= 2.4"
37
+ spec.required_ruby_version = ">= 3.0"
26
38
 
27
- spec.add_development_dependency "bundler", ">= 1.14"
28
- spec.add_development_dependency "pry", ">= 0.10.0"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rubocop", ">= 0.70.0"
32
- spec.add_development_dependency "rubocop-performance", ">= 1.3.0"
39
+ spec.add_dependency "csv"
33
40
  end
metadata CHANGED
@@ -1,110 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recite_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Hanamura
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2023-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: csv
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
20
- type: :development
19
+ version: '0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
27
- - !ruby/object:Gem::Dependency
28
- name: pry
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.10.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 0.10.0
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 0.70.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 0.70.0
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-performance
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 1.3.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 1.3.0
97
- description: ReciteCSV helps to build a class for CSV reader.
26
+ version: '0'
27
+ description: 'ReciteCSV assists to implement a class for CSV reader. A reader class
28
+ implemented by ReciteCSV iterate each row as PORO(Plain Old Ruby Object).
29
+
30
+ '
98
31
  email:
99
32
  - yuji.developer@gmail.com
100
33
  executables: []
101
34
  extensions: []
102
35
  extra_rdoc_files: []
103
36
  files:
37
+ - ".github/workflows/ruby.yml"
104
38
  - ".gitignore"
105
39
  - ".rspec"
106
40
  - ".rubocop.yml"
107
- - ".travis.yml"
108
41
  - CHANGELOG.md
109
42
  - Gemfile
110
43
  - LICENSE.txt
@@ -127,8 +60,13 @@ files:
127
60
  homepage: https://github.com/yujideveloper/recite_csv
128
61
  licenses:
129
62
  - MIT
130
- metadata: {}
131
- post_install_message:
63
+ metadata:
64
+ allowed_push_host: https://rubygems.org
65
+ homepage_uri: https://github.com/yujideveloper/recite_csv
66
+ source_code_uri: https://github.com/yujideveloper/recite_csv
67
+ changelog_uri: https://github.com/yujideveloper/recite_csv/tree/main/CHANGELOG.md
68
+ rubygems_mfa_required: 'true'
69
+ post_install_message:
132
70
  rdoc_options: []
133
71
  require_paths:
134
72
  - lib
@@ -136,15 +74,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
74
  requirements:
137
75
  - - ">="
138
76
  - !ruby/object:Gem::Version
139
- version: '2.4'
77
+ version: '3.0'
140
78
  required_rubygems_version: !ruby/object:Gem::Requirement
141
79
  requirements:
142
80
  - - ">="
143
81
  - !ruby/object:Gem::Version
144
82
  version: '0'
145
83
  requirements: []
146
- rubygems_version: 3.0.3
147
- signing_key:
84
+ rubygems_version: 3.5.3
85
+ signing_key:
148
86
  specification_version: 4
149
- summary: ReciteCSV helps to build a class for CSV reader.
87
+ summary: ReciteCSV assists to implement a class for CSV reader.
150
88
  test_files: []
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.6
5
- - 2.5.5
6
- - 2.6.3
7
- script:
8
- - bundle exec rake spec