nucleo-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +2 -0
  3. data/.gitignore +16 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +31 -0
  7. data/Rakefile +37 -0
  8. data/lib/nucleo/client.rb +172 -0
  9. data/lib/nucleo/client/version.rb +5 -0
  10. data/lib/nucleo/configuration.rb +83 -0
  11. data/lib/nucleo/configurations.rb +6 -0
  12. data/lib/nucleo/configurations/default.rb +100 -0
  13. data/lib/nucleo/connection.rb +44 -0
  14. data/lib/nucleo/errors.rb +7 -0
  15. data/lib/nucleo/errors/invalid_uri_error.rb +6 -0
  16. data/lib/nucleo/errors/record_not_found.rb +6 -0
  17. data/lib/nucleo/logger.rb +36 -0
  18. data/lib/nucleo/models.rb +50 -0
  19. data/lib/nucleo/models/change_types.rb +10 -0
  20. data/lib/nucleo/models/change_types/base.rb +81 -0
  21. data/lib/nucleo/models/change_types/seo.rb +13 -0
  22. data/lib/nucleo/models/change_types/seo/base.rb +50 -0
  23. data/lib/nucleo/models/change_types/seo/meta_description.rb +10 -0
  24. data/lib/nucleo/models/change_types/seo/page_title.rb +10 -0
  25. data/lib/nucleo/models/changes.rb +50 -0
  26. data/lib/nucleo/models/check_js.rb +41 -0
  27. data/lib/nucleo/models/check_types.rb +11 -0
  28. data/lib/nucleo/models/check_types/base.rb +25 -0
  29. data/lib/nucleo/models/check_types/count.rb +26 -0
  30. data/lib/nucleo/models/check_types/length.rb +26 -0
  31. data/lib/nucleo/models/check_types/not_exists.rb +8 -0
  32. data/lib/nucleo/models/checks.rb +56 -0
  33. data/lib/nucleo/models/concerns.rb +7 -0
  34. data/lib/nucleo/models/concerns/count.rb +57 -0
  35. data/lib/nucleo/models/concerns/length.rb +57 -0
  36. data/lib/nucleo/models/date_range.rb +66 -0
  37. data/lib/nucleo/models/element.rb +40 -0
  38. data/lib/nucleo/models/elements.rb +47 -0
  39. data/lib/nucleo/models/feed.rb +141 -0
  40. data/lib/nucleo/models/feed_types.rb +11 -0
  41. data/lib/nucleo/models/feed_types/analytics.rb +18 -0
  42. data/lib/nucleo/models/feed_types/analytics/base.rb +12 -0
  43. data/lib/nucleo/models/feed_types/analytics/page/channels.rb +61 -0
  44. data/lib/nucleo/models/feed_types/analytics/page/pages.rb +58 -0
  45. data/lib/nucleo/models/feed_types/analytics/page/referrers.rb +61 -0
  46. data/lib/nucleo/models/feed_types/analytics/page/social.rb +61 -0
  47. data/lib/nucleo/models/feed_types/analytics/site/channels.rb +61 -0
  48. data/lib/nucleo/models/feed_types/analytics/site/pages.rb +61 -0
  49. data/lib/nucleo/models/feed_types/analytics/site/referrers.rb +61 -0
  50. data/lib/nucleo/models/feed_types/analytics/site/social.rb +61 -0
  51. data/lib/nucleo/models/feed_types/base.rb +182 -0
  52. data/lib/nucleo/models/feed_types/seo.rb +22 -0
  53. data/lib/nucleo/models/feed_types/seo/page/base.rb +47 -0
  54. data/lib/nucleo/models/feed_types/seo/page/img_alt.rb +90 -0
  55. data/lib/nucleo/models/feed_types/seo/page/meta_description.rb +49 -0
  56. data/lib/nucleo/models/feed_types/seo/page/meta_robots.rb +48 -0
  57. data/lib/nucleo/models/feed_types/seo/page/page_title.rb +48 -0
  58. data/lib/nucleo/models/feed_types/seo/page/seo_summary.rb +53 -0
  59. data/lib/nucleo/models/feed_types/seo/page/summary.rb +52 -0
  60. data/lib/nucleo/models/feed_types/seo/site/base.rb +22 -0
  61. data/lib/nucleo/models/feed_types/seo/site/img_alt.rb +14 -0
  62. data/lib/nucleo/models/feed_types/seo/site/meta_description.rb +14 -0
  63. data/lib/nucleo/models/feed_types/seo/site/meta_robots.rb +14 -0
  64. data/lib/nucleo/models/feed_types/seo/site/page_title.rb +14 -0
  65. data/lib/nucleo/models/feeds.rb +126 -0
  66. data/lib/nucleo/models/metric.rb +54 -0
  67. data/lib/nucleo/models/metric_period.rb +97 -0
  68. data/lib/nucleo/models/metric_period_row.rb +125 -0
  69. data/lib/nucleo/models/metric_period_rows.rb +34 -0
  70. data/lib/nucleo/models/metric_period_totals.rb +121 -0
  71. data/lib/nucleo/models/metric_periods.rb +78 -0
  72. data/lib/nucleo/models/metric_periods_comparison.rb +80 -0
  73. data/lib/nucleo/models/metric_periods_comparisons.rb +73 -0
  74. data/lib/nucleo/models/metric_periods_totals.rb +58 -0
  75. data/lib/nucleo/models/page.rb +147 -0
  76. data/lib/nucleo/models/page_alerts.rb +27 -0
  77. data/lib/nucleo/models/page_metric.rb +58 -0
  78. data/lib/nucleo/models/page_rank.rb +28 -0
  79. data/lib/nucleo/models/pages.rb +40 -0
  80. data/lib/nucleo/models/seo_score.rb +28 -0
  81. data/lib/nucleo/models/site_feed.rb +82 -0
  82. data/lib/nucleo/models/tag.rb +48 -0
  83. data/lib/nucleo/models/tags.rb +35 -0
  84. data/lib/nucleo/requests.rb +14 -0
  85. data/lib/nucleo/requests/analyzer.rb +35 -0
  86. data/lib/nucleo/requests/check_js.rb +56 -0
  87. data/lib/nucleo/requests/feed.rb +58 -0
  88. data/lib/nucleo/requests/page.rb +113 -0
  89. data/lib/nucleo/requests/page_alerts.rb +36 -0
  90. data/lib/nucleo/requests/page_changes.rb +44 -0
  91. data/lib/nucleo/requests/site.rb +26 -0
  92. data/lib/nucleo/requests/site_changes.rb +56 -0
  93. data/lib/nucleo/requests/site_feed.rb +41 -0
  94. data/lib/nucleo/response.rb +52 -0
  95. data/lib/nucleo/utilities.rb +7 -0
  96. data/lib/nucleo/utilities/status_code_mapper.rb +53 -0
  97. data/lib/nucleo/webhook.rb +26 -0
  98. data/nucleo-client.gemspec +35 -0
  99. data/spec/data/models/feed_types/seo/heading_tag_length.json +55 -0
  100. data/spec/data/models/feed_types/seo/internal_link_count.json +149 -0
  101. data/spec/data/models/feed_types/seo/no_follow_link_count.json +142 -0
  102. data/spec/spec_helper.rb +15 -0
  103. data/spec/unit/nucleo/models/concerns/count_spec.rb +103 -0
  104. data/spec/unit/nucleo/models/concerns/length_spec.rb +79 -0
  105. data/spec/unit/nucleo/models/feed_types/analytics/site/pages_no_data_spec.rb +39 -0
  106. data/spec/unit/nucleo/models/metric_periods_comparison_spec.rb +50 -0
  107. data/spec/unit/nucleo/models/metric_periods_comparisons_spec.rb +58 -0
  108. metadata +341 -0
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../feed_types/base', __FILE__)
2
+
3
+ require File.expand_path('../feed_types/seo', __FILE__)
4
+ require File.expand_path('../feed_types/analytics', __FILE__)
5
+
6
+ module Nucleo
7
+ module Models
8
+ module FeedTypes
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../analytics/base', __FILE__)
2
+ require File.expand_path('../analytics/page/social', __FILE__)
3
+ require File.expand_path('../analytics/page/pages', __FILE__)
4
+ require File.expand_path('../analytics/page/channels', __FILE__)
5
+ require File.expand_path('../analytics/page/referrers', __FILE__)
6
+ require File.expand_path('../analytics/site/social', __FILE__)
7
+ require File.expand_path('../analytics/site/pages', __FILE__)
8
+ require File.expand_path('../analytics/site/channels', __FILE__)
9
+ require File.expand_path('../analytics/site/referrers', __FILE__)
10
+
11
+ module Nucleo
12
+ module Models
13
+ module FeedTypes
14
+ module Analytics
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../base', __FILE__)
2
+
3
+ module Nucleo
4
+ module Models
5
+ module FeedTypes
6
+ module Analytics
7
+ class Base < Nucleo::Models::FeedTypes::Base
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Page
6
+
7
+ class Channels < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:channelGrouping'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ # Delegates to the Metric Period
42
+ #
43
+ # @return [Nucleo::Models::MetricPeriod]
44
+ def prior_period
45
+ self.metric.metric_periods.prior_period
46
+ end
47
+ alias :previous_period :prior_period
48
+
49
+ # Delegates to the Metric Period
50
+ #
51
+ # @return [Nucleo::Models::MetricPeriodsComparisons]
52
+ def periods_comparisons
53
+ self.metric.metric_periods.periods_comparisons
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,58 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Page
6
+
7
+ class Pages < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:pageviews'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ def any?
42
+ self.current_period.rows?
43
+ end
44
+
45
+ # Delegates to the Metric Period
46
+ #
47
+ # @return [Nucleo::Models::MetricPeriod]
48
+ def prior_period
49
+ self.metric.metric_periods.prior_period
50
+ end
51
+ alias :previous_period :prior_period
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,61 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Page
6
+
7
+ class Referrers < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:source'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ # Delegates to the Metric Period
42
+ #
43
+ # @return [Nucleo::Models::MetricPeriod]
44
+ def prior_period
45
+ self.metric.metric_periods.prior_period
46
+ end
47
+ alias :previous_period :prior_period
48
+
49
+ # Delegates to the Metric Period
50
+ #
51
+ # @return [Nucleo::Models::MetricPeriodsComparisons]
52
+ def periods_comparisons
53
+ self.metric.metric_periods.periods_comparisons
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Page
6
+
7
+ class Social < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:socialNetwork'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ # Delegates to the Metric Period
42
+ #
43
+ # @return [Nucleo::Models::MetricPeriod]
44
+ def prior_period
45
+ self.metric.metric_periods.prior_period
46
+ end
47
+ alias :previous_period :prior_period
48
+
49
+ # Delegates to the Metric Period
50
+ #
51
+ # @return [Nucleo::Models::MetricPeriodsComparisons]
52
+ def periods_comparisons
53
+ self.metric.metric_periods.periods_comparisons
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Site
6
+
7
+ class Channels < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:channelGrouping'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ # Delegates to the Metric Period
42
+ #
43
+ # @return [Nucleo::Models::MetricPeriod]
44
+ def prior_period
45
+ self.metric.metric_periods.prior_period
46
+ end
47
+ alias :previous_period :prior_period
48
+
49
+ # Delegates to the Metric Period
50
+ #
51
+ # @return [Nucleo::Models::MetricPeriodsComparisons]
52
+ def periods_comparisons
53
+ self.metric.metric_periods.periods_comparisons
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ require File.expand_path('../../../../metric', __FILE__)
2
+ require File.expand_path('../../base', __FILE__)
3
+
4
+ module Nucleo
5
+ module Models
6
+ module FeedTypes
7
+ module Analytics
8
+ module Site
9
+
10
+ class Pages < Nucleo::Models::FeedTypes::Analytics::Base
11
+ DIMENSION_NAME = 'ga:pageviews'.freeze
12
+ METRIC_NAME = 'ga:pageviews'.freeze
13
+
14
+ # Returns the specific Metric for this page
15
+ #
16
+ # @return [Nucleo::Models::Metric]
17
+ def metric
18
+ params = {
19
+ 'metric' => METRIC_NAME,
20
+ 'dimension' => DIMENSION_NAME,
21
+ 'classification' => @attributes['classification'],
22
+ 'totals' => data.fetch('totals', {}),
23
+ 'current_period' => data.fetch('current_period', {}),
24
+ 'prior_period' => data.fetch('prior_period', {})
25
+ }
26
+
27
+ Nucleo::Models::Metric.new(params)
28
+ end
29
+
30
+ # Delegates to the Totals
31
+ #
32
+ # @return [Nucleo::Models::MetricPeriodsTotals]
33
+ def totals
34
+ self.metric.metric_periods.totals
35
+ end
36
+
37
+ # Delegates to the Metric Period
38
+ #
39
+ # @return [Nucleo::Models::MetricPeriod]
40
+ def current_period
41
+ self.metric.metric_periods.current_period
42
+ end
43
+
44
+ def any?
45
+ self.current_period.rows?
46
+ end
47
+
48
+ # Delegates to the Metric Period
49
+ #
50
+ # @return [Nucleo::Models::MetricPeriod]
51
+ def prior_period
52
+ self.metric.metric_periods.prior_period
53
+ end
54
+ alias :previous_period :prior_period
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ module Nucleo
2
+ module Models
3
+ module FeedTypes
4
+ module Analytics
5
+ module Site
6
+
7
+ class Referrers < Nucleo::Models::FeedTypes::Analytics::Base
8
+ DIMENSION_NAME = 'ga:source'.freeze
9
+ METRIC_NAME = 'ga:pageviews'.freeze
10
+
11
+ # Returns the specific Metric for this page
12
+ #
13
+ # @return [Nucleo::Models::Metric]
14
+ def metric
15
+ params = {
16
+ 'metric' => METRIC_NAME,
17
+ 'dimension' => DIMENSION_NAME,
18
+ 'classification' => @attributes['classification'],
19
+ 'totals' => data['totals'],
20
+ 'current_period' => data['current_period'],
21
+ 'prior_period' => data['prior_period']
22
+ }
23
+
24
+ Nucleo::Models::Metric.new(params)
25
+ end
26
+
27
+ # Delegates to the Totals
28
+ #
29
+ # @return [Nucleo::Models::MetricPeriodsTotals]
30
+ def totals
31
+ self.metric.metric_periods.totals
32
+ end
33
+
34
+ # Delegates to the Metric Period
35
+ #
36
+ # @return [Nucleo::Models::MetricPeriod]
37
+ def current_period
38
+ self.metric.metric_periods.current_period
39
+ end
40
+
41
+ # Delegates to the Metric Period
42
+ #
43
+ # @return [Nucleo::Models::MetricPeriod]
44
+ def prior_period
45
+ self.metric.metric_periods.prior_period
46
+ end
47
+ alias :previous_period :prior_period
48
+
49
+ # Delegates to the Metric Period
50
+ #
51
+ # @return [Nucleo::Models::MetricPeriodsComparisons]
52
+ def periods_comparisons
53
+ self.metric.metric_periods.periods_comparisons
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end