acb 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
  SHA256:
3
- metadata.gz: d03c6b8de9a823ee7da1d09ba0a8c919729de19c2386ebe0f8d3d7ac0f8b290d
4
- data.tar.gz: 7e4fad7a51f42efe2720a4a6b8388fc495d08bf0c58694600b0e343f967b89df
3
+ metadata.gz: 78012876872f6c6493c9613eb2a64fe4ad023e9a25f1f9afc43077f320e74cff
4
+ data.tar.gz: e806a9b3d9d2a3c39d9145bd8a44edd8e81e19ecc59d5bd53c041123e6e5ed82
5
5
  SHA512:
6
- metadata.gz: 13c6dfe5f3c3ef2343e5f25e61f8e0f14f268fc568124cfa00d661fde77a2f586826319fe1f2d7a24ebca9926b130d7a164d87d5b28f8a2be0f921d78c03c9bc
7
- data.tar.gz: 80e9ad4bfd5e64252950251c0415e78130ebc74a22678d2d2cd164a94bff360e5dabde9c69cfbac14b1499a39787e794143c9bdb7edc148b9a3f2f025d4de90b
6
+ metadata.gz: b692b3210b15b704c75039571cd079459d55e133894a117a8021e3c24a7b6186272540bad6d540f4ebf28a3e59317a84ef3bd193c2e67357ebee07e41eef3b69
7
+ data.tar.gz: 8e8f579b6776aefeb3cf643b058943356a83091e379c2f926164debff5c576f8fb4abb693ac39f78bad0f952639b33a9bf145eaecc6d9645522bdb2bdb9b69ce
data/.rubocop.yml CHANGED
@@ -1,5 +1,12 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+ Exclude:
6
+ - 'gemfiles/*'
7
+
8
+ Gemspec/RequireMFA:
9
+ Enabled: false
3
10
 
4
11
  Style/Documentation:
5
12
  Enabled: false
@@ -14,3 +21,5 @@ Style/StringLiteralsInInterpolation:
14
21
 
15
22
  Layout/LineLength:
16
23
  Max: 120
24
+ Exclude:
25
+ - 'spec/support/seed.rb'
data/Appraisals ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-6.0-stable' do
4
+ gem 'activerecord', '~> 6.0.0'
5
+ gem 'activesupport', '~> 6.0.0'
6
+ end
7
+
8
+ appraise 'rails-6.1-stable' do
9
+ gem 'activerecord', '~> 6.1.0'
10
+ gem 'activesupport', '~> 6.1.0'
11
+ end
12
+
13
+ appraise 'rails-7.0-stable' do
14
+ gem 'activerecord', '~> 7.0.0'
15
+ gem 'activesupport', '~> 7.0.0'
16
+ end
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Acb
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/acb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Acb is a gem for formatting and outputting csv data from ActiveRecord data
6
4
 
7
5
  ## Installation
8
6
 
@@ -10,24 +8,61 @@ Install the gem and add to the application's Gemfile by executing:
10
8
 
11
9
  $ bundle add acb
12
10
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
-
15
- $ gem install acb
16
11
 
17
12
  ## Usage
18
13
 
19
- TODO: Write usage instructions here
20
14
 
21
- ## Development
15
+ ```ruby
16
+ ActiveRecord::Schema.define do
17
+ create_table :users, force: true do |t|
18
+ t.string :name
19
+ end
20
+
21
+ create_table :posts, force: true do |t|
22
+ t.integer :user_id
23
+ t.timestamps
24
+ end
25
+
26
+ create_table :comments, force: true do |t|
27
+ t.integer :post_id
28
+ t.string :content
29
+ end
30
+ end
31
+
32
+ class User < ActiveRecord::Base
33
+ has_many :posts
34
+ end
35
+
36
+ class Post < ActiveRecord::Base
37
+ belongs_to :user
38
+ has_many :comments
39
+ end
40
+
41
+ class Comment < ActiveRecord::Base
42
+ belongs_to :post
43
+ end
44
+
45
+ class PostCsvBuilder
46
+ include Acb
22
47
 
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
48
+ add_column name: 'id'
49
+ add_column name: 'User Name', index: 'user.name'
50
+ add_column name: 'created_at', format: '%Y-%m-%d'
51
+ add_column name: 'Comment Amount', index: 'comments.size'
52
+ add_column name: 'First Comment', index: ->(post) { post.comments.first&.content }
24
53
 
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+ def initialize(user_id)
55
+ @data = Post.where(user_id: user_id)
56
+ end
26
57
 
27
- ## Contributing
58
+ def relations
59
+ [:user, :comments]
60
+ end
61
+ end
28
62
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/acb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/acb/blob/main/CODE_OF_CONDUCT.md).
63
+ PostCsvBuilder.new(user_id).content_string
64
+ ```
30
65
 
31
66
  ## Code of Conduct
32
67
 
33
- Everyone interacting in the Acb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/acb/blob/main/CODE_OF_CONDUCT.md).
68
+ Everyone interacting in the Acb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kakubin/acb/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rubocop", "~> 1.21"
8
+ gem "activerecord", "~> 6.0.0"
9
+ gem "activesupport", "~> 6.0.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rubocop", "~> 1.21"
8
+ gem "activerecord", "~> 6.1.0"
9
+ gem "activesupport", "~> 6.1.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rubocop", "~> 1.21"
8
+ gem "activerecord", "~> 7.0.0"
9
+ gem "activesupport", "~> 7.0.0"
10
+
11
+ gemspec path: "../"
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.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/acb.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative 'acb/version'
4
4
  require 'active_support'
5
5
  require 'forwardable'
6
+ require 'csv'
6
7
 
7
8
  module Acb
8
9
  extend ActiveSupport::Concern
@@ -28,7 +29,7 @@ module Acb
28
29
  end
29
30
 
30
31
  def get_data(row)
31
- @columns.map { _1.digest(row) }
32
+ @columns.map { |column| column.digest(row) }
32
33
  end
33
34
  end
34
35
 
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akito Hikasa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-23 00:00:00.000000000 Z
11
+ date: 2022-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,9 +16,51 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 6.0.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 6.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: appraisal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
66
  - - ">="
@@ -33,12 +75,16 @@ extra_rdoc_files: []
33
75
  files:
34
76
  - ".rspec"
35
77
  - ".rubocop.yml"
78
+ - Appraisals
36
79
  - CHANGELOG.md
37
80
  - CODE_OF_CONDUCT.md
38
81
  - Gemfile
39
82
  - LICENSE
40
83
  - README.md
41
84
  - Rakefile
85
+ - gemfiles/rails_6.0_stable.gemfile
86
+ - gemfiles/rails_6.1_stable.gemfile
87
+ - gemfiles/rails_7.0_stable.gemfile
42
88
  - lib/acb.rb
43
89
  - lib/acb/version.rb
44
90
  - sig/acb.rbs