actv 1.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.
- data/.gitignore +30 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +64 -0
- data/Gemfile +4 -0
- data/Guardfile +20 -0
- data/LICENSE +22 -0
- data/README.md +63 -0
- data/Rakefile +17 -0
- data/actv.gemspec +34 -0
- data/lib/actv.rb +48 -0
- data/lib/actv/address.rb +9 -0
- data/lib/actv/article.rb +89 -0
- data/lib/actv/article_search_results.rb +15 -0
- data/lib/actv/asset.rb +186 -0
- data/lib/actv/asset_channel.rb +13 -0
- data/lib/actv/asset_component.rb +8 -0
- data/lib/actv/asset_description.rb +15 -0
- data/lib/actv/asset_description_type.rb +12 -0
- data/lib/actv/asset_image.rb +13 -0
- data/lib/actv/asset_legacy_data.rb +20 -0
- data/lib/actv/asset_price.rb +11 -0
- data/lib/actv/asset_seo_url.rb +5 -0
- data/lib/actv/asset_status.rb +17 -0
- data/lib/actv/asset_tag.rb +9 -0
- data/lib/actv/asset_topic.rb +11 -0
- data/lib/actv/base.rb +148 -0
- data/lib/actv/channel.rb +13 -0
- data/lib/actv/client.rb +330 -0
- data/lib/actv/configurable.rb +39 -0
- data/lib/actv/default.rb +87 -0
- data/lib/actv/error.rb +32 -0
- data/lib/actv/error/bad_gateway.rb +11 -0
- data/lib/actv/error/bad_request.rb +10 -0
- data/lib/actv/error/client_error.rb +39 -0
- data/lib/actv/error/enhance_your_calm.rb +10 -0
- data/lib/actv/error/forbidden.rb +10 -0
- data/lib/actv/error/internal_server_error.rb +11 -0
- data/lib/actv/error/not_acceptable.rb +10 -0
- data/lib/actv/error/not_found.rb +10 -0
- data/lib/actv/error/server_error.rb +19 -0
- data/lib/actv/error/service_unavailable.rb +11 -0
- data/lib/actv/error/unauthorized.rb +10 -0
- data/lib/actv/event.rb +213 -0
- data/lib/actv/event_result.rb +8 -0
- data/lib/actv/event_search_results.rb +11 -0
- data/lib/actv/evergreen.rb +53 -0
- data/lib/actv/facet.rb +16 -0
- data/lib/actv/facet_term.rb +5 -0
- data/lib/actv/facet_value.rb +7 -0
- data/lib/actv/identity.rb +28 -0
- data/lib/actv/interest.rb +39 -0
- data/lib/actv/null_object.rb +19 -0
- data/lib/actv/phone_number.rb +9 -0
- data/lib/actv/place.rb +24 -0
- data/lib/actv/popular_interest.rb +18 -0
- data/lib/actv/popular_interest_search_results.rb +12 -0
- data/lib/actv/request/multipart_with_file.rb +37 -0
- data/lib/actv/response/parse_json.rb +29 -0
- data/lib/actv/response/raise_client_error.rb +21 -0
- data/lib/actv/response/raise_server_error.rb +18 -0
- data/lib/actv/search_results.rb +30 -0
- data/lib/actv/sub_event.rb +15 -0
- data/lib/actv/tag.rb +9 -0
- data/lib/actv/topic.rb +9 -0
- data/lib/actv/user.rb +38 -0
- data/lib/actv/version.rb +3 -0
- data/spec/actv/article_search_results_spec.rb +16 -0
- data/spec/actv/article_spec.rb +44 -0
- data/spec/actv/asset_channel_spec.rb +17 -0
- data/spec/actv/asset_description_spec.rb +17 -0
- data/spec/actv/asset_image_spec.rb +27 -0
- data/spec/actv/asset_price_spec.rb +23 -0
- data/spec/actv/asset_spec.rb +172 -0
- data/spec/actv/asset_status_spec.rb +24 -0
- data/spec/actv/base_spec.rb +51 -0
- data/spec/actv/client/articles_spec.rb +130 -0
- data/spec/actv/client/assets_spec.rb +87 -0
- data/spec/actv/client/event_results_spec.rb +35 -0
- data/spec/actv/client/events_spec.rb +99 -0
- data/spec/actv/client/search_spec.rb +58 -0
- data/spec/actv/client/system_health_spec.rb +16 -0
- data/spec/actv/client/users_spec.rb +31 -0
- data/spec/actv/client_spec.rb +140 -0
- data/spec/actv/event_spec.rb +331 -0
- data/spec/actv/evergreen_spec.rb +33 -0
- data/spec/actv/identifiable_spec.rb +31 -0
- data/spec/actv/null_object_spec.rb +24 -0
- data/spec/actv/place_spec.rb +25 -0
- data/spec/actv/search_results_spec.rb +44 -0
- data/spec/actv/user_spec.rb +25 -0
- data/spec/actv_spec.rb +60 -0
- data/spec/faraday/response_spec.rb +0 -0
- data/spec/fixtures/me.json +21 -0
- data/spec/fixtures/system_health.json +1 -0
- data/spec/fixtures/valid_article.json +187 -0
- data/spec/fixtures/valid_asset.json +185 -0
- data/spec/fixtures/valid_event.json +188 -0
- data/spec/fixtures/valid_event_results.json +23 -0
- data/spec/fixtures/valid_evergreen.json +1 -0
- data/spec/fixtures/valid_evergreen_child_1.json +1 -0
- data/spec/fixtures/valid_search.json +1282 -0
- data/spec/fixtures/valid_search_no_event_results.json +5 -0
- data/spec/fixtures/valid_search_no_results.json +9 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/helper.rb +43 -0
- metadata +432 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.DS_Store
|
|
4
|
+
.bundle
|
|
5
|
+
.config
|
|
6
|
+
.yardoc
|
|
7
|
+
Gemfile.lock
|
|
8
|
+
InstalledFiles
|
|
9
|
+
_yardoc
|
|
10
|
+
coverage
|
|
11
|
+
doc/
|
|
12
|
+
lib/bundler/man
|
|
13
|
+
pkg
|
|
14
|
+
rdoc
|
|
15
|
+
spec/reports
|
|
16
|
+
test/tmp
|
|
17
|
+
test/version_tmp
|
|
18
|
+
tmp
|
|
19
|
+
.DS_Store
|
|
20
|
+
.rvmrc
|
|
21
|
+
|
|
22
|
+
/.idea/.rakeTasks
|
|
23
|
+
/.idea/active-a3pi-gem.iml
|
|
24
|
+
/.idea/encodings.xml
|
|
25
|
+
/.idea/misc.xml
|
|
26
|
+
/.idea/modules.xml
|
|
27
|
+
/.idea/scopes/scope_settings.xml
|
|
28
|
+
/.idea/vcs.xml
|
|
29
|
+
/.idea/workspace.xml
|
|
30
|
+
.idea/
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
actv
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-1.9.3-p194
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## Changelog
|
|
2
|
+
###v1.0.20
|
|
3
|
+
- Basic implementation of ACTV::Event
|
|
4
|
+
- Added ability to find events by Id
|
|
5
|
+
- Added ability to search for events
|
|
6
|
+
|
|
7
|
+
###v.1.0.12
|
|
8
|
+
- Add author_footer to ACTV::Article
|
|
9
|
+
- fixed author_image/author_bio on ACTV::Article to pull correct info
|
|
10
|
+
|
|
11
|
+
###v.1.0.10
|
|
12
|
+
- Implemented fix to get authentication to work correctly through HTTP Headers
|
|
13
|
+
|
|
14
|
+
###v.1.0.9
|
|
15
|
+
- Implemented user_name and display_name existence check
|
|
16
|
+
|
|
17
|
+
###v1.0.8
|
|
18
|
+
- Basic implementation of ACTV::PhoneNumber
|
|
19
|
+
- ACTV::User.phone_number returns a PhoneNumber object
|
|
20
|
+
- Implemented code to give the ability to update current user
|
|
21
|
+
|
|
22
|
+
###v1.0.7
|
|
23
|
+
- Basic implementation of ACTV::AssetTopic
|
|
24
|
+
- ACTV::Asset.topics returns an array of AssetTopics
|
|
25
|
+
|
|
26
|
+
###v1.0.6
|
|
27
|
+
- Basic implemenetation of ACTV::AssetPrice
|
|
28
|
+
- ACTV::Asset.prices returns an array of AssetPrices
|
|
29
|
+
- Added footer and inline_ad attribute to ACTV::Article
|
|
30
|
+
|
|
31
|
+
###v1.0.5
|
|
32
|
+
- Basic implementation of ACTV::AssetComponent
|
|
33
|
+
- ACTV::Asset.components returns an array of AssetComponents
|
|
34
|
+
- Added link and target to ACTV::AssetImage
|
|
35
|
+
|
|
36
|
+
###v1.0.4
|
|
37
|
+
- Basic implementation of ACTV::Article
|
|
38
|
+
- Added ability to find articles by Id
|
|
39
|
+
- Added ability to search for articles
|
|
40
|
+
- Added Summary and Description attributes to ACTV::Asset
|
|
41
|
+
- Basic implementation of ACTV::AssetTag
|
|
42
|
+
- Basic implementation of ACTV::Tag
|
|
43
|
+
- ACTV::Asset.tags returns an array of AssetTags
|
|
44
|
+
|
|
45
|
+
###v1.0.3
|
|
46
|
+
- Address now extends ACTV::Base instead of ACTV::Identity
|
|
47
|
+
|
|
48
|
+
### v1.0.2
|
|
49
|
+
- Basic implementation of ACTV::User
|
|
50
|
+
- Added method to return current user
|
|
51
|
+
- Added ability to search assets
|
|
52
|
+
- Basic implementation of ACTV::SearchResults
|
|
53
|
+
- Bubbling up client errors correctly
|
|
54
|
+
|
|
55
|
+
### v1.0.1
|
|
56
|
+
- New class ACTV::AssetImage
|
|
57
|
+
- ACTV::Asset.images returns an array of AssetImages
|
|
58
|
+
- Added method_missing and respond_to? to ACTV::Base to allow access to arbitrary attributes
|
|
59
|
+
|
|
60
|
+
### v1.0.0
|
|
61
|
+
- Basic ACTV::Asset implementation
|
|
62
|
+
- Basic Base object implementation
|
|
63
|
+
- HTTP Request implementation
|
|
64
|
+
|
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard 'rspec', :version => 2 do
|
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
6
|
+
watch(%r{^spec/support/.+_spec\.rb$})
|
|
7
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
8
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
9
|
+
|
|
10
|
+
# Lib
|
|
11
|
+
watch(%r{^lib/.+\.rb$}) { "spec" }
|
|
12
|
+
|
|
13
|
+
# Capybara request specs
|
|
14
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
|
15
|
+
|
|
16
|
+
# Turnip features and steps
|
|
17
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
18
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
19
|
+
end
|
|
20
|
+
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Active Network
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ACTV
|
|
2
|
+
|
|
3
|
+
A Ruby wrapper for The ACTIVE Network 3.0 API. You can get your v2
|
|
4
|
+
search API key at http://developer.active.com
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
gem 'actv'
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install actv
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
Require the gem, then configure the endpoint and your api key:
|
|
23
|
+
|
|
24
|
+
ACTV.configure do |config|
|
|
25
|
+
config.endpoint = "http://api.amp.active.com"
|
|
26
|
+
config.api_key = "YOUR_API_KEY"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
## Usage Examples
|
|
30
|
+
|
|
31
|
+
Search for Running
|
|
32
|
+
|
|
33
|
+
ACTV.search('Running')
|
|
34
|
+
|
|
35
|
+
Return an Asset with Id of 12345678-9012-3456-7890-123456789012
|
|
36
|
+
|
|
37
|
+
ACTV.asset('12345678-9012-3456-7890-123456789012')
|
|
38
|
+
|
|
39
|
+
Search for Swimming Articles
|
|
40
|
+
|
|
41
|
+
ACTV.articles('Swimming')
|
|
42
|
+
|
|
43
|
+
Return an Article with Id of 12345678-9012-3456-7890-123456789012
|
|
44
|
+
|
|
45
|
+
ACTV.article('12345678-9012-3456-7890-123456789012')
|
|
46
|
+
|
|
47
|
+
Certain methods require authentication. You need to instantiate a Client object with a valid acceess token
|
|
48
|
+
|
|
49
|
+
@actv = ACTV::Client.new({
|
|
50
|
+
oauth_token: session[:access_token]
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
Get the requested current user
|
|
54
|
+
|
|
55
|
+
@actv.me
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
1. Fork it
|
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
61
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
63
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
require 'bundler'
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Bundler::GemHelper.install_tasks
|
|
7
|
+
|
|
8
|
+
require 'rspec/core/rake_task'
|
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
10
|
+
|
|
11
|
+
task :test => :spec
|
|
12
|
+
task :default => :spec
|
|
13
|
+
|
|
14
|
+
require 'yard'
|
|
15
|
+
YARD::Rake::YardocTask.new
|
|
16
|
+
|
|
17
|
+
task :default => :spec
|
data/actv.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/actv/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.add_dependency 'faraday', '~> 0.8'
|
|
6
|
+
gem.add_dependency 'multi_json', '~> 1.3'
|
|
7
|
+
gem.add_dependency 'simple_oauth', '~> 0.1.6'
|
|
8
|
+
gem.add_development_dependency 'json'
|
|
9
|
+
gem.add_development_dependency 'maruku'
|
|
10
|
+
gem.add_development_dependency 'pry'
|
|
11
|
+
gem.add_development_dependency 'rake'
|
|
12
|
+
gem.add_development_dependency 'rspec'
|
|
13
|
+
gem.add_development_dependency 'simplecov'
|
|
14
|
+
gem.add_development_dependency 'timecop'
|
|
15
|
+
gem.add_development_dependency 'webmock'
|
|
16
|
+
gem.add_development_dependency 'yard'
|
|
17
|
+
gem.add_development_dependency 'guard-rspec'
|
|
18
|
+
gem.add_development_dependency 'nokogiri'
|
|
19
|
+
gem.add_development_dependency 'active_support'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
gem.authors = ["Nathaniel Barnes"]
|
|
23
|
+
gem.email = ["Nathaniel.Barnes@activenetwork.com"]
|
|
24
|
+
gem.description = %q{A Ruby wrapper for the Active API}
|
|
25
|
+
gem.summary = %q{Active API}
|
|
26
|
+
gem.homepage = ""
|
|
27
|
+
|
|
28
|
+
gem.files = `git ls-files`.split($\)
|
|
29
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
30
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
31
|
+
gem.name = "actv"
|
|
32
|
+
gem.require_paths = ["lib"]
|
|
33
|
+
gem.version = ACTV::VERSION
|
|
34
|
+
end
|
data/lib/actv.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "actv/base"
|
|
2
|
+
require 'actv/client'
|
|
3
|
+
require 'actv/configurable'
|
|
4
|
+
require 'actv/default'
|
|
5
|
+
|
|
6
|
+
module ACTV
|
|
7
|
+
class << self
|
|
8
|
+
include ACTV::Configurable
|
|
9
|
+
|
|
10
|
+
# Delegate to a ACTV::Client
|
|
11
|
+
#
|
|
12
|
+
# @return [ACTV::Client]
|
|
13
|
+
def client
|
|
14
|
+
ACTV::Client.new(options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def options
|
|
18
|
+
@options = {}
|
|
19
|
+
ACTV::Configurable.keys.each do |key|
|
|
20
|
+
@options[key] = instance_variable_get("@#{key}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
@options
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def respond_to?(method, include_private=false)
|
|
27
|
+
self.client.respond_to?(method, include_private) || super
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def reset!
|
|
31
|
+
ACTV::Configurable.keys.each do |key|
|
|
32
|
+
instance_variable_set("@#{key}", ACTV::Default.options[key])
|
|
33
|
+
end
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
alias setup reset!
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def method_missing(method, *args, &block)
|
|
41
|
+
return super unless self.client.respond_to?(method)
|
|
42
|
+
self.client.send(method, *args, &block)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
ACTV.setup
|
data/lib/actv/address.rb
ADDED
data/lib/actv/article.rb
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'actv/asset'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
|
|
4
|
+
module ACTV
|
|
5
|
+
class Article < ACTV::Asset
|
|
6
|
+
|
|
7
|
+
def author_footer
|
|
8
|
+
@author_footer ||= description_by_type 'authorFooter'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def by_line
|
|
12
|
+
@author ||= description_by_type 'articleByLine'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def author_bio
|
|
16
|
+
@author_bio ||= begin
|
|
17
|
+
bio_node = get_from_author_footer('div.author-text')
|
|
18
|
+
bio_node.inner_html unless bio_node.nil?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def author_photo
|
|
23
|
+
@author_photo ||= begin
|
|
24
|
+
image = nil
|
|
25
|
+
|
|
26
|
+
image_node = get_from_author_footer('div.signature-block-photo img')
|
|
27
|
+
if !image_node.nil?
|
|
28
|
+
image = ACTV::AssetImage.new({imageUrlAdr: image_node.attribute('src').text}) if image_node.attribute 'src'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
image
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def author_name_from_footer
|
|
36
|
+
@author_name_from_footer ||= begin
|
|
37
|
+
name_node = get_from_author_footer('span.author-name')
|
|
38
|
+
name_node.text unless name_node.nil?
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def source
|
|
43
|
+
@source ||= description_by_type 'articleSource'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def type
|
|
47
|
+
@type ||= tag_by_description 'articleType'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def image
|
|
51
|
+
@image ||= image_by_name 'image2'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def subtitle
|
|
55
|
+
@subtitle ||= description_by_type 'subtitle'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def footer
|
|
59
|
+
@footer ||= description_by_type 'footer'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def inline_ad
|
|
63
|
+
@inline_ad ||= begin
|
|
64
|
+
val = tag_by_description 'inlinead'
|
|
65
|
+
if val
|
|
66
|
+
val.downcase == 'true'
|
|
67
|
+
else
|
|
68
|
+
true
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
alias inline_ad? inline_ad
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def get_from_author_footer(selector)
|
|
77
|
+
node = nil
|
|
78
|
+
|
|
79
|
+
if !author_footer.nil? && !author_footer.empty?
|
|
80
|
+
doc = Nokogiri::HTML(author_footer)
|
|
81
|
+
node = doc.css(selector).first
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
node
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'actv/search_results'
|
|
2
|
+
|
|
3
|
+
module ACTV
|
|
4
|
+
class ArticleSearchResults < ACTV::SearchResults
|
|
5
|
+
def results
|
|
6
|
+
@results ||= Array(@attrs[:results]).map do |event|
|
|
7
|
+
ACTV::Article.new(event)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def first_article? art
|
|
12
|
+
results.first == art
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/actv/asset.rb
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
require 'actv/asset_channel'
|
|
2
|
+
require 'actv/asset_component'
|
|
3
|
+
require 'actv/asset_description'
|
|
4
|
+
require 'actv/asset_image'
|
|
5
|
+
require 'actv/asset_legacy_data'
|
|
6
|
+
require 'actv/asset_price'
|
|
7
|
+
require 'actv/asset_status'
|
|
8
|
+
require 'actv/asset_tag'
|
|
9
|
+
require 'actv/asset_topic'
|
|
10
|
+
require 'actv/asset_seo_url'
|
|
11
|
+
require 'actv/identity'
|
|
12
|
+
require 'actv/place'
|
|
13
|
+
|
|
14
|
+
module ACTV
|
|
15
|
+
class Asset < ACTV::Identity
|
|
16
|
+
|
|
17
|
+
attr_reader :assetGuid, :assetName, :assetDsc, :activityStartDate, :activityStartTime, :activityEndDate, :activityEndTime,
|
|
18
|
+
:homePageUrlAdr, :isRecurring, :contactName, :contactEmailAdr, :contactPhone, :showContact, :publishDate, :createdDate, :modifiedDate,
|
|
19
|
+
:authorName, :is_event, :is_article
|
|
20
|
+
|
|
21
|
+
alias id assetGuid
|
|
22
|
+
alias title assetName
|
|
23
|
+
alias start_date activityStartDate
|
|
24
|
+
alias start_time activityStartTime
|
|
25
|
+
alias end_date activityEndDate
|
|
26
|
+
alias end_time activityEndTime
|
|
27
|
+
alias home_page_url homePageUrlAdr
|
|
28
|
+
alias is_recurring? isRecurring
|
|
29
|
+
alias contact_name contactName
|
|
30
|
+
alias contact_email contactEmailAdr
|
|
31
|
+
alias contact_phone contactPhone
|
|
32
|
+
alias show_contact? showContact
|
|
33
|
+
alias published_at publishDate
|
|
34
|
+
alias created_at createdDate
|
|
35
|
+
alias updated_at modifiedDate
|
|
36
|
+
alias author_name authorName
|
|
37
|
+
|
|
38
|
+
def place
|
|
39
|
+
@place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def place_timezone
|
|
43
|
+
@timezone ||= place[:timezone] unless place[:timezone].nil?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def descriptions
|
|
47
|
+
@descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
|
|
48
|
+
ACTV::AssetDescription.new(description)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
alias asset_descriptions descriptions
|
|
52
|
+
alias assetDescriptions descriptions
|
|
53
|
+
|
|
54
|
+
def status
|
|
55
|
+
@status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
|
|
56
|
+
end
|
|
57
|
+
alias asset_status status
|
|
58
|
+
alias assetStatus status
|
|
59
|
+
|
|
60
|
+
def legacy_data
|
|
61
|
+
@legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
|
|
62
|
+
end
|
|
63
|
+
alias asset_legacy_data legacy_data
|
|
64
|
+
alias assetLegacyData legacy_data
|
|
65
|
+
|
|
66
|
+
def channels
|
|
67
|
+
@asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
|
|
68
|
+
ACTV::AssetChannel.new(channel)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
alias asset_channels channels
|
|
72
|
+
alias assetChannels channels
|
|
73
|
+
|
|
74
|
+
def images
|
|
75
|
+
@images ||= Array(@attrs[:assetImages]).map do |img|
|
|
76
|
+
ACTV::AssetImage.new(img)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
alias asset_images images
|
|
80
|
+
alias assetImages images
|
|
81
|
+
|
|
82
|
+
def tags
|
|
83
|
+
@asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
|
|
84
|
+
ACTV::AssetTag.new(tag)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
alias asset_tags tags
|
|
88
|
+
alias assetTags tags
|
|
89
|
+
|
|
90
|
+
def components
|
|
91
|
+
@asset_components ||= Array(@attrs[:assetComponents]).map do |component|
|
|
92
|
+
ACTV::AssetComponent.new(component)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
alias asset_components components
|
|
96
|
+
alias assetComponents components
|
|
97
|
+
|
|
98
|
+
def prices
|
|
99
|
+
@asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
|
|
100
|
+
ACTV::AssetPrice.new(price)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
alias asset_prices prices
|
|
104
|
+
alias assetPrices prices
|
|
105
|
+
|
|
106
|
+
def topics
|
|
107
|
+
@asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
|
|
108
|
+
ACTV::AssetTopic.new(topic)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
alias asset_topics topics
|
|
112
|
+
alias assetTopics topics
|
|
113
|
+
|
|
114
|
+
def seo_urls
|
|
115
|
+
@seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
|
|
116
|
+
ACTV::AssetSeoUrl.new(seo_url)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
alias asset_seo_urls seo_urls
|
|
120
|
+
alias assetSeoUrls seo_urls
|
|
121
|
+
|
|
122
|
+
def summary
|
|
123
|
+
@summary ||= description_by_type 'summary'
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def description
|
|
127
|
+
@description ||= description_by_type 'Standard'
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def seo_url(systemName = 'as3')
|
|
131
|
+
seo_url = self.seo_urls.find { |s| s.seoSystemName.downcase == systemName.downcase }
|
|
132
|
+
seo_url.urlAdr unless seo_url.nil?
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def description_by_type(type)
|
|
136
|
+
dsc = self.descriptions.find { |dsc| dsc.type.name.downcase == type.downcase }
|
|
137
|
+
(dsc.description.downcase == 'n/a' ? '' : dsc.description) if dsc
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def image_by_name(name)
|
|
141
|
+
self.images.find { |img| img.name.downcase == name.downcase }
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def tag_by_description(description)
|
|
145
|
+
asset_tag = self.tags.find { |at| at.tag.description.downcase == description.downcase }
|
|
146
|
+
asset_tag.tag.name if asset_tag
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def is_event?
|
|
150
|
+
self.assetCategories.each do |category|
|
|
151
|
+
if category[:category][:categoryTaxonomy].downcase.start_with?('event')
|
|
152
|
+
return true
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
false
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def is_article?
|
|
159
|
+
is_article = false
|
|
160
|
+
if self.assetCategories.any?
|
|
161
|
+
self.assetCategories.each do |category|
|
|
162
|
+
if category[:category][:categoryName].downcase == 'articles'
|
|
163
|
+
is_article = true
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
else
|
|
167
|
+
# no categories so check the sourceSystem
|
|
168
|
+
# this guid is equal to the Active.com Articles
|
|
169
|
+
if self.sourceSystem.fetch(:legacyGuid, "").upcase == "CA4EA0B1-7377-470D-B20D-BF6BEA23F040"
|
|
170
|
+
is_article = true
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
is_article
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def evergreen?
|
|
178
|
+
self.evergreenAssetFlag.downcase == 'true' rescue false
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def registration_status
|
|
182
|
+
@registration_status ||= nil
|
|
183
|
+
end
|
|
184
|
+
alias reg_status registration_status
|
|
185
|
+
end
|
|
186
|
+
end
|