active_model_exporters 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sqlite3"
6
- gem "simplecov"
7
- gem "appraisal"
8
- gem "coveralls", require: false
9
- gem "rails", "~> 5.0.0"
10
-
11
- gemspec path: "../"
@@ -1,149 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- active_model_exporters (0.5.1)
5
- activemodel (>= 4.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actioncable (5.0.7)
11
- actionpack (= 5.0.7)
12
- nio4r (>= 1.2, < 3.0)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.7)
15
- actionpack (= 5.0.7)
16
- actionview (= 5.0.7)
17
- activejob (= 5.0.7)
18
- mail (~> 2.5, >= 2.5.4)
19
- rails-dom-testing (~> 2.0)
20
- actionpack (5.0.7)
21
- actionview (= 5.0.7)
22
- activesupport (= 5.0.7)
23
- rack (~> 2.0)
24
- rack-test (~> 0.6.3)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.7)
28
- activesupport (= 5.0.7)
29
- builder (~> 3.1)
30
- erubis (~> 2.7.0)
31
- rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.0.7)
34
- activesupport (= 5.0.7)
35
- globalid (>= 0.3.6)
36
- activemodel (5.0.7)
37
- activesupport (= 5.0.7)
38
- activerecord (5.0.7)
39
- activemodel (= 5.0.7)
40
- activesupport (= 5.0.7)
41
- arel (~> 7.0)
42
- activesupport (5.0.7)
43
- concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (>= 0.7, < 2)
45
- minitest (~> 5.1)
46
- tzinfo (~> 1.1)
47
- appraisal (2.2.0)
48
- bundler
49
- rake
50
- thor (>= 0.14.0)
51
- arel (7.1.4)
52
- builder (3.2.3)
53
- concurrent-ruby (1.0.5)
54
- coveralls (0.7.2)
55
- multi_json (~> 1.3)
56
- rest-client (= 1.6.7)
57
- simplecov (>= 0.7)
58
- term-ansicolor (= 1.2.2)
59
- thor (= 0.18.1)
60
- crass (1.0.4)
61
- docile (1.3.0)
62
- erubis (2.7.0)
63
- globalid (0.4.1)
64
- activesupport (>= 4.2.0)
65
- i18n (1.0.1)
66
- concurrent-ruby (~> 1.0)
67
- json (2.1.0)
68
- loofah (2.2.2)
69
- crass (~> 1.0.2)
70
- nokogiri (>= 1.5.9)
71
- mail (2.7.0)
72
- mini_mime (>= 0.1.1)
73
- method_source (0.9.0)
74
- mime-types (3.1)
75
- mime-types-data (~> 3.2015)
76
- mime-types-data (3.2016.0521)
77
- mini_mime (1.0.0)
78
- mini_portile2 (2.3.0)
79
- minitest (5.11.3)
80
- multi_json (1.13.1)
81
- nio4r (2.3.1)
82
- nokogiri (1.8.2)
83
- mini_portile2 (~> 2.3.0)
84
- rack (2.0.5)
85
- rack-test (0.6.3)
86
- rack (>= 1.0)
87
- rails (5.0.7)
88
- actioncable (= 5.0.7)
89
- actionmailer (= 5.0.7)
90
- actionpack (= 5.0.7)
91
- actionview (= 5.0.7)
92
- activejob (= 5.0.7)
93
- activemodel (= 5.0.7)
94
- activerecord (= 5.0.7)
95
- activesupport (= 5.0.7)
96
- bundler (>= 1.3.0)
97
- railties (= 5.0.7)
98
- sprockets-rails (>= 2.0.0)
99
- rails-dom-testing (2.0.3)
100
- activesupport (>= 4.2.0)
101
- nokogiri (>= 1.6)
102
- rails-html-sanitizer (1.0.4)
103
- loofah (~> 2.2, >= 2.2.2)
104
- railties (5.0.7)
105
- actionpack (= 5.0.7)
106
- activesupport (= 5.0.7)
107
- method_source
108
- rake (>= 0.8.7)
109
- thor (>= 0.18.1, < 2.0)
110
- rake (12.3.1)
111
- rest-client (1.6.7)
112
- mime-types (>= 1.16)
113
- simplecov (0.16.1)
114
- docile (~> 1.1)
115
- json (>= 1.8, < 3)
116
- simplecov-html (~> 0.10.0)
117
- simplecov-html (0.10.2)
118
- sprockets (3.7.1)
119
- concurrent-ruby (~> 1.0)
120
- rack (> 1, < 3)
121
- sprockets-rails (3.2.1)
122
- actionpack (>= 4.0)
123
- activesupport (>= 4.0)
124
- sprockets (>= 3.0.0)
125
- sqlite3 (1.3.13)
126
- term-ansicolor (1.2.2)
127
- tins (~> 0.8)
128
- thor (0.18.1)
129
- thread_safe (0.3.6)
130
- tins (0.13.2)
131
- tzinfo (1.2.5)
132
- thread_safe (~> 0.1)
133
- websocket-driver (0.6.5)
134
- websocket-extensions (>= 0.1.0)
135
- websocket-extensions (0.1.3)
136
-
137
- PLATFORMS
138
- ruby
139
-
140
- DEPENDENCIES
141
- active_model_exporters!
142
- appraisal
143
- coveralls
144
- rails (~> 5.0.0)
145
- simplecov
146
- sqlite3
147
-
148
- BUNDLED WITH
149
- 1.16.2
@@ -1,3 +0,0 @@
1
- class ARUserExporter < ActiveModel::Exporter
2
- attributes :first_name, :last_name
3
- end
@@ -1,18 +0,0 @@
1
- require 'active_record'
2
-
3
- ActiveRecord::Base.establish_connection(
4
- adapter: 'sqlite3',
5
- database: ':memory:'
6
- )
7
-
8
- ActiveRecord::Schema.define do
9
- create_table :ar_users, force: true do |t|
10
- t.string :first_name
11
- t.string :last_name
12
-
13
- t.timestamps null: false
14
- end
15
- end
16
-
17
- class ARUser < ActiveRecord::Base
18
- end
@@ -1,23 +0,0 @@
1
- class UserExporter < ActiveModel::Exporter
2
- attributes :first_name, :last_name, :full_name
3
-
4
- def full_name
5
- "#{object.first_name}-#{object.last_name}#{scope ? "-#{scope}" : ''}"
6
- end
7
- end
8
-
9
- class FancyUserExporter < ActiveModel::Exporter
10
- attributes :first_name, :last_name
11
- end
12
-
13
- class FilterUserExporter < ActiveModel::Exporter
14
- attributes :first_name, :last_name, :email
15
-
16
- def filter(attrs)
17
- if object.last_name == 'Bar1'
18
- attrs - [:last_name]
19
- else
20
- attrs
21
- end
22
- end
23
- end
@@ -1,20 +0,0 @@
1
- require 'i18n'
2
-
3
- class I18n::Backend::Simple
4
- def translations_store
5
- translations
6
- end
7
- end
8
-
9
- I18n.enforce_available_locales = false
10
-
11
- I18n.backend.translations_store[:en] = {
12
- activerecord: {
13
- attributes: {
14
- ar_user: {
15
- first_name: 'First',
16
- last_name: 'Last'
17
- }
18
- }
19
- }
20
- }
@@ -1,6 +0,0 @@
1
- class Model < OpenStruct
2
- include ActiveModel
3
- end
4
-
5
- class User < Model
6
- end
@@ -1,162 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActionController
4
- module Exportation::CSV
5
- class ImplicitExporterTest < ActionController::TestCase
6
- class TestsController < ActionController::Base
7
- def render_using_implicit_exporter
8
- render csv: [
9
- User.new(first_name: 'Foo1', last_name: 'Bar1'),
10
- User.new(first_name: 'Foo2', last_name: 'Bar2'),
11
- User.new(first_name: 'Foo3', last_name: 'Bar3')
12
- ]
13
- end
14
- end
15
-
16
- tests TestsController
17
-
18
- def test_render_using_implicit_exporter
19
- get :render_using_implicit_exporter
20
- assert_equal 'text/csv', @response.content_type
21
- assert_equal "first_name,last_name,full_name\n"\
22
- "Foo1,Bar1,Foo1-Bar1\n"\
23
- "Foo2,Bar2,Foo2-Bar2\n"\
24
- "Foo3,Bar3,Foo3-Bar3\n", @response.body
25
- end
26
- end
27
-
28
- class ExplicitExporterTest < ActionController::TestCase
29
- class TestsController < ActionController::Base
30
- def render_using_explicit_exporter
31
- render csv: [
32
- User.new(first_name: 'Foo1', last_name: 'Bar1')
33
- ], exporter: FancyUserExporter
34
- end
35
- end
36
-
37
- tests TestsController
38
-
39
- def test_render_using_explicit_exporter
40
- get :render_using_explicit_exporter
41
- assert_equal 'text/csv', @response.content_type
42
- assert_equal "first_name,last_name\n"\
43
- "Foo1,Bar1\n", @response.body
44
- end
45
- end
46
-
47
- class ImplicitExportationScopeTest < ActionController::TestCase
48
- class TestsController < ActionController::Base
49
- def render_using_implicit_exportation_scope
50
- render csv: [
51
- User.new(first_name: 'Foo1', last_name: 'Bar1')
52
- ]
53
- end
54
-
55
- private
56
-
57
- def current_user
58
- 'current_user'
59
- end
60
- end
61
-
62
- tests TestsController
63
-
64
- def test_render_using_implicit_exportation_scope
65
- get :render_using_implicit_exportation_scope
66
- assert_equal 'text/csv', @response.content_type
67
- assert_equal "first_name,last_name,full_name\n"\
68
- "Foo1,Bar1,Foo1-Bar1-current_user\n", @response.body
69
- end
70
- end
71
-
72
- class ExplicitExportationScopeTest < ActionController::TestCase
73
- class TestsController < ActionController::Base
74
- def render_using_explicit_exportation_scope
75
- render csv: [
76
- User.new(first_name: 'Foo1', last_name: 'Bar1')
77
- ], scope: current_admin
78
- end
79
-
80
- private
81
-
82
- def current_admin
83
- 'current_admin'
84
- end
85
- end
86
-
87
- tests TestsController
88
-
89
- def test_render_using_explicit_exportation_scope
90
- get :render_using_explicit_exportation_scope
91
- assert_equal 'text/csv', @response.content_type
92
- assert_equal "first_name,last_name,full_name\n"\
93
- "Foo1,Bar1,Foo1-Bar1-current_admin\n", @response.body
94
- end
95
- end
96
-
97
- class CallingExportationScopeTest < ActionController::TestCase
98
- class TestsController < ActionController::Base
99
- exportation_scope :current_admin
100
-
101
- def render_calling_exportation_scope
102
- render csv: [
103
- User.new(first_name: 'Foo1', last_name: 'Bar1')
104
- ]
105
- end
106
-
107
- private
108
-
109
- def current_admin
110
- 'current_admin'
111
- end
112
- end
113
-
114
- tests TestsController
115
-
116
- def test_render_calling_exportation_scope
117
- get :render_calling_exportation_scope
118
- assert_equal 'text/csv', @response.content_type
119
- assert_equal "first_name,last_name,full_name\n"\
120
- "Foo1,Bar1,Foo1-Bar1-current_admin\n", @response.body
121
- end
122
- end
123
-
124
- class UsingFilterAttributesTest < ActionController::TestCase
125
- class TestsController < ActionController::Base
126
- def render_using_filter_attributes
127
- render csv: [
128
- User.new(first_name: 'Foo1', last_name: 'Bar1', email: 'FooBar1'),
129
- User.new(first_name: 'Foo2', last_name: 'Bar2', email: 'FooBar2')
130
- ], exporter: FilterUserExporter
131
- end
132
- end
133
-
134
- tests TestsController
135
-
136
- def test_render_using_filter_attributes
137
- get :render_using_filter_attributes
138
- assert_equal 'text/csv', @response.content_type
139
- assert_equal "first_name,last_name,email\n"\
140
- "Foo1,,FooBar1\n"\
141
- "Foo2,Bar2,FooBar2\n", @response.body
142
- end
143
- end
144
-
145
- class ExporterSingleResourceTest < ActionController::TestCase
146
- class TestsController < ActionController::Base
147
- def render_single_resource
148
- render csv: User.new(first_name: 'Foo1', last_name: 'Bar1')
149
- end
150
- end
151
-
152
- tests TestsController
153
-
154
- def test_render_single_resource
155
- get :render_single_resource
156
- assert_equal 'text/csv', @response.content_type
157
- assert_equal "first_name,last_name,full_name\n"\
158
- "Foo1,Bar1,Foo1-Bar1\n", @response.body
159
- end
160
- end
161
- end
162
- end
@@ -1,162 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActionController
4
- module Exportation::XLS
5
- class ImplicitExporterTest < ActionController::TestCase
6
- class TestsController < ActionController::Base
7
- def render_using_implicit_exporter
8
- render xls: [
9
- User.new(first_name: 'Foo1', last_name: 'Bar1'),
10
- User.new(first_name: 'Foo2', last_name: 'Bar2'),
11
- User.new(first_name: 'Foo3', last_name: 'Bar3')
12
- ]
13
- end
14
- end
15
-
16
- tests TestsController
17
-
18
- def test_render_using_implicit_exporter
19
- get :render_using_implicit_exporter
20
- assert_equal 'application/vnd.ms-excel', @response.content_type
21
- assert_equal "first_name\tlast_name\tfull_name\n"\
22
- "Foo1\tBar1\tFoo1-Bar1\n"\
23
- "Foo2\tBar2\tFoo2-Bar2\n"\
24
- "Foo3\tBar3\tFoo3-Bar3\n", @response.body
25
- end
26
- end
27
-
28
- class ExplicitExporterTest < ActionController::TestCase
29
- class TestsController < ActionController::Base
30
- def render_using_explicit_exporter
31
- render xls: [
32
- User.new(first_name: 'Foo1', last_name: 'Bar1')
33
- ], exporter: FancyUserExporter
34
- end
35
- end
36
-
37
- tests TestsController
38
-
39
- def test_render_using_explicit_exporter
40
- get :render_using_explicit_exporter
41
- assert_equal 'application/vnd.ms-excel', @response.content_type
42
- assert_equal "first_name\tlast_name\n"\
43
- "Foo1\tBar1\n", @response.body
44
- end
45
- end
46
-
47
- class ImplicitExportationScopeTest < ActionController::TestCase
48
- class TestsController < ActionController::Base
49
- def render_using_implicit_exportation_scope
50
- render xls: [
51
- User.new(first_name: 'Foo1', last_name: 'Bar1')
52
- ]
53
- end
54
-
55
- private
56
-
57
- def current_user
58
- 'current_user'
59
- end
60
- end
61
-
62
- tests TestsController
63
-
64
- def test_render_using_implicit_exportation_scope
65
- get :render_using_implicit_exportation_scope
66
- assert_equal 'application/vnd.ms-excel', @response.content_type
67
- assert_equal "first_name\tlast_name\tfull_name\n"\
68
- "Foo1\tBar1\tFoo1-Bar1-current_user\n", @response.body
69
- end
70
- end
71
-
72
- class ExplicitExportationScopeTest < ActionController::TestCase
73
- class TestsController < ActionController::Base
74
- def render_using_explicit_exportation_scope
75
- render xls: [
76
- User.new(first_name: 'Foo1', last_name: 'Bar1')
77
- ], scope: current_admin
78
- end
79
-
80
- private
81
-
82
- def current_admin
83
- 'current_admin'
84
- end
85
- end
86
-
87
- tests TestsController
88
-
89
- def test_render_using_explicit_exportation_scope
90
- get :render_using_explicit_exportation_scope
91
- assert_equal 'application/vnd.ms-excel', @response.content_type
92
- assert_equal "first_name\tlast_name\tfull_name\n"\
93
- "Foo1\tBar1\tFoo1-Bar1-current_admin\n", @response.body
94
- end
95
- end
96
-
97
- class CallingExportationScopeTest < ActionController::TestCase
98
- class TestsController < ActionController::Base
99
- exportation_scope :current_admin
100
-
101
- def render_calling_exportation_scope
102
- render xls: [
103
- User.new(first_name: 'Foo1', last_name: 'Bar1')
104
- ]
105
- end
106
-
107
- private
108
-
109
- def current_admin
110
- 'current_admin'
111
- end
112
- end
113
-
114
- tests TestsController
115
-
116
- def test_render_calling_exportation_scope
117
- get :render_calling_exportation_scope
118
- assert_equal 'application/vnd.ms-excel', @response.content_type
119
- assert_equal "first_name\tlast_name\tfull_name\n"\
120
- "Foo1\tBar1\tFoo1-Bar1-current_admin\n", @response.body
121
- end
122
- end
123
-
124
- class UsingFilterAttributesTest < ActionController::TestCase
125
- class TestsController < ActionController::Base
126
- def render_using_filter_attributes
127
- render xls: [
128
- User.new(first_name: 'Foo1', last_name: 'Bar1', email: 'FooBar1'),
129
- User.new(first_name: 'Foo2', last_name: 'Bar2', email: 'FooBar2')
130
- ], exporter: FilterUserExporter
131
- end
132
- end
133
-
134
- tests TestsController
135
-
136
- def test_render_using_filter_attributes
137
- get :render_using_filter_attributes
138
- assert_equal 'application/vnd.ms-excel', @response.content_type
139
- assert_equal "first_name\tlast_name\temail\n"\
140
- "Foo1\t\tFooBar1\n"\
141
- "Foo2\tBar2\tFooBar2\n", @response.body
142
- end
143
- end
144
-
145
- class ExporterSingleResourceTest < ActionController::TestCase
146
- class TestsController < ActionController::Base
147
- def render_single_resource
148
- render xls: User.new(first_name: 'Foo1', last_name: 'Bar1')
149
- end
150
- end
151
-
152
- tests TestsController
153
-
154
- def test_render_single_resource
155
- get :render_single_resource
156
- assert_equal 'application/vnd.ms-excel', @response.content_type
157
- assert_equal "first_name\tlast_name\tfull_name\n"\
158
- "Foo1\tBar1\tFoo1-Bar1\n", @response.body
159
- end
160
- end
161
- end
162
- end