active_record_to_xls 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/Gemfile.lock +39 -0
- data/active_record_to_xls-1.0.0.gem +0 -0
- data/active_record_to_xls.gemspec +23 -13
- data/lib/active_record_to_xls.rb +1 -1
- data/spec/active_record_to_xls_spec.rb +108 -0
- data/spec/spec_helper.rb +7 -0
- metadata +41 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a28637e0fbd89376daf42e567bc69ca06982871f3430026ee84babfbc0f1815
|
4
|
+
data.tar.gz: ee9f6f3ed47b367ee1170ef08afe07f49aac9a7eb3058f71cf5fa454eb190b28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02186a0bfe458945c08fd63654793e3f847efada1c5ff4e0bd3b7366a9f0321f1c3fa556d08e0e74a880010638c05969d1f36733cbb3726cc4e68d6c58cb39cf'
|
7
|
+
data.tar.gz: 5efeedb9a27213c33e84fdba6dc902804c907e15f131b3f1f2b7924582538cf17e2fbb8d7bc2749af130b4ce4e9187a5b618be7d38f6e6fb0a6706a841e17b97
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_record_to_xls (1.0.1)
|
5
|
+
spreadsheet (~> 0.8.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
rake (12.3.1)
|
12
|
+
rspec (3.7.0)
|
13
|
+
rspec-core (~> 3.7.0)
|
14
|
+
rspec-expectations (~> 3.7.0)
|
15
|
+
rspec-mocks (~> 3.7.0)
|
16
|
+
rspec-core (3.7.1)
|
17
|
+
rspec-support (~> 3.7.0)
|
18
|
+
rspec-expectations (3.7.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.7.0)
|
21
|
+
rspec-mocks (3.7.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.7.0)
|
24
|
+
rspec-support (3.7.1)
|
25
|
+
ruby-ole (1.2.12.1)
|
26
|
+
spreadsheet (0.8.9)
|
27
|
+
ruby-ole (>= 1.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
active_record_to_xls!
|
34
|
+
bundler (~> 1.3)
|
35
|
+
rake
|
36
|
+
rspec (~> 3.7, >= 3.7.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.16.5
|
Binary file
|
@@ -1,20 +1,30 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
2
4
|
|
3
|
-
|
5
|
+
# Maintain your gem's version:
|
6
|
+
require "active_record_to_xls/version"
|
4
7
|
|
5
8
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.
|
9
|
-
spec.email
|
10
|
-
spec.
|
11
|
-
spec.summary
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
|
15
|
-
spec.
|
9
|
+
spec.name = 'active_record_to_xls'
|
10
|
+
spec.version = ActiveRecordToXls::VERSION
|
11
|
+
spec.authors = ["Gordon B. Isnor"]
|
12
|
+
spec.email = ["info@isnorcreative.com"]
|
13
|
+
spec.description = "This simple plugin gives you the ability to get XLS for a collection of ActiveRecord models."
|
14
|
+
spec.summary = "Export Rails ActiveRecord data to Excel XLS data"
|
15
|
+
spec.homepage = "http://github.com/gordonbisnor/active_record_to_xls"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
16
23
|
spec.add_runtime_dependency 'spreadsheet', '~> 0.8.5'
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
17
26
|
spec.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
|
18
|
-
|
27
|
+
|
19
28
|
spec.required_rubygems_version = ">= 1.3.4"
|
20
29
|
end
|
30
|
+
|
data/lib/active_record_to_xls.rb
CHANGED
@@ -22,7 +22,7 @@ class ActiveRecordToXls
|
|
22
22
|
elsif !target.nil?
|
23
23
|
if target.first.is_a? Hash
|
24
24
|
target.first.keys.map(&:to_sym) - Array(options[:except]).map(&:to_sym)
|
25
|
-
|
25
|
+
elsif target.first && target.first.respond_to?('attributes')
|
26
26
|
target.first.attributes.keys.map(&:to_sym) - Array(options[:except]).map(&:to_sym)
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe ActiveRecordToXls do
|
5
|
+
|
6
|
+
let(:foo) {
|
7
|
+
OpenStruct.new({
|
8
|
+
title: "foo", description: "bar",
|
9
|
+
attributes: {
|
10
|
+
title: "foo", description: "bar"
|
11
|
+
}
|
12
|
+
})
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:baz) {
|
16
|
+
OpenStruct.new({
|
17
|
+
title: "baz", description: "qux",
|
18
|
+
attributes: {
|
19
|
+
title: "baz", description: "qux"
|
20
|
+
}
|
21
|
+
})
|
22
|
+
}
|
23
|
+
|
24
|
+
let(:items) { [foo, baz] }
|
25
|
+
|
26
|
+
describe 'being called' do
|
27
|
+
|
28
|
+
let(:subject) { ActiveRecordToXls.call(items) }
|
29
|
+
|
30
|
+
it 'returns a string' do
|
31
|
+
expect(subject).to be_kind_of(String)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'contains expected string data' do
|
35
|
+
expect(subject).to match(/foo/)
|
36
|
+
expect(subject).to match(/bar/)
|
37
|
+
expect(subject).to match(/baz/)
|
38
|
+
expect(subject).to match(/qux/)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with header columns' do
|
44
|
+
|
45
|
+
let(:subject) { ActiveRecordToXls.call( items, header_columns: ["GreatTitle","GreatDescription"] ) }
|
46
|
+
|
47
|
+
it 'returns a string' do
|
48
|
+
expect(subject).to be_kind_of(String)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'with omitted header' do
|
53
|
+
|
54
|
+
let(:subject) { ActiveRecordToXls.call( items, header: false ) }
|
55
|
+
|
56
|
+
it 'returns a string' do
|
57
|
+
expect(subject).to be_kind_of(String)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with prepend' do
|
62
|
+
let(:subject) { ActiveRecordToXls.call( items, prepend: [["my title","my desc"]] ) }
|
63
|
+
|
64
|
+
it 'contains expected string data' do
|
65
|
+
expect(subject).to match(/my title/)
|
66
|
+
expect(subject).to match(/my desc/)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with append' do
|
72
|
+
let(:subject) { ActiveRecordToXls.call( items, append: [["my footer title","my footer desc"]] ) }
|
73
|
+
|
74
|
+
it 'contains expected string data' do
|
75
|
+
expect(subject).to match(/my footer title/)
|
76
|
+
expect(subject).to match(/my footer desc/)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with only' do
|
82
|
+
|
83
|
+
let(:subject) { ActiveRecordToXls.call( items, only: [:title] ) }
|
84
|
+
|
85
|
+
it 'contains expected string data' do
|
86
|
+
expect(subject).to match(/foo/)
|
87
|
+
expect(subject).not_to match(/bar/)
|
88
|
+
expect(subject).to match(/baz/)
|
89
|
+
expect(subject).not_to match(/qux/)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
context 'with except' do
|
96
|
+
|
97
|
+
let(:subject) { ActiveRecordToXls.call( items, except: [:title] ) }
|
98
|
+
|
99
|
+
it 'contains expected string data' do
|
100
|
+
expect(subject).not_to match(/foo/)
|
101
|
+
expect(subject).to match(/bar/)
|
102
|
+
expect(subject).not_to match(/baz/)
|
103
|
+
expect(subject).to match(/qux/)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_to_xls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gordon B. Isnor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spreadsheet
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.8.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rspec
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,19 +74,26 @@ dependencies:
|
|
46
74
|
version: 3.7.0
|
47
75
|
description: This simple plugin gives you the ability to get XLS for a collection
|
48
76
|
of ActiveRecord models.
|
49
|
-
email:
|
77
|
+
email:
|
78
|
+
- info@isnorcreative.com
|
50
79
|
executables: []
|
51
80
|
extensions: []
|
52
81
|
extra_rdoc_files: []
|
53
82
|
files:
|
83
|
+
- ".gitignore"
|
84
|
+
- ".rspec"
|
54
85
|
- Gemfile
|
86
|
+
- Gemfile.lock
|
55
87
|
- MIT-LICENSE
|
56
88
|
- README.md
|
57
89
|
- Rakefile
|
58
90
|
- VERSION
|
91
|
+
- active_record_to_xls-1.0.0.gem
|
59
92
|
- active_record_to_xls.gemspec
|
60
93
|
- init.rb
|
61
94
|
- lib/active_record_to_xls.rb
|
95
|
+
- spec/active_record_to_xls_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
62
97
|
homepage: http://github.com/gordonbisnor/active_record_to_xls
|
63
98
|
licenses:
|
64
99
|
- MIT
|
@@ -83,4 +118,6 @@ rubygems_version: 2.7.6
|
|
83
118
|
signing_key:
|
84
119
|
specification_version: 4
|
85
120
|
summary: Export Rails ActiveRecord data to Excel XLS data
|
86
|
-
test_files:
|
121
|
+
test_files:
|
122
|
+
- spec/active_record_to_xls_spec.rb
|
123
|
+
- spec/spec_helper.rb
|