resque-reports 0.4.7 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d8fe72c2d6787d6712d449a39b5f22e0fe5aacae
4
- data.tar.gz: 3096c843f018c23fe0e685b80dddd3ece87cb3a2
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODMyYmYxYjk1NDJmZjkxOGMzZTI1Y2YwMGZkM2M3MWM0YjRkNDRiMw==
5
+ data.tar.gz: !binary |-
6
+ NDI0MTk3YjVmYjkwNGE2NzFjOWVlNTAxNTA2NmFlYTJjNjEwMDdmNw==
5
7
  SHA512:
6
- metadata.gz: 619a5b219764940f8b4a9b94ce2ca25a35ef68346c63fef9bba329e7a92b879d41da8145facec25790cb6652df70cd3ece1cfdc480f347b8d73588ad4db7c516
7
- data.tar.gz: 071e25a470e450834ee80d7c8916ee54bc403f0fe19b2b42d021180b6eb81ab5da33a8e3bd5b8b0180f9e237e11b3797885b4bcf0d17171e7749cb4cfa9276c4
8
+ metadata.gz: !binary |-
9
+ MDA5YjYxNTI3ODgwZmVkNDM5NjY1YmM3ZWJjYmFhMjAzYTg3OGRjZjZhNDMx
10
+ Y2M1ZWUyOTViZTQyYWVkMThiODJiOWRlZDYxMzE0NDBmYWI1NGI4MTBiZGE1
11
+ MTU2MzcwM2E4Y2ViNDZjMjliMmI1ZjgxZmY3OGNhZjJiY2UxNjI=
12
+ data.tar.gz: !binary |-
13
+ NDhiZGUxNDFjOTg2NzZlNGJlODI2MDA5OTI3ODBiMTQ5YjlkNGQwNzgwZjM0
14
+ OTZmY2MyMGU2ZjY4Mjk4MDg4Nzk3YTcyMzcxNzBkYzRmYzZhMDFhZjNkNjYz
15
+ ZDc1YTdmYjAzN2M3MTYwOTMxNGE5YWQyMjIxYmIxYmRjMjE3NjM=
@@ -23,25 +23,7 @@ module Resque
23
23
  end
24
24
 
25
25
  def hash(*args)
26
- Digest::SHA1.hexdigest(obj_to_string(args))
27
- end
28
-
29
- def obj_to_string(obj)
30
- case obj
31
- when Hash
32
- s = []
33
- obj.keys.sort.each do |k|
34
- s << obj_to_string(k)
35
- s << obj_to_string(obj[k])
36
- end
37
- s.to_s
38
- when Array
39
- s = []
40
- obj.each { |a| s << obj_to_string(a) }
41
- s.to_s
42
- else
43
- obj.to_s
44
- end
26
+ Digest::SHA1.hexdigest(args.to_json)
45
27
  end
46
28
  end
47
29
  end
@@ -51,7 +51,11 @@ module Resque
51
51
  return if @header_collecting
52
52
 
53
53
  if column_value.is_a? Symbol
54
- column_value = @row_object[column_value]
54
+ column_value = if @row_object.respond_to?(column_value)
55
+ @row_object.public_send(column_value)
56
+ else
57
+ @row_object[column_value]
58
+ end
55
59
  end
56
60
 
57
61
  if (formatter_name = options[:formatter])
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  module Resque
3
3
  module Reports
4
- VERSION = '0.4.7'
4
+ VERSION = '0.5.0'
5
5
  end
6
6
  end
7
7
 
@@ -67,6 +67,30 @@ class MyCsvExpiredReport < Resque::Reports::CsvReport
67
67
  end
68
68
  end
69
69
 
70
+
71
+ Person = Struct.new(:first_name, :second_name) do
72
+ def full_name
73
+ "#{first_name} #{second_name}"
74
+ end
75
+ end
76
+
77
+ class ReportWithObjects < Resque::Reports::CsvReport
78
+ source :select_data
79
+ encoding UTF8
80
+
81
+ directory File.join(Dir.tmpdir, 'resque-reports')
82
+
83
+ table do
84
+ column 'First name', :first_name
85
+ column 'Second name', :second_name
86
+ column 'Full name', :full_name
87
+ end
88
+
89
+ def select_data
90
+ [Person.new('Steve', 'Jobs')]
91
+ end
92
+ end
93
+
70
94
  describe 'Resque::Reports::CsvReport successor' do
71
95
  describe '.csv_options' do
72
96
  context 'when custom options not set' do
@@ -105,6 +129,18 @@ describe 'Resque::Reports::CsvReport successor' do
105
129
  CSV
106
130
  end
107
131
  end
132
+
133
+ context 'when report source data contains decorated objects' do
134
+ subject(:report) { ReportWithObjects.new }
135
+
136
+ it 'builds report with decorated object attributes' do
137
+ report.build(true)
138
+
139
+ report_content = File.read(report.filename)
140
+
141
+ expect(report_content).to include 'Steve;Jobs;Steve Jobs'
142
+ end
143
+ end
108
144
  end
109
145
 
110
146
  describe '#exists?' do
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey D.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque-integration
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.14.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.14.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: timecop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.7.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.7.1
111
111
  description: Make your custom reports to CSV in background using Resque with simple
@@ -116,9 +116,9 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - ".gitignore"
120
- - ".rspec"
121
- - ".rubocop.yml"
119
+ - .gitignore
120
+ - .rspec
121
+ - .rubocop.yml
122
122
  - Gemfile
123
123
  - MIT-LICENSE
124
124
  - README
@@ -155,17 +155,17 @@ require_paths:
155
155
  - lib
156
156
  required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - ! '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ">="
163
+ - - ! '>='
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.3
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: resque-reports