nucleo-client 0.1.0
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 +7 -0
- data/.env.sample +2 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +37 -0
- data/lib/nucleo/client.rb +172 -0
- data/lib/nucleo/client/version.rb +5 -0
- data/lib/nucleo/configuration.rb +83 -0
- data/lib/nucleo/configurations.rb +6 -0
- data/lib/nucleo/configurations/default.rb +100 -0
- data/lib/nucleo/connection.rb +44 -0
- data/lib/nucleo/errors.rb +7 -0
- data/lib/nucleo/errors/invalid_uri_error.rb +6 -0
- data/lib/nucleo/errors/record_not_found.rb +6 -0
- data/lib/nucleo/logger.rb +36 -0
- data/lib/nucleo/models.rb +50 -0
- data/lib/nucleo/models/change_types.rb +10 -0
- data/lib/nucleo/models/change_types/base.rb +81 -0
- data/lib/nucleo/models/change_types/seo.rb +13 -0
- data/lib/nucleo/models/change_types/seo/base.rb +50 -0
- data/lib/nucleo/models/change_types/seo/meta_description.rb +10 -0
- data/lib/nucleo/models/change_types/seo/page_title.rb +10 -0
- data/lib/nucleo/models/changes.rb +50 -0
- data/lib/nucleo/models/check_js.rb +41 -0
- data/lib/nucleo/models/check_types.rb +11 -0
- data/lib/nucleo/models/check_types/base.rb +25 -0
- data/lib/nucleo/models/check_types/count.rb +26 -0
- data/lib/nucleo/models/check_types/length.rb +26 -0
- data/lib/nucleo/models/check_types/not_exists.rb +8 -0
- data/lib/nucleo/models/checks.rb +56 -0
- data/lib/nucleo/models/concerns.rb +7 -0
- data/lib/nucleo/models/concerns/count.rb +57 -0
- data/lib/nucleo/models/concerns/length.rb +57 -0
- data/lib/nucleo/models/date_range.rb +66 -0
- data/lib/nucleo/models/element.rb +40 -0
- data/lib/nucleo/models/elements.rb +47 -0
- data/lib/nucleo/models/feed.rb +141 -0
- data/lib/nucleo/models/feed_types.rb +11 -0
- data/lib/nucleo/models/feed_types/analytics.rb +18 -0
- data/lib/nucleo/models/feed_types/analytics/base.rb +12 -0
- data/lib/nucleo/models/feed_types/analytics/page/channels.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/page/pages.rb +58 -0
- data/lib/nucleo/models/feed_types/analytics/page/referrers.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/page/social.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/site/channels.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/site/pages.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/site/referrers.rb +61 -0
- data/lib/nucleo/models/feed_types/analytics/site/social.rb +61 -0
- data/lib/nucleo/models/feed_types/base.rb +182 -0
- data/lib/nucleo/models/feed_types/seo.rb +22 -0
- data/lib/nucleo/models/feed_types/seo/page/base.rb +47 -0
- data/lib/nucleo/models/feed_types/seo/page/img_alt.rb +90 -0
- data/lib/nucleo/models/feed_types/seo/page/meta_description.rb +49 -0
- data/lib/nucleo/models/feed_types/seo/page/meta_robots.rb +48 -0
- data/lib/nucleo/models/feed_types/seo/page/page_title.rb +48 -0
- data/lib/nucleo/models/feed_types/seo/page/seo_summary.rb +53 -0
- data/lib/nucleo/models/feed_types/seo/page/summary.rb +52 -0
- data/lib/nucleo/models/feed_types/seo/site/base.rb +22 -0
- data/lib/nucleo/models/feed_types/seo/site/img_alt.rb +14 -0
- data/lib/nucleo/models/feed_types/seo/site/meta_description.rb +14 -0
- data/lib/nucleo/models/feed_types/seo/site/meta_robots.rb +14 -0
- data/lib/nucleo/models/feed_types/seo/site/page_title.rb +14 -0
- data/lib/nucleo/models/feeds.rb +126 -0
- data/lib/nucleo/models/metric.rb +54 -0
- data/lib/nucleo/models/metric_period.rb +97 -0
- data/lib/nucleo/models/metric_period_row.rb +125 -0
- data/lib/nucleo/models/metric_period_rows.rb +34 -0
- data/lib/nucleo/models/metric_period_totals.rb +121 -0
- data/lib/nucleo/models/metric_periods.rb +78 -0
- data/lib/nucleo/models/metric_periods_comparison.rb +80 -0
- data/lib/nucleo/models/metric_periods_comparisons.rb +73 -0
- data/lib/nucleo/models/metric_periods_totals.rb +58 -0
- data/lib/nucleo/models/page.rb +147 -0
- data/lib/nucleo/models/page_alerts.rb +27 -0
- data/lib/nucleo/models/page_metric.rb +58 -0
- data/lib/nucleo/models/page_rank.rb +28 -0
- data/lib/nucleo/models/pages.rb +40 -0
- data/lib/nucleo/models/seo_score.rb +28 -0
- data/lib/nucleo/models/site_feed.rb +82 -0
- data/lib/nucleo/models/tag.rb +48 -0
- data/lib/nucleo/models/tags.rb +35 -0
- data/lib/nucleo/requests.rb +14 -0
- data/lib/nucleo/requests/analyzer.rb +35 -0
- data/lib/nucleo/requests/check_js.rb +56 -0
- data/lib/nucleo/requests/feed.rb +58 -0
- data/lib/nucleo/requests/page.rb +113 -0
- data/lib/nucleo/requests/page_alerts.rb +36 -0
- data/lib/nucleo/requests/page_changes.rb +44 -0
- data/lib/nucleo/requests/site.rb +26 -0
- data/lib/nucleo/requests/site_changes.rb +56 -0
- data/lib/nucleo/requests/site_feed.rb +41 -0
- data/lib/nucleo/response.rb +52 -0
- data/lib/nucleo/utilities.rb +7 -0
- data/lib/nucleo/utilities/status_code_mapper.rb +53 -0
- data/lib/nucleo/webhook.rb +26 -0
- data/nucleo-client.gemspec +35 -0
- data/spec/data/models/feed_types/seo/heading_tag_length.json +55 -0
- data/spec/data/models/feed_types/seo/internal_link_count.json +149 -0
- data/spec/data/models/feed_types/seo/no_follow_link_count.json +142 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/unit/nucleo/models/concerns/count_spec.rb +103 -0
- data/spec/unit/nucleo/models/concerns/length_spec.rb +79 -0
- data/spec/unit/nucleo/models/feed_types/analytics/site/pages_no_data_spec.rb +39 -0
- data/spec/unit/nucleo/models/metric_periods_comparison_spec.rb +50 -0
- data/spec/unit/nucleo/models/metric_periods_comparisons_spec.rb +58 -0
- metadata +341 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require File.expand_path('../metric_period_rows', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Nucleo
|
|
4
|
+
module Models
|
|
5
|
+
class MetricPeriod
|
|
6
|
+
include Comparable
|
|
7
|
+
|
|
8
|
+
# Returns an instance of the Metric Period domain model
|
|
9
|
+
#
|
|
10
|
+
# @param attributes [Hash]
|
|
11
|
+
#
|
|
12
|
+
# @return [Nucleo::Models::MetricPeriod]
|
|
13
|
+
def initialize(attributes={})
|
|
14
|
+
@attributes = attributes
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Implement Comparable
|
|
18
|
+
def <=>(other)
|
|
19
|
+
if self.current?
|
|
20
|
+
1
|
|
21
|
+
elsif self.prior?
|
|
22
|
+
0
|
|
23
|
+
else
|
|
24
|
+
-1
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns the type of the metric
|
|
29
|
+
#
|
|
30
|
+
# @return [String]
|
|
31
|
+
def metric
|
|
32
|
+
@attributes['metric']
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns the dimension
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
def dimension
|
|
39
|
+
@attributes['dimension']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Returns the name of the period
|
|
43
|
+
#
|
|
44
|
+
# @return [String]
|
|
45
|
+
def period_name
|
|
46
|
+
@attributes['period_name']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Returns true if this is current
|
|
50
|
+
#
|
|
51
|
+
# @return [Boolean]
|
|
52
|
+
def current?
|
|
53
|
+
'current' == self.period_name
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns true if this is for the prior period
|
|
57
|
+
#
|
|
58
|
+
# @return [Boolean]
|
|
59
|
+
def prior?
|
|
60
|
+
'prior' == self.period_name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns the totals for this type of metric
|
|
64
|
+
#
|
|
65
|
+
# @return [Integer]
|
|
66
|
+
def totals
|
|
67
|
+
totals_hash.fetch(self.metric, 0).to_i
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Returns the instance of the DateRange domain model
|
|
71
|
+
#
|
|
72
|
+
# @return [Nucleo::Models::DateRange]
|
|
73
|
+
def date_range
|
|
74
|
+
Nucleo::Models::DateRange.new(@attributes.fetch('date_range', {}))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Returns an instance of the MetricPeriodRows domain model
|
|
78
|
+
#
|
|
79
|
+
# @return [Nucleo::Models::MetricPeriodRows]
|
|
80
|
+
def rows
|
|
81
|
+
Nucleo::Models::MetricPeriodRows.new(self.metric, self.dimension, self.period_name, @attributes.fetch('rows', []))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Returns true if there are any rows
|
|
85
|
+
#
|
|
86
|
+
# @return [Boolean]
|
|
87
|
+
def rows?
|
|
88
|
+
self.rows.any?
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
def totals_hash
|
|
93
|
+
@attributes.fetch('totals', {})
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
class MetricPeriodRow
|
|
4
|
+
# Returns an instance of the Metric Period Row domain model
|
|
5
|
+
#
|
|
6
|
+
# @param attributes [Hash]
|
|
7
|
+
#
|
|
8
|
+
# @return [Nucleo::Models::MetricPeriodRow]
|
|
9
|
+
def initialize(attributes={})
|
|
10
|
+
@attributes = attributes
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Returns the type of the row
|
|
14
|
+
#
|
|
15
|
+
# @return [String]
|
|
16
|
+
def metric
|
|
17
|
+
@attributes['metric']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns the dimension
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
def dimension
|
|
24
|
+
@attributes['dimension']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Returns the dimension name
|
|
28
|
+
#
|
|
29
|
+
# @return [String]
|
|
30
|
+
def dimension_name
|
|
31
|
+
if self.page?
|
|
32
|
+
self.page.title
|
|
33
|
+
else
|
|
34
|
+
row.fetch(self.dimension, '')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Returns the period name
|
|
39
|
+
#
|
|
40
|
+
# @return [String]
|
|
41
|
+
def period_name
|
|
42
|
+
@attributes['period_name']
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Returns true if this is the current period
|
|
46
|
+
#
|
|
47
|
+
# @return [Boolean]
|
|
48
|
+
def current?
|
|
49
|
+
'current' == self.period_name
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Returns true if this is the prior period
|
|
53
|
+
#
|
|
54
|
+
# @return [Boolean]
|
|
55
|
+
def prior?
|
|
56
|
+
'prior' == self.period_name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Returns an instance of the Page domain model
|
|
60
|
+
#
|
|
61
|
+
# @return [Nucleo::Models::Page]
|
|
62
|
+
def page
|
|
63
|
+
val = row['page']
|
|
64
|
+
|
|
65
|
+
return nil if val.nil? || val.empty?
|
|
66
|
+
|
|
67
|
+
Nucleo::Models::Page.new(val)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Returns true if there is a page
|
|
71
|
+
#
|
|
72
|
+
# @return [Boolean]
|
|
73
|
+
def page?
|
|
74
|
+
!self.page.nil?
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Return the value for this metric
|
|
78
|
+
#
|
|
79
|
+
# @return [Integer]
|
|
80
|
+
def value
|
|
81
|
+
row.fetch(self.metric, 0).to_i
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Returns the change
|
|
85
|
+
#
|
|
86
|
+
# @return [Float]
|
|
87
|
+
def change
|
|
88
|
+
row[translated_key_name(:change)].to_f
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Returns the percent total
|
|
92
|
+
#
|
|
93
|
+
# @return [Float]
|
|
94
|
+
def pct_total
|
|
95
|
+
row[translated_key_name(:pct_total)].to_f
|
|
96
|
+
end
|
|
97
|
+
alias :percent_total :pct_total
|
|
98
|
+
|
|
99
|
+
# Returns the rank change
|
|
100
|
+
#
|
|
101
|
+
# @return [Integer]
|
|
102
|
+
def rank_change
|
|
103
|
+
row[translated_key_name(:rank_change)].to_i
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Returns the rank
|
|
107
|
+
#
|
|
108
|
+
# @return [Integer]
|
|
109
|
+
def rank
|
|
110
|
+
row[translated_key_name(:rank)].to_i
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
def translated_key_name(key)
|
|
115
|
+
key = key.to_s
|
|
116
|
+
|
|
117
|
+
[self.metric, key].join('_')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def row
|
|
121
|
+
@attributes.fetch('row', {})
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path('../metric_period_row', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Nucleo
|
|
4
|
+
module Models
|
|
5
|
+
class MetricPeriodRows
|
|
6
|
+
include Enumerable
|
|
7
|
+
|
|
8
|
+
def initialize(metric, dimension, period_name, collection)
|
|
9
|
+
@metric = metric
|
|
10
|
+
@dimension = dimension
|
|
11
|
+
@period_name = period_name
|
|
12
|
+
@collection = Array(collection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def each(&block)
|
|
16
|
+
internal_collection.each(&block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
def internal_collection
|
|
21
|
+
@collection.map do |r|
|
|
22
|
+
params = {
|
|
23
|
+
'metric' => @metric,
|
|
24
|
+
'dimension' => @dimension,
|
|
25
|
+
'period_name' => @period_name,
|
|
26
|
+
'row' => r
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Nucleo::Models::MetricPeriodRow.new(params)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
class MetricPeriodTotals
|
|
4
|
+
# Returns an instance of the Metric Period Totals
|
|
5
|
+
#
|
|
6
|
+
# This is specific to the period being returned.
|
|
7
|
+
#
|
|
8
|
+
# @param attributes [Hash]
|
|
9
|
+
#
|
|
10
|
+
# @return [Nucleo::Models::MetricPeriodTotals]
|
|
11
|
+
def initialize(attributes={})
|
|
12
|
+
@attributes = attributes
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Returns the type of metric
|
|
16
|
+
#
|
|
17
|
+
# @return [String]
|
|
18
|
+
def metric
|
|
19
|
+
@attributes['metric']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the dimension
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
def dimension
|
|
26
|
+
@attributes['dimension']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns the period for the totals
|
|
30
|
+
#
|
|
31
|
+
# @return [Hash]
|
|
32
|
+
def period
|
|
33
|
+
@attributes.fetch('period', {})
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns the site change totals
|
|
37
|
+
#
|
|
38
|
+
# @return [Float]
|
|
39
|
+
def site_change
|
|
40
|
+
self.period[translated_key_name(:site_change)].to_f
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Returns true if there is a site change
|
|
44
|
+
#
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
def site_change?
|
|
47
|
+
self.site_change > 0
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns the site change percentage
|
|
51
|
+
#
|
|
52
|
+
# @return [Float]
|
|
53
|
+
def site_change_percent
|
|
54
|
+
if self.site_change?
|
|
55
|
+
self.site_change
|
|
56
|
+
else
|
|
57
|
+
(self.site_change * -1)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Returns the dimension change
|
|
62
|
+
#
|
|
63
|
+
# @return [Float]
|
|
64
|
+
def dimension_change
|
|
65
|
+
self.period[translated_key_name(:dimension_change)].to_f
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Returns the site total
|
|
69
|
+
#
|
|
70
|
+
# @return [Float]
|
|
71
|
+
def site
|
|
72
|
+
self.period[translated_key_name(:site)].to_f
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Returns the dimension percentage of site change
|
|
76
|
+
#
|
|
77
|
+
# @return [Float]
|
|
78
|
+
def dimension_pct_of_site_change
|
|
79
|
+
self.period[translated_key_name(:dimension_pct_of_site_change)].to_f
|
|
80
|
+
end
|
|
81
|
+
alias :dimension_percent_of_site_change :dimension_pct_of_site_change
|
|
82
|
+
|
|
83
|
+
# Returns true if there is a dimension percent of site change
|
|
84
|
+
#
|
|
85
|
+
# @return [Boolean]
|
|
86
|
+
def dimension_percent_of_site_change?
|
|
87
|
+
self.dimension_percent_of_site_change > 0
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def dimension_percent_of_site_change_percent
|
|
91
|
+
if self.dimension_percent_of_site_change?
|
|
92
|
+
self.dimension_percent_of_site_change
|
|
93
|
+
else
|
|
94
|
+
(self.dimension_percent_of_site * -1)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Returns the dimension percentage of site
|
|
99
|
+
#
|
|
100
|
+
# @return [Float]
|
|
101
|
+
def dimension_pct_of_site
|
|
102
|
+
self.period[translated_key_name(:dimension_pct_of_site)].to_f
|
|
103
|
+
end
|
|
104
|
+
alias :dimension_percent_of_site :dimension_pct_of_site
|
|
105
|
+
|
|
106
|
+
# Returns the dimension total
|
|
107
|
+
#
|
|
108
|
+
# @return [Float]
|
|
109
|
+
def dimension
|
|
110
|
+
self.period[translated_key_name(:dimension)].to_f
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
def translated_key_name(key)
|
|
115
|
+
key = key.to_s
|
|
116
|
+
|
|
117
|
+
[self.metric, key].join('_')
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require File.expand_path('../metric_period', __FILE__)
|
|
2
|
+
require File.expand_path('../metric_periods_totals', __FILE__)
|
|
3
|
+
|
|
4
|
+
module Nucleo
|
|
5
|
+
module Models
|
|
6
|
+
class MetricPeriods
|
|
7
|
+
# Returns an instance of the Metric Periods domain models
|
|
8
|
+
#
|
|
9
|
+
# This takes in the `totals`, `current_period`, and `prior_period`
|
|
10
|
+
# and wraps their response bodies in specific objects for comparisons.
|
|
11
|
+
#
|
|
12
|
+
# @param attributes [Hash]
|
|
13
|
+
#
|
|
14
|
+
# @return [Nucleo::Models::MetricPeriods]
|
|
15
|
+
def initialize(attributes={})
|
|
16
|
+
@attributes = attributes
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns the type of metric for period
|
|
20
|
+
#
|
|
21
|
+
# @return [String]
|
|
22
|
+
def type
|
|
23
|
+
@attributes['type']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns the type of the metric
|
|
27
|
+
#
|
|
28
|
+
# @return [String]
|
|
29
|
+
def metric
|
|
30
|
+
@attributes['metric']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns the dimension
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
def dimension
|
|
37
|
+
@attributes['dimension']
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns the metric period totals
|
|
41
|
+
#
|
|
42
|
+
# @return [Nucleo::Models::MetricPeriodTotals]
|
|
43
|
+
def totals
|
|
44
|
+
params = {
|
|
45
|
+
'metric' => self.metric,
|
|
46
|
+
'dimension' => self.dimension,
|
|
47
|
+
'totals' => @attributes['totals']
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Nucleo::Models::MetricPeriodsTotals.new(params)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns the metric period
|
|
54
|
+
#
|
|
55
|
+
# @return [Nucleo::Models::MetricPeriod]
|
|
56
|
+
def current_period
|
|
57
|
+
params = @attributes.fetch('current_period', {}).merge!('metric' => self.metric, 'dimension' => self.dimension, 'period_name' => 'current')
|
|
58
|
+
Nucleo::Models::MetricPeriod.new(params)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Returns the prior metric period
|
|
62
|
+
#
|
|
63
|
+
# @return [Nucleo::Models::MetricPeriod]
|
|
64
|
+
def prior_period
|
|
65
|
+
params = @attributes.fetch('prior_period', {}).merge!('metric' => self.metric, 'dimension' => self.dimension, 'period_name' => 'prior')
|
|
66
|
+
Nucleo::Models::MetricPeriod.new(params)
|
|
67
|
+
end
|
|
68
|
+
alias :previous_period :prior_period
|
|
69
|
+
|
|
70
|
+
# Returns a metric periods comparisons collection domain model
|
|
71
|
+
#
|
|
72
|
+
# @return [Array]
|
|
73
|
+
def periods_comparisons
|
|
74
|
+
Nucleo::Models::MetricPeriodsComparisons.new(self.current_period, self.prior_period)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|