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,48 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
module FeedTypes
|
|
4
|
+
module Seo
|
|
5
|
+
module Page
|
|
6
|
+
|
|
7
|
+
class MetaRobots < Nucleo::Models::FeedTypes::Seo::Page::Base
|
|
8
|
+
# Returns the class level feed summary title
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
def self.feed_summary
|
|
12
|
+
"<strong>Meta robot</strong> feed summary"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Delegate to the class level feed summary
|
|
16
|
+
#
|
|
17
|
+
# @return [String]
|
|
18
|
+
def feed_summary
|
|
19
|
+
self.class.feed_summary
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the headline based on the length of the content
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
def headline
|
|
26
|
+
"Meta robot headline"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns the detailed summary
|
|
30
|
+
#
|
|
31
|
+
# @return [String]
|
|
32
|
+
def long_summary
|
|
33
|
+
"Meta robots long summary"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns the short summary
|
|
37
|
+
#
|
|
38
|
+
# @return [String]
|
|
39
|
+
def short_summary
|
|
40
|
+
"Meta robots <strong>noindex</strong> will block search engines."
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
module FeedTypes
|
|
4
|
+
module Seo
|
|
5
|
+
module Page
|
|
6
|
+
|
|
7
|
+
class PageTitle < Nucleo::Models::FeedTypes::Seo::Page::Base
|
|
8
|
+
# Returns the class level feed summary title
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
def self.feed_summary
|
|
12
|
+
"<strong>page title</strong> feed summary"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Delegate to the class level feed summary
|
|
16
|
+
#
|
|
17
|
+
# @return [String]
|
|
18
|
+
def feed_summary
|
|
19
|
+
self.class.feed_summary
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the headline based on the length of the content
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
def headline
|
|
26
|
+
"page title headline"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns the detailed summary
|
|
30
|
+
#
|
|
31
|
+
# @return [String]
|
|
32
|
+
def long_summary
|
|
33
|
+
"page titles long summary"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns the short summary
|
|
37
|
+
#
|
|
38
|
+
# @return [String]
|
|
39
|
+
def short_summary
|
|
40
|
+
"Page titles are customers first impression in search results."
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
module FeedTypes
|
|
4
|
+
module Seo
|
|
5
|
+
module Page
|
|
6
|
+
|
|
7
|
+
class SeoSummary < Nucleo::Models::FeedTypes::Seo::Page::Base
|
|
8
|
+
|
|
9
|
+
# Returns an instance of the SeoScore domain model
|
|
10
|
+
#
|
|
11
|
+
# @return [Nucleo::Models::SeoScore]
|
|
12
|
+
def seo_score
|
|
13
|
+
params = {
|
|
14
|
+
'score' => data['seo_score'],
|
|
15
|
+
'grade' => data['seo_grade']
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Nucleo::Models::SeoScore.new(params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns an instance of the PageRank domain model
|
|
22
|
+
#
|
|
23
|
+
# @return [Nucleo::Models::PageRank]
|
|
24
|
+
def page_rank
|
|
25
|
+
params = {
|
|
26
|
+
'rank' => data['page_rank'],
|
|
27
|
+
'rank_max' => data['page_rank_max']
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Nucleo::Models::PageRank.new(params)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns the number of page views
|
|
34
|
+
#
|
|
35
|
+
# @return [Integer]
|
|
36
|
+
def page_views
|
|
37
|
+
data['page_views'].to_i
|
|
38
|
+
end
|
|
39
|
+
alias :pageviews :page_views
|
|
40
|
+
|
|
41
|
+
# Returns the count of issues (children recommendations)
|
|
42
|
+
#
|
|
43
|
+
# @return [Integer]
|
|
44
|
+
def issue_count
|
|
45
|
+
data['issue_count'].to_i
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Nucleo
|
|
2
|
+
module Models
|
|
3
|
+
module FeedTypes
|
|
4
|
+
module Seo
|
|
5
|
+
module Page
|
|
6
|
+
|
|
7
|
+
class Summary < Nucleo::Models::FeedTypes::Seo::Page::Base
|
|
8
|
+
# Returns an instance of the SeoScore domain model
|
|
9
|
+
#
|
|
10
|
+
# @return [Nucleo::Models::SeoScore]
|
|
11
|
+
def seo_score
|
|
12
|
+
params = {
|
|
13
|
+
'score' => data['seo_score'],
|
|
14
|
+
'grade' => data['seo_grade']
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Nucleo::Models::SeoScore.new(params)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns an instance of the PageRank domain model
|
|
21
|
+
#
|
|
22
|
+
# @return [Nucleo::Models::PageRank]
|
|
23
|
+
def page_rank
|
|
24
|
+
params = {
|
|
25
|
+
'rank' => data['page_rank'],
|
|
26
|
+
'rank_max' => data['page_rank_max']
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Nucleo::Models::PageRank.new(params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the number of page views
|
|
33
|
+
#
|
|
34
|
+
# @return [Integer]
|
|
35
|
+
def page_views
|
|
36
|
+
data['page_views'].to_i
|
|
37
|
+
end
|
|
38
|
+
alias :pageviews :page_views
|
|
39
|
+
|
|
40
|
+
# Returns the count of issues (children recommendations)
|
|
41
|
+
#
|
|
42
|
+
# @return [Integer]
|
|
43
|
+
def issue_count
|
|
44
|
+
data['issue_count'].to_i
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.expand_path('../../../base', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Nucleo
|
|
4
|
+
module Models
|
|
5
|
+
module FeedTypes
|
|
6
|
+
module Seo
|
|
7
|
+
module Site
|
|
8
|
+
|
|
9
|
+
class Base < Nucleo::Models::FeedTypes::Base
|
|
10
|
+
# Returns the count of checks
|
|
11
|
+
#
|
|
12
|
+
# @return [Array]
|
|
13
|
+
def count
|
|
14
|
+
data['count']
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require File.expand_path('../feed', __FILE__)
|
|
2
|
+
require File.expand_path('../../requests/feed', __FILE__)
|
|
3
|
+
|
|
4
|
+
module Nucleo
|
|
5
|
+
module Models
|
|
6
|
+
class Feeds
|
|
7
|
+
include Enumerable
|
|
8
|
+
|
|
9
|
+
# Return an instance of the Feeds Collection domain model
|
|
10
|
+
#
|
|
11
|
+
# @param collection [Array]
|
|
12
|
+
#
|
|
13
|
+
# @return [Nucleo::Models::Feeds]
|
|
14
|
+
def initialize(collection)
|
|
15
|
+
@collection = Array(collection)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Retrieve a record by the ID.
|
|
19
|
+
#
|
|
20
|
+
# @return [Nucleo::Models::Feed, nil]
|
|
21
|
+
def find_by_id(id)
|
|
22
|
+
self.find { |record| record.id == id.to_s }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns only SEO category items
|
|
26
|
+
#
|
|
27
|
+
# @return [Array]
|
|
28
|
+
def seo_category
|
|
29
|
+
self.select(&:seo_category?)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns only the Analytics category items
|
|
33
|
+
#
|
|
34
|
+
# @return [Array]
|
|
35
|
+
def analytics_category
|
|
36
|
+
self.select(&:analytics_category?)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Returns only the page context items
|
|
40
|
+
#
|
|
41
|
+
# @return [Array]
|
|
42
|
+
def page_context
|
|
43
|
+
self.select(&:page_context?)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# REturns only the site context items
|
|
47
|
+
#
|
|
48
|
+
# @return [Array]
|
|
49
|
+
def site_context
|
|
50
|
+
self.select(&:site_context?)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns all records that match the site id
|
|
54
|
+
#
|
|
55
|
+
# @return [Array]
|
|
56
|
+
def find_all_by_site_id(id)
|
|
57
|
+
self.select { |record| record.site_id == id.to_i }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Returns all records that match the category name
|
|
61
|
+
#
|
|
62
|
+
# @return [Array]
|
|
63
|
+
def find_all_by_category_name(name)
|
|
64
|
+
self.select { |record| record.category_name == name.to_s }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Returns all records that match the type name
|
|
68
|
+
#
|
|
69
|
+
# @return [Array]
|
|
70
|
+
def find_all_by_type_name(name)
|
|
71
|
+
self.select { |record| record.type_name == name.to_s }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns all records that match the status name
|
|
75
|
+
#
|
|
76
|
+
# @return [Array]
|
|
77
|
+
def find_all_by_status_name(name)
|
|
78
|
+
self.select { |record| record.status_name == name.to_s }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Retrieve a feed with the specified params and return
|
|
82
|
+
# the model as an instance of Feeds.
|
|
83
|
+
#
|
|
84
|
+
# @param site_id [String,Integer] The ID of the site for the feed
|
|
85
|
+
# @param max_feed_items [Integer] Max number of feed items
|
|
86
|
+
#
|
|
87
|
+
# @return [Nucleo::Models::Feeds]
|
|
88
|
+
def self.retrieve(site_id, params={})
|
|
89
|
+
response_body = Nucleo::Requests::Feed.retrieve(site_id, params)
|
|
90
|
+
|
|
91
|
+
self.new(response_body)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def each(&block)
|
|
95
|
+
internal_collection.each(&block)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Delegate sample to the array
|
|
99
|
+
#
|
|
100
|
+
# @todo: Ensure this delegates properly
|
|
101
|
+
#
|
|
102
|
+
# @return [Array]
|
|
103
|
+
def sample(n)
|
|
104
|
+
self.to_a.sample(n)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
def internal_collection
|
|
109
|
+
core_collection = []
|
|
110
|
+
@collection.inject(core_collection) do |collection,record|
|
|
111
|
+
const_name = ['nucleo', 'models', 'feed_types', record['category'], record['context'], record['type']].map(&:camelcase).join('::')
|
|
112
|
+
|
|
113
|
+
begin
|
|
114
|
+
collection.push(Object.const_get(const_name).new(record))
|
|
115
|
+
rescue
|
|
116
|
+
Nucleo::Client.configuration.logger.fatal("Could not instantiate %s" % [const_name])
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
collection
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
Array(core_collection)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require File.expand_path('../metric_periods', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Nucleo
|
|
4
|
+
module Models
|
|
5
|
+
class Metric
|
|
6
|
+
# Returns an instance of the Metric domain model. This is
|
|
7
|
+
# the core domain model for a specific metric `type` and
|
|
8
|
+
# `classification`.
|
|
9
|
+
#
|
|
10
|
+
# @param attributes [Hash]
|
|
11
|
+
#
|
|
12
|
+
# @return [Nucleo::Models::Metric]
|
|
13
|
+
def initialize(attributes={})
|
|
14
|
+
@attributes = attributes
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Returns the classification of the metric
|
|
18
|
+
#
|
|
19
|
+
# @return [String]
|
|
20
|
+
def classification
|
|
21
|
+
@attributes['classification']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns the type of the metric
|
|
25
|
+
#
|
|
26
|
+
# @return [String]
|
|
27
|
+
def metric
|
|
28
|
+
@attributes['metric']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the dimension
|
|
32
|
+
#
|
|
33
|
+
# @return [String]
|
|
34
|
+
def dimension
|
|
35
|
+
@attributes['dimension']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Returns the metric periods used for comparison
|
|
39
|
+
#
|
|
40
|
+
# @return [Nucleo::Models::MetricPeriods]
|
|
41
|
+
def metric_periods
|
|
42
|
+
params = {
|
|
43
|
+
'metric' => self.metric,
|
|
44
|
+
'dimension' => self.dimension,
|
|
45
|
+
'totals' => @attributes['totals'],
|
|
46
|
+
'current_period' => @attributes['current_period'],
|
|
47
|
+
'prior_period' => @attributes['prior_period']
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Nucleo::Models::MetricPeriods.new(params)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|