acb 0.1.4 → 0.1.5

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: 9e3c77997c9ede024d51be4db16615292e55b6014482f31f7688d7a9762acb3d
4
- data.tar.gz: 88b9d179edbc54240d77b4625f1386f519284c8fa07a98b024e0be4dd1790c12
3
+ metadata.gz: 70841480cde94d2576aef69df161eb518f54408da050458d1078674aa02b2812
4
+ data.tar.gz: f10c1ee92974a7d97baa779e73bfc90cf7d4d30637587f7b6475c6565f1f1bb9
5
5
  SHA512:
6
- metadata.gz: 246cf3749a975639a8086ac4d7e96f3f3e1545e8ef3ade4caa853952e9310c89f90cf0b2bdff4da888814d836e344e3e89727a32d190b2c62457bc513aec68cb
7
- data.tar.gz: 7c3eda99c5133d3367fd4f19bf36b8d68a8788175074d3eedf88cdfad65df3c2c7a0a8dcf137c204bf4330f2c6f403b78a668062aae8983c75e6487b9521b03c
6
+ metadata.gz: aebf88bf60738a19583b02be227a150a787552c4381736a1ff9e99c0d56d0201ec8e452ea4bc8c8a971640e3b211b1c6fed141a8a3c915f617b64fea15e030f7
7
+ data.tar.gz: 65c6fad9dcd3f0c0d516c236ac53e0ffba381592ebf785ad1d3c0a540354232d0779775ff8458911c3ef58407e1c8fffa97c80836c3b2cb79e996848bcc2a6ea
data/.rubocop.yml CHANGED
@@ -5,6 +5,9 @@ AllCops:
5
5
  Exclude:
6
6
  - 'gemfiles/*'
7
7
 
8
+ Gemspec/DevelopmentDependencies:
9
+ EnforcedStyle: gemspec
10
+
8
11
  Gemspec/RequireMFA:
9
12
  Enabled: false
10
13
 
data/README.md CHANGED
@@ -60,7 +60,7 @@ class PostCsvBuilder
60
60
  end
61
61
  end
62
62
 
63
- PostCsvBuilder.new(user_id).content_string
63
+ PostCsvBuilder.new(user_id).to_csv
64
64
  ```
65
65
 
66
66
  ## Code of Conduct
data/acb.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/acb/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'acb'
7
+ spec.version = Acb::VERSION
8
+ spec.authors = ['Akito Hikasa']
9
+ spec.email = ['wetsand.wfs@gmail.com']
10
+
11
+ spec.summary = %(ActiveRecord CSV Builder)
12
+ spec.description = %(ActiveRecord CSV Builder)
13
+ spec.homepage = 'https://github.com/kakubin/acb'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = spec.homepage
20
+ # spec.metadata["changelog_uri"] = 'TODO: Put your gem's CHANGELOG.md URL here.'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_dependency 'activesupport', '>= 6.0.0'
34
+
35
+ spec.add_development_dependency 'activerecord', '>= 6.0.0'
36
+ spec.add_development_dependency 'appraisal'
37
+ spec.add_development_dependency 'sqlite3'
38
+ end
data/lib/acb/base.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Acb
4
+ module Base
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def columns
9
+ @columns ||= Columns.new
10
+ end
11
+
12
+ def add_column(name:, **options)
13
+ columns.push(name, **options)
14
+ end
15
+ end
16
+
17
+ def to_csv(**options)
18
+ CSV.generate(**options) do |csv|
19
+ csv << self.class.columns.header
20
+ data.each do |row|
21
+ csv << get_data_from(row)
22
+ end
23
+ end
24
+ end
25
+ alias content_string to_csv
26
+
27
+ private
28
+
29
+ def data
30
+ @data = @data.preload(relations) if respond_to?(:relations)
31
+ @data.find_each
32
+ end
33
+
34
+ def get_data_from(row)
35
+ self.class.columns.get_data(row)
36
+ end
37
+ end
38
+ end
data/lib/acb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Acb
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
data/lib/acb.rb CHANGED
@@ -7,34 +7,9 @@ require 'csv'
7
7
  module Acb
8
8
  extend ActiveSupport::Concern
9
9
 
10
+ autoload :Base, 'acb/base'
10
11
  autoload :Column, 'acb/column'
11
12
  autoload :Columns, 'acb/columns'
12
13
 
13
- class_methods do
14
- def columns
15
- @columns ||= Columns.new
16
- end
17
-
18
- def add_column(name:, **options)
19
- columns.push(name, **options)
20
- end
21
- end
22
-
23
- def data
24
- @data = @data.preload(relations) if respond_to?(:relations)
25
- @data.find_each
26
- end
27
-
28
- def get_data_from(row)
29
- self.class.columns.get_data(row)
30
- end
31
-
32
- def content_string(**options)
33
- CSV.generate(**options) do |csv|
34
- csv << self.class.columns.header
35
- data.each do |row|
36
- csv << get_data_from(row)
37
- end
38
- end
39
- end
14
+ include Base
40
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akito Hikasa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -82,10 +82,12 @@ files:
82
82
  - LICENSE
83
83
  - README.md
84
84
  - Rakefile
85
+ - acb.gemspec
85
86
  - gemfiles/rails_6.0_stable.gemfile
86
87
  - gemfiles/rails_6.1_stable.gemfile
87
88
  - gemfiles/rails_7.0_stable.gemfile
88
89
  - lib/acb.rb
90
+ - lib/acb/base.rb
89
91
  - lib/acb/column.rb
90
92
  - lib/acb/columns.rb
91
93
  - lib/acb/version.rb
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  requirements: []
114
- rubygems_version: 3.3.7
116
+ rubygems_version: 3.4.10
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: ActiveRecord CSV Builder