tricle 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/tricle.gemspec CHANGED
@@ -18,20 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "actionmailer", "~> 4.0"
22
- spec.add_dependency "activesupport", "~> 4.0"
23
- spec.add_dependency "mail_view", "~> 1.0"
21
+ spec.add_dependency "actionmailer", ">= 3.2"
22
+ spec.add_dependency "activesupport", ">= 3.2"
23
+ spec.add_dependency "mail_view", "~> 2.0"
24
24
  spec.add_dependency "nokogiri", "~> 1.6"
25
25
  spec.add_dependency "premailer", "~> 1.7"
26
26
  spec.add_dependency "rack", "~> 1.1"
27
-
28
- spec.add_development_dependency "bundler", "~> 1.3"
29
- spec.add_development_dependency "debugger"
30
- spec.add_development_dependency "guard", "~> 1.8"
31
- spec.add_development_dependency "guard-rspec"
32
- spec.add_development_dependency "rake"
33
- spec.add_development_dependency "rspec", "~> 2.14"
34
- spec.add_development_dependency "ruby_gntp"
35
- spec.add_development_dependency "shotgun"
36
- spec.add_development_dependency "timecop", "~> 0.6.2"
37
27
  end
metadata CHANGED
@@ -1,225 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tricle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Feldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-19 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '3.2'
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
- version: '4.0'
26
+ version: '3.2'
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
- version: '4.0'
33
+ version: '3.2'
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
- version: '4.0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mail_view
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.6'
62
62
  type: :runtime
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: '1.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: premailer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.7'
76
76
  type: :runtime
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: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.1'
90
90
  type: :runtime
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: '1.1'
97
- - !ruby/object:Gem::Dependency
98
- name: bundler
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: '1.3'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: '1.3'
111
- - !ruby/object:Gem::Dependency
112
- name: debugger
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: guard
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ~>
130
- - !ruby/object:Gem::Version
131
- version: '1.8'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ~>
137
- - !ruby/object:Gem::Version
138
- version: '1.8'
139
- - !ruby/object:Gem::Dependency
140
- name: guard-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - '>='
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '>='
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rake
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '>='
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '>='
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: rspec
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ~>
172
- - !ruby/object:Gem::Version
173
- version: '2.14'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ~>
179
- - !ruby/object:Gem::Version
180
- version: '2.14'
181
- - !ruby/object:Gem::Dependency
182
- name: ruby_gntp
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - '>='
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - '>='
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: shotgun
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - '>='
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - '>='
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: timecop
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ~>
214
- - !ruby/object:Gem::Version
215
- version: 0.6.2
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ~>
221
- - !ruby/object:Gem::Version
222
- version: 0.6.2
223
97
  description: Automated metrics reporting via email
224
98
  email:
225
99
  - aidan.feldman@gmail.com
@@ -227,24 +101,27 @@ executables: []
227
101
  extensions: []
228
102
  extra_rdoc_files: []
229
103
  files:
230
- - .gitignore
231
- - .rspec
232
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Appraisals
233
108
  - CONTRIBUTING.md
234
109
  - Gemfile
235
110
  - Guardfile
236
111
  - LICENSE.txt
237
112
  - README.md
238
113
  - Rakefile
114
+ - gemfiles/rails_3.gemfile
115
+ - gemfiles/rails_4.gemfile
239
116
  - lib/tricle.rb
240
117
  - lib/tricle/abstract_method_error.rb
118
+ - lib/tricle/aggregation.rb
241
119
  - lib/tricle/email_helper.rb
242
120
  - lib/tricle/mail_preview.rb
243
121
  - lib/tricle/mailer.rb
244
122
  - lib/tricle/metric.rb
245
123
  - lib/tricle/presenters/group.rb
246
124
  - lib/tricle/presenters/list.rb
247
- - lib/tricle/presenters/metric.rb
248
125
  - lib/tricle/presenters/report.rb
249
126
  - lib/tricle/presenters/section.rb
250
127
  - lib/tricle/range_data.rb
@@ -256,18 +133,20 @@ files:
256
133
  - screenshot.png
257
134
  - spec/app/group_test_mailer.rb
258
135
  - spec/app/list_test_mailer.rb
136
+ - spec/app/no_total_test_mailer.rb
259
137
  - spec/app/test_mailer.rb
260
138
  - spec/app/test_metric.rb
261
139
  - spec/app/test_metric_with_long_name.rb
140
+ - spec/app/test_metric_with_no_total.rb
262
141
  - spec/app/uber_test_mailer.rb
263
142
  - spec/config/timecop.rb
264
143
  - spec/fixture_generator
265
144
  - spec/fixtures/weeks.csv
266
145
  - spec/presenters/group_spec.rb
267
- - spec/presenters/metric_spec.rb
268
146
  - spec/presenters/report_spec.rb
269
147
  - spec/spec_helper.rb
270
148
  - spec/unit/abstract_method_error_spec.rb
149
+ - spec/unit/aggregation_spec.rb
271
150
  - spec/unit/email_helper_spec.rb
272
151
  - spec/unit/mail_preview_spec.rb
273
152
  - spec/unit/mailer_spec.rb
@@ -285,17 +164,17 @@ require_paths:
285
164
  - lib
286
165
  required_ruby_version: !ruby/object:Gem::Requirement
287
166
  requirements:
288
- - - '>='
167
+ - - ">="
289
168
  - !ruby/object:Gem::Version
290
169
  version: '0'
291
170
  required_rubygems_version: !ruby/object:Gem::Requirement
292
171
  requirements:
293
- - - '>='
172
+ - - ">="
294
173
  - !ruby/object:Gem::Version
295
174
  version: '0'
296
175
  requirements: []
297
176
  rubyforge_project:
298
- rubygems_version: 2.0.3
177
+ rubygems_version: 2.4.1
299
178
  signing_key:
300
179
  specification_version: 4
301
180
  summary: A datastore-agnostic mailer where you can define custom metrics, where you
@@ -304,18 +183,20 @@ summary: A datastore-agnostic mailer where you can define custom metrics, where
304
183
  test_files:
305
184
  - spec/app/group_test_mailer.rb
306
185
  - spec/app/list_test_mailer.rb
186
+ - spec/app/no_total_test_mailer.rb
307
187
  - spec/app/test_mailer.rb
308
188
  - spec/app/test_metric.rb
309
189
  - spec/app/test_metric_with_long_name.rb
190
+ - spec/app/test_metric_with_no_total.rb
310
191
  - spec/app/uber_test_mailer.rb
311
192
  - spec/config/timecop.rb
312
193
  - spec/fixture_generator
313
194
  - spec/fixtures/weeks.csv
314
195
  - spec/presenters/group_spec.rb
315
- - spec/presenters/metric_spec.rb
316
196
  - spec/presenters/report_spec.rb
317
197
  - spec/spec_helper.rb
318
198
  - spec/unit/abstract_method_error_spec.rb
199
+ - spec/unit/aggregation_spec.rb
319
200
  - spec/unit/email_helper_spec.rb
320
201
  - spec/unit/mail_preview_spec.rb
321
202
  - spec/unit/mailer_spec.rb
@@ -1,51 +0,0 @@
1
- module Tricle
2
- module Presenters
3
- class Metric
4
- attr_reader :metric, :now
5
-
6
- def initialize(klass)
7
- @metric = klass.new
8
- # TODO allow Time to be passed in so it can be frozen
9
- @now = Time.now
10
- end
11
-
12
- def title
13
- self.metric.title
14
- end
15
-
16
- def total
17
- self.metric.total
18
- end
19
-
20
- def days_ago(n)
21
- start_at = self.now.beginning_of_day.days_ago(n)
22
- end_at = start_at + 1.day
23
- self.metric.size_for_range(start_at, end_at)
24
- end
25
-
26
- def yesterday
27
- self.days_ago(1)
28
- end
29
-
30
- def weeks_ago(n)
31
- start_at = self.now.beginning_of_week.weeks_ago(n)
32
- end_at = start_at + 7.days
33
- self.metric.size_for_range(start_at, end_at)
34
- end
35
-
36
- def last_week
37
- self.weeks_ago(1)
38
- end
39
-
40
- def weeks_average(past_num_weeks)
41
- weeks_range = 1..past_num_weeks
42
- total = weeks_range.reduce(0){|sum, n| sum + self.weeks_ago(n) }
43
- total.to_f / past_num_weeks
44
- end
45
-
46
- def week_average_this_quarter
47
- self.weeks_average(13)
48
- end
49
- end
50
- end
51
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require_relative '../../lib/tricle/presenters/metric'
3
-
4
- describe Tricle::Presenters::Metric do
5
- let(:presenter) { Tricle::Presenters::Metric.new(TestMetric) }
6
- let(:metric) { presenter.metric }
7
-
8
- describe '#days_ago' do
9
- it "should start and end at midnight" do
10
- metric.should_receive(:size_for_range).with(Time.new(2013, 7, 29), Time.new(2013, 7, 30))
11
- presenter.days_ago(3)
12
- end
13
- end
14
-
15
- describe '#yesterday' do
16
- it "should start and end at midnight" do
17
- metric.should_receive(:size_for_range).with(Time.new(2013, 7, 31), Time.new(2013, 8, 1))
18
- presenter.yesterday
19
- end
20
- end
21
-
22
- describe '#weeks_ago' do
23
- it "should start and end on Monday" do
24
- metric.should_receive(:size_for_range).with(Time.new(2013, 7, 8), Time.new(2013, 7, 15))
25
- presenter.weeks_ago(3)
26
- end
27
- end
28
-
29
- describe '#last_week' do
30
- it "should start and end on Monday" do
31
- metric.should_receive(:size_for_range).with(Time.new(2013, 7, 22), Time.new(2013, 7, 29))
32
- presenter.last_week
33
- end
34
- end
35
-
36
- describe '#week_average_this_quarter' do
37
- it "should average the values provided by #size_for_range" do
38
- metric.should_receive(:size_for_range).exactly(13).times.and_return(1)
39
- presenter.week_average_this_quarter.should eq(1)
40
- end
41
- end
42
- end