csvbuilder-exporter 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.tool-versions +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +83 -55
- data/README.md +43 -3
- data/gemfiles/Gemfile.7.0._gemfile +20 -0
- data/gemfiles/Gemfile.8.0._gemfile +20 -0
- data/lib/csvbuilder/exporter/concerns/export/base.rb +2 -1
- data/lib/csvbuilder/exporter/public/export/file.rb +2 -2
- data/lib/csvbuilder/exporter/public/export.rb +0 -2
- data/lib/csvbuilder/exporter/version.rb +1 -1
- data/lib/csvbuilder/exporter.rb +1 -1
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0db04d170e72816077bcbf51535b13ae0ddcda9b22288d6c89762de3e1d76b9b
|
4
|
+
data.tar.gz: a0f15a63bb1ff5ab9517ef571d7c4c7041939d7f4762b856ec668981ee7061b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 875fdf3f17d83012bf0a2d3b05f2176eff3112ebb533de968d132a065b2873da34c1cbe50c2300061d5fbdbd490108b5e3734262d3ca44a1b803bf75f11b8109
|
7
|
+
data.tar.gz: 8ebc6669f9bf4503d093904f88f1a410e9934551d4e4d5c5bc2299c1d40da61a2366f4740041e5aff81d8a6442979f56b36509d810bfc625f08dfa9778d37295
|
data/.rubocop.yml
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.4.2
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,77 +1,105 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
csvbuilder-exporter (0.1.
|
5
|
-
activemodel (>= 5.2
|
6
|
-
activesupport (>= 5.2
|
4
|
+
csvbuilder-exporter (0.1.1)
|
5
|
+
activemodel (>= 5.2)
|
6
|
+
activesupport (>= 5.2)
|
7
|
+
csv
|
7
8
|
csvbuilder-core
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activemodel (
|
13
|
-
activesupport (=
|
14
|
-
activesupport (
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
activemodel (8.0.1)
|
14
|
+
activesupport (= 8.0.1)
|
15
|
+
activesupport (8.0.1)
|
16
|
+
base64
|
17
|
+
benchmark (>= 0.3)
|
18
|
+
bigdecimal
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
20
|
+
connection_pool (>= 2.2.5)
|
21
|
+
drb
|
22
|
+
i18n (>= 1.6, < 2)
|
23
|
+
logger (>= 1.4.2)
|
24
|
+
minitest (>= 5.1)
|
25
|
+
securerandom (>= 0.3)
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
27
|
+
uri (>= 0.13.1)
|
19
28
|
ast (2.4.2)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
29
|
+
base64 (0.2.0)
|
30
|
+
benchmark (0.4.0)
|
31
|
+
bigdecimal (3.1.9)
|
32
|
+
concurrent-ruby (1.3.5)
|
33
|
+
connection_pool (2.5.0)
|
34
|
+
csv (3.3.2)
|
35
|
+
csvbuilder-core (0.1.4)
|
36
|
+
activesupport (>= 5.2)
|
37
|
+
csv
|
38
|
+
diff-lcs (1.6.0)
|
39
|
+
drb (2.2.1)
|
40
|
+
i18n (1.14.7)
|
25
41
|
concurrent-ruby (~> 1.0)
|
26
|
-
json (2.
|
27
|
-
|
28
|
-
|
29
|
-
|
42
|
+
json (2.10.1)
|
43
|
+
language_server-protocol (3.17.0.4)
|
44
|
+
lint_roller (1.1.0)
|
45
|
+
logger (1.6.6)
|
46
|
+
minitest (5.25.4)
|
47
|
+
parallel (1.26.3)
|
48
|
+
parser (3.3.7.1)
|
30
49
|
ast (~> 2.4.1)
|
50
|
+
racc
|
51
|
+
racc (1.8.1)
|
31
52
|
rainbow (3.1.1)
|
32
|
-
rake (13.
|
33
|
-
regexp_parser (2.
|
34
|
-
|
35
|
-
|
36
|
-
rspec-
|
37
|
-
rspec-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
rspec-expectations (3.12.1)
|
53
|
+
rake (13.2.1)
|
54
|
+
regexp_parser (2.10.0)
|
55
|
+
rspec (3.13.0)
|
56
|
+
rspec-core (~> 3.13.0)
|
57
|
+
rspec-expectations (~> 3.13.0)
|
58
|
+
rspec-mocks (~> 3.13.0)
|
59
|
+
rspec-core (3.13.3)
|
60
|
+
rspec-support (~> 3.13.0)
|
61
|
+
rspec-expectations (3.13.3)
|
42
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-mocks (3.
|
63
|
+
rspec-support (~> 3.13.0)
|
64
|
+
rspec-mocks (3.13.2)
|
45
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.
|
47
|
-
rspec-support (3.
|
48
|
-
rubocop (1.
|
66
|
+
rspec-support (~> 3.13.0)
|
67
|
+
rspec-support (3.13.2)
|
68
|
+
rubocop (1.72.2)
|
49
69
|
json (~> 2.3)
|
70
|
+
language_server-protocol (~> 3.17.0.2)
|
71
|
+
lint_roller (~> 1.1.0)
|
50
72
|
parallel (~> 1.10)
|
51
|
-
parser (>= 3.
|
73
|
+
parser (>= 3.3.0.2)
|
52
74
|
rainbow (>= 2.2.2, < 4.0)
|
53
|
-
regexp_parser (>=
|
54
|
-
|
55
|
-
rubocop-ast (>= 1.23.0, < 2.0)
|
75
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
76
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
56
77
|
ruby-progressbar (~> 1.7)
|
57
|
-
unicode-display_width (>=
|
58
|
-
rubocop-ast (1.
|
59
|
-
parser (>= 3.
|
60
|
-
rubocop-performance (1.
|
61
|
-
|
62
|
-
rubocop
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
rubocop (
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
78
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
79
|
+
rubocop-ast (1.38.1)
|
80
|
+
parser (>= 3.3.1.0)
|
81
|
+
rubocop-performance (1.24.0)
|
82
|
+
lint_roller (~> 1.1)
|
83
|
+
rubocop (>= 1.72.1, < 2.0)
|
84
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
85
|
+
rubocop-rake (0.7.1)
|
86
|
+
lint_roller (~> 1.1)
|
87
|
+
rubocop (>= 1.72.1)
|
88
|
+
rubocop-rspec (3.5.0)
|
89
|
+
lint_roller (~> 1.1)
|
90
|
+
rubocop (~> 1.72, >= 1.72.1)
|
91
|
+
ruby-progressbar (1.13.0)
|
92
|
+
securerandom (0.4.1)
|
93
|
+
tzinfo (2.0.6)
|
94
|
+
concurrent-ruby (~> 1.0)
|
95
|
+
unicode-display_width (3.1.4)
|
96
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
97
|
+
unicode-emoji (4.0.4)
|
98
|
+
uri (1.0.2)
|
72
99
|
|
73
100
|
PLATFORMS
|
74
|
-
arm64-darwin-
|
101
|
+
arm64-darwin-24
|
102
|
+
ruby
|
75
103
|
|
76
104
|
DEPENDENCIES
|
77
105
|
csvbuilder-exporter!
|
@@ -83,4 +111,4 @@ DEPENDENCIES
|
|
83
111
|
rubocop-rspec
|
84
112
|
|
85
113
|
BUNDLED WITH
|
86
|
-
2.
|
114
|
+
2.6.2
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Csvbuilder::Exporter
|
2
2
|
|
3
|
-
|
3
|
+
[Csvbuilder::Exporter](https://github.com/joel/csvbuilder-exporter) is part of the [csvbuilder-collection](https://github.com/joel/csvbuilder)
|
4
4
|
|
5
|
-
|
5
|
+
The exporter contains the implementation for exporting a collection of objects as a CSV file.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
+
The gem doesn't need [csvbuilder-collection](https://github.com/joel/csvbuilder) and can be installed alone.
|
9
10
|
Install the gem and add to the application's Gemfile by executing:
|
10
11
|
|
11
12
|
$ bundle add csvbuilder-exporter
|
@@ -16,7 +17,46 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
17
|
|
17
18
|
## Usage
|
18
19
|
|
19
|
-
|
20
|
+
Exporting is straightforward; a `CsvRowModel` is needed to map the Ruby Object. Often an `ActiveRecord` Object. A `CsvExportModel` is required to carry the specifics of exporting.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
class UserCsvRowModel
|
24
|
+
include Csvbuilder::Model
|
25
|
+
|
26
|
+
column :first_name
|
27
|
+
column :last_name
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
NOTE: If shipping is the only need, both classes can be merged.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class UserCsvExportModel
|
35
|
+
include Csvbuilder::Model
|
36
|
+
include Csvbuilder::Export
|
37
|
+
|
38
|
+
column :first_name
|
39
|
+
column :last_name
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
You need to provide both object collection and exporter class as follow:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
collection = User.all
|
47
|
+
|
48
|
+
exporter = Csvbuilder::Export::File.new(UserCsvExportModel, context = {})
|
49
|
+
|
50
|
+
exporter.headers
|
51
|
+
# => "First Name", "Last Name"
|
52
|
+
|
53
|
+
exporter.generate do |csv|
|
54
|
+
collection.each do |user|
|
55
|
+
csv.append_model(user, another_context: true)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# => "First Name,Last Name\nJohn,Doe\n"
|
59
|
+
```
|
20
60
|
|
21
61
|
## Development
|
22
62
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Runtime dependencies
|
6
|
+
gem "activemodel", "~> 7.0"
|
7
|
+
gem "activerecord", "~> 7.0"
|
8
|
+
gem "activesupport", "~> 7.0"
|
9
|
+
|
10
|
+
# Libraries dependencies
|
11
|
+
gem "csvbuilder-core"
|
12
|
+
gem "csv"
|
13
|
+
|
14
|
+
# Development dependencies
|
15
|
+
gem "rake"
|
16
|
+
gem "rspec"
|
17
|
+
gem "rubocop"
|
18
|
+
gem "rubocop-performance"
|
19
|
+
gem "rubocop-rake"
|
20
|
+
gem "rubocop-rspec"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Runtime dependencies
|
6
|
+
gem "activemodel", "~> 8.0"
|
7
|
+
gem "activerecord", "~> 8.0"
|
8
|
+
gem "activesupport", "~> 8.0"
|
9
|
+
|
10
|
+
# Libraries dependencies
|
11
|
+
gem "csvbuilder-core"
|
12
|
+
gem "csv"
|
13
|
+
|
14
|
+
# Development dependencies
|
15
|
+
gem "rake"
|
16
|
+
gem "rspec"
|
17
|
+
gem "rubocop"
|
18
|
+
gem "rubocop-performance"
|
19
|
+
gem "rubocop-rake"
|
20
|
+
gem "rubocop-rspec"
|
@@ -7,13 +7,14 @@ module Csvbuilder
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
attr_reader :source_model
|
10
|
-
# validates :source_model, presence: true
|
11
10
|
end
|
12
11
|
|
13
12
|
# @param [Model] source_model object to export to CSV
|
14
13
|
# @param [Hash] context
|
15
14
|
def initialize(source_model = nil, context = {})
|
16
15
|
@source_model = source_model
|
16
|
+
raise ArgumentError, "source_model must be provided" unless source_model
|
17
|
+
|
17
18
|
super(context: context)
|
18
19
|
end
|
19
20
|
|
data/lib/csvbuilder/exporter.rb
CHANGED
@@ -4,10 +4,10 @@ require "csvbuilder/exporter/version"
|
|
4
4
|
|
5
5
|
require "csv"
|
6
6
|
require "ostruct"
|
7
|
-
# require "active_model"
|
8
7
|
|
9
8
|
require "active_support"
|
10
9
|
require "active_support/dependencies/autoload"
|
10
|
+
|
11
11
|
require "active_support/core_ext/object"
|
12
12
|
require "active_support/core_ext/string"
|
13
13
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csvbuilder-exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Azemar
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activemodel
|
@@ -17,9 +16,6 @@ dependencies:
|
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '5.2'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '8'
|
23
19
|
type: :runtime
|
24
20
|
prerelease: false
|
25
21
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +23,6 @@ dependencies:
|
|
27
23
|
- - ">="
|
28
24
|
- !ruby/object:Gem::Version
|
29
25
|
version: '5.2'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '8'
|
33
26
|
- !ruby/object:Gem::Dependency
|
34
27
|
name: activesupport
|
35
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,9 +30,6 @@ dependencies:
|
|
37
30
|
- - ">="
|
38
31
|
- !ruby/object:Gem::Version
|
39
32
|
version: '5.2'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '8'
|
43
33
|
type: :runtime
|
44
34
|
prerelease: false
|
45
35
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +37,20 @@ dependencies:
|
|
47
37
|
- - ">="
|
48
38
|
- !ruby/object:Gem::Version
|
49
39
|
version: '5.2'
|
50
|
-
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: csv
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
53
54
|
- !ruby/object:Gem::Dependency
|
54
55
|
name: csvbuilder-core
|
55
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- ".rspec"
|
75
76
|
- ".rubocop.yml"
|
76
77
|
- ".rubocop_todo.yml"
|
78
|
+
- ".tool-versions"
|
77
79
|
- CHANGELOG.md
|
78
80
|
- CODE_OF_CONDUCT.md
|
79
81
|
- Gemfile
|
@@ -81,6 +83,8 @@ files:
|
|
81
83
|
- LICENSE.txt
|
82
84
|
- README.md
|
83
85
|
- Rakefile
|
86
|
+
- gemfiles/Gemfile.7.0._gemfile
|
87
|
+
- gemfiles/Gemfile.8.0._gemfile
|
84
88
|
- lib/csvbuilder/exporter.rb
|
85
89
|
- lib/csvbuilder/exporter/concerns/export/attributes.rb
|
86
90
|
- lib/csvbuilder/exporter/concerns/export/base.rb
|
@@ -89,15 +93,14 @@ files:
|
|
89
93
|
- lib/csvbuilder/exporter/public/export/file.rb
|
90
94
|
- lib/csvbuilder/exporter/version.rb
|
91
95
|
- sig/csvbuilder/exporter.rbs
|
92
|
-
homepage: https://github.com/joel/csvbuilder-
|
96
|
+
homepage: https://github.com/joel/csvbuilder-exporter
|
93
97
|
licenses:
|
94
98
|
- MIT
|
95
99
|
metadata:
|
96
|
-
homepage_uri: https://github.com/joel/csvbuilder-
|
97
|
-
source_code_uri: https://github.com/joel/csvbuilder-
|
98
|
-
changelog_uri: https://github.com/joel/csvbuilder-
|
100
|
+
homepage_uri: https://github.com/joel/csvbuilder-exporter
|
101
|
+
source_code_uri: https://github.com/joel/csvbuilder-exporter
|
102
|
+
changelog_uri: https://github.com/joel/csvbuilder-exporter/blob/main/CHANGELOG.md
|
99
103
|
rubygems_mfa_required: 'true'
|
100
|
-
post_install_message:
|
101
104
|
rdoc_options: []
|
102
105
|
require_paths:
|
103
106
|
- lib
|
@@ -105,15 +108,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
108
|
requirements:
|
106
109
|
- - ">="
|
107
110
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
111
|
+
version: '3.4'
|
109
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
113
|
requirements:
|
111
114
|
- - ">="
|
112
115
|
- !ruby/object:Gem::Version
|
113
116
|
version: '0'
|
114
117
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
116
|
-
signing_key:
|
118
|
+
rubygems_version: 3.6.2
|
117
119
|
specification_version: 4
|
118
120
|
summary: Csvbuilder Exporter contain the components to handle CSV exporting
|
119
121
|
test_files: []
|