7digital 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -7
- data/lib/sevendigital.rb +54 -53
- data/lib/sevendigital/api_operator.rb +33 -30
- data/lib/sevendigital/api_operator_cached.rb +23 -23
- data/lib/sevendigital/api_request.rb +23 -23
- data/lib/sevendigital/client.rb +136 -124
- data/lib/sevendigital/default_configuration.yml +2 -2
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +31 -31
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +27 -27
- data/lib/sevendigital/digestion_tract/digestor.rb +66 -66
- data/lib/sevendigital/digestion_tract/format_digestor.rb +21 -21
- data/lib/sevendigital/digestion_tract/label_digestor.rb +19 -19
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/price_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/release_digestor.rb +52 -52
- data/lib/sevendigital/digestion_tract/track_digestor.rb +37 -37
- data/lib/sevendigital/management/artist_manager.rb +45 -39
- data/lib/sevendigital/management/manager.rb +11 -11
- data/lib/sevendigital/management/release_manager.rb +57 -50
- data/lib/sevendigital/management/track_manager.rb +28 -17
- data/lib/sevendigital/model/api_response.rb +24 -12
- data/lib/sevendigital/model/artist.rb +46 -36
- data/lib/sevendigital/model/chart_item.rb +9 -9
- data/lib/sevendigital/model/format.rb +9 -9
- data/lib/sevendigital/model/label.rb +9 -9
- data/lib/sevendigital/model/price.rb +11 -11
- data/lib/sevendigital/model/release.rb +33 -33
- data/lib/sevendigital/model/sevendigital_error.rb +3 -3
- data/lib/sevendigital/model/sevendigital_object.rb +51 -51
- data/lib/sevendigital/model/track.rb +28 -7
- data/lib/sevendigital/pager.rb +16 -16
- data/lib/sevendigital/peachy_patch.rb +19 -0
- data/lib/sevendigital/proxy_police.rb +23 -23
- data/spec/api_operator_cached_spec.rb +47 -46
- data/spec/api_operator_spec.rb +114 -107
- data/spec/api_request_spec.rb +26 -27
- data/spec/client_spec.rb +75 -45
- data/spec/data/config/sevendigital.yml +5 -5
- data/spec/data/configuration_env_override.yml +5 -5
- data/spec/digestion_tract/api_response_digestor_spec.rb +78 -74
- data/spec/digestion_tract/artist_digestor_spec.rb +81 -82
- data/spec/digestion_tract/chart_digestor_spec.rb +52 -53
- data/spec/digestion_tract/format_digestor_spec.rb +38 -39
- data/spec/digestion_tract/label_digestor_spec.rb +33 -34
- data/spec/digestion_tract/pager_digestor_spec.rb +50 -51
- data/spec/digestion_tract/price_digestor_spec.rb +57 -57
- data/spec/digestion_tract/release_digestor_spec.rb +101 -102
- data/spec/digestion_tract/track_digestor_spec.rb +104 -106
- data/spec/management/artist_manager_spec.rb +128 -107
- data/spec/management/release_manager_spec.rb +222 -178
- data/spec/management/track_manager_spec.rb +88 -52
- data/spec/model/api_response_spec.rb +44 -31
- data/spec/model/artist_spec.rb +166 -121
- data/spec/model/release_spec.rb +109 -110
- data/spec/model/track_spec.rb +140 -0
- data/spec/pager_spec.rb +7 -8
- data/spec/peachy_spec_helper_patch.rb +7 -0
- data/spec/proxy_police_spec.rb +47 -48
- data/spec/spec_helper.rb +52 -48
- data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
- data/spec/test-xml/methods/artist/details.xml +9 -9
- data/spec/test-xml/methods/artist/releases.xml +544 -544
- data/spec/test-xml/methods/artist/search.xml +19 -0
- data/spec/test-xml/methods/artist/similar.xml +39 -39
- data/spec/test-xml/methods/artist/toptracks.xml +279 -279
- data/spec/test-xml/methods/release/bydate.xml +173 -173
- data/spec/test-xml/methods/release/bytag/top.xml +150 -150
- data/spec/test-xml/methods/release/chart.xml +181 -181
- data/spec/test-xml/methods/release/details.xml +48 -48
- data/spec/test-xml/methods/release/recommend.xml +89 -89
- data/spec/test-xml/methods/release/search.xml +195 -0
- data/spec/test-xml/methods/release/tracks.xml +28 -28
- data/spec/test-xml/methods/track/chart.xml +149 -149
- data/spec/test-xml/methods/track/details.xml +30 -30
- data/spec/test-xml/methods/track/search.xml +160 -0
- data/spec/test-xml/objects/artist.xml +6 -6
- data/spec/test-xml/objects/artist_chart_item.xml +7 -7
- data/spec/test-xml/objects/artist_list.xml +22 -22
- data/spec/test-xml/objects/artist_list_empty.xml +4 -4
- data/spec/test-xml/objects/price.xml +7 -7
- data/spec/test-xml/objects/release.xml +40 -40
- data/spec/test-xml/objects/release_chart_item.xml +39 -34
- data/spec/test-xml/objects/release_list.xml +18 -18
- data/spec/test-xml/objects/release_list_empty.xml +4 -4
- data/spec/test-xml/objects/response.xml +39 -0
- data/spec/test-xml/objects/track.xml +33 -33
- data/spec/test-xml/objects/track_chart_item.xml +27 -27
- metadata +10 -5
- data/lib/peachy_patchy.rb +0 -14
- data/lib/sevendigital/version.rb +0 -3
data/README.rdoc
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
Ruby wrapper for 7digital API
|
2
|
-
|
3
|
-
Example usage:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
Ruby wrapper for 7digital API
|
2
|
+
|
3
|
+
Example usage:
|
4
|
+
require "sevendigital"
|
5
|
+
|
6
|
+
sevendigital_client = Sevendigital::Client.new(:oauth_consumer_key => "YOUR_KEY_HERE", :country => "GB")
|
7
|
+
artist = sevendigital_client.artist.get_details(1)
|
8
|
+
puts artist.name
|
9
|
+
|
data/lib/sevendigital.rb
CHANGED
@@ -1,53 +1,54 @@
|
|
1
|
-
|
2
|
-
module Sevendigital
|
3
|
-
|
4
|
-
# :stopdoc:
|
5
|
-
VERSION = '0.0.1'
|
6
|
-
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
7
|
-
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
8
|
-
# :startdoc:
|
9
|
-
|
10
|
-
# Returns the version string for the library.
|
11
|
-
#
|
12
|
-
def self.version
|
13
|
-
VERSION
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns the library path for the module. If any arguments are given,
|
17
|
-
# they will be joined to the end of the libray path using
|
18
|
-
# <tt>File.join</tt>.
|
19
|
-
#
|
20
|
-
def self.libpath( *args )
|
21
|
-
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns the lpath for the module. If any arguments are given,
|
25
|
-
# they will be joined to the end of the path using
|
26
|
-
# <tt>File.join</tt>.
|
27
|
-
#
|
28
|
-
def self.path( *args )
|
29
|
-
args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Utility method used to require all files ending in .rb that lie in the
|
33
|
-
# directory below this file that has the same name as the filename passed
|
34
|
-
# in. Optionally, a specific _directory_ name can be passed in such that
|
35
|
-
# the _filename_ does not have to be equivalent to the directory.
|
36
|
-
#
|
37
|
-
def self.require_all_libs_relative_to( fname, dir = nil )
|
38
|
-
dir ||= ::File.basename(fname, '.*')
|
39
|
-
search_me = ::File.expand_path(
|
40
|
-
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
41
|
-
|
42
|
-
Dir.glob(search_me).sort.each {|rb| require rb }
|
43
|
-
end
|
44
|
-
|
45
|
-
end # module 7digital
|
46
|
-
|
47
|
-
require 'peachy'
|
48
|
-
require File.join( File.dirname( File.expand_path(__FILE__)), '
|
49
|
-
|
50
|
-
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', '
|
51
|
-
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', '
|
52
|
-
|
53
|
-
|
1
|
+
|
2
|
+
module Sevendigital
|
3
|
+
|
4
|
+
# :stopdoc:
|
5
|
+
VERSION = '0.0.1'
|
6
|
+
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
7
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
8
|
+
# :startdoc:
|
9
|
+
|
10
|
+
# Returns the version string for the library.
|
11
|
+
#
|
12
|
+
def self.version
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the library path for the module. If any arguments are given,
|
17
|
+
# they will be joined to the end of the libray path using
|
18
|
+
# <tt>File.join</tt>.
|
19
|
+
#
|
20
|
+
def self.libpath( *args )
|
21
|
+
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the lpath for the module. If any arguments are given,
|
25
|
+
# they will be joined to the end of the path using
|
26
|
+
# <tt>File.join</tt>.
|
27
|
+
#
|
28
|
+
def self.path( *args )
|
29
|
+
args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Utility method used to require all files ending in .rb that lie in the
|
33
|
+
# directory below this file that has the same name as the filename passed
|
34
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
35
|
+
# the _filename_ does not have to be equivalent to the directory.
|
36
|
+
#
|
37
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
38
|
+
dir ||= ::File.basename(fname, '.*')
|
39
|
+
search_me = ::File.expand_path(
|
40
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
41
|
+
|
42
|
+
Dir.glob(search_me).sort.each {|rb| require rb }
|
43
|
+
end
|
44
|
+
|
45
|
+
end # module 7digital
|
46
|
+
|
47
|
+
require 'peachy'
|
48
|
+
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'peachy_patch')
|
49
|
+
Peachy.be_quiet
|
50
|
+
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'management', 'manager')
|
51
|
+
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'digestion_tract', 'digestor')
|
52
|
+
require File.join( File.dirname( File.expand_path(__FILE__)), 'sevendigital', 'model', 'sevendigital_object')
|
53
|
+
Sevendigital.require_all_libs_relative_to(__FILE__)
|
54
|
+
|
@@ -1,31 +1,34 @@
|
|
1
|
-
module Sevendigital
|
2
|
-
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
class ApiOperator
|
6
|
-
|
7
|
-
def initialize(client)
|
8
|
-
@client = client
|
9
|
-
end
|
10
|
-
|
11
|
-
def call_api(api_request)
|
12
|
-
make_http_request_and_digest(create_request_uri(api_request))
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
class ApiOperator
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def call_api(api_request)
|
12
|
+
api_response = make_http_request_and_digest(create_request_uri(api_request))
|
13
|
+
puts api_response if @client.very_verbose?
|
14
|
+
api_response
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_http_request_and_digest(uri)
|
18
|
+
puts "ApiOperator: Calling #{uri}" if @client.verbose?
|
19
|
+
http_response = Net::HTTP.get_response(uri)
|
20
|
+
api_response = @client.api_response_digestor.from_http_response(http_response)
|
21
|
+
raise Sevendigital::SevendigitalError, "#{api_response.error_code} - #{api_response.error_message}" if !api_response.ok?
|
22
|
+
api_response
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_request_uri(api_request)
|
26
|
+
api_request.ensure_country_is_set(@client.country)
|
27
|
+
params = api_request.parameters.collect{ |a,v| "&#{a}=#{v}" }.join
|
28
|
+
URI.parse("http://#{@client.configuration.api_url}/#{@client.configuration.api_version}/#{api_request.api_method}"+
|
29
|
+
"?oauth_consumer_key=#{@client.configuration.oauth_consumer_key}#{params}")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
31
34
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
module Sevendigital
|
2
|
-
|
3
|
-
class ApiOperatorCached < ApiOperator
|
4
|
-
|
5
|
-
def initialize(client, cache)
|
6
|
-
@cache = cache
|
7
|
-
super(client)
|
8
|
-
end
|
9
|
-
|
10
|
-
def call_api(api_request)
|
11
|
-
uri = create_request_uri(api_request)
|
12
|
-
api_response = @cache.get(uri.to_s)
|
13
|
-
|
14
|
-
if (!api_response) then
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
api_response
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class ApiOperatorCached < ApiOperator
|
4
|
+
|
5
|
+
def initialize(client, cache)
|
6
|
+
@cache = cache
|
7
|
+
super(client)
|
8
|
+
end
|
9
|
+
|
10
|
+
def call_api(api_request)
|
11
|
+
uri = create_request_uri(api_request)
|
12
|
+
api_response = @cache.get(uri.to_s)
|
13
|
+
puts "ApiOperatorCached: Got from cache #{uri}" if api_response if @client.verbose?
|
14
|
+
if (!api_response) then
|
15
|
+
api_response = make_http_request_and_digest(uri)
|
16
|
+
@cache.set(uri.to_s, api_response)
|
17
|
+
end
|
18
|
+
puts api_response if @client.very_verbose?
|
19
|
+
api_response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
module Sevendigital
|
2
|
-
|
3
|
-
class ApiRequest
|
4
|
-
|
5
|
-
attr_reader :api_method, :parameters
|
6
|
-
|
7
|
-
def initialize(api_method, parameters, options = {})
|
8
|
-
@api_method = api_method
|
9
|
-
@parameters = comb_parameters(options.merge(parameters))
|
10
|
-
end
|
11
|
-
|
12
|
-
def comb_parameters(parameters)
|
13
|
-
page_size = parameters[:page_size] || parameters[:per_page]
|
14
|
-
parameters[:pageSize] ||= page_size if page_size
|
15
|
-
return parameters
|
16
|
-
end
|
17
|
-
|
18
|
-
def ensure_country_is_set(country)
|
19
|
-
@parameters[:country] ||= country
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
1
|
+
module Sevendigital
|
2
|
+
|
3
|
+
class ApiRequest
|
4
|
+
|
5
|
+
attr_reader :api_method, :parameters
|
6
|
+
|
7
|
+
def initialize(api_method, parameters, options = {})
|
8
|
+
@api_method = api_method
|
9
|
+
@parameters = comb_parameters(options.merge(parameters))
|
10
|
+
end
|
11
|
+
|
12
|
+
def comb_parameters(parameters)
|
13
|
+
page_size = parameters[:page_size] || parameters[:per_page]
|
14
|
+
parameters[:pageSize] ||= page_size if page_size
|
15
|
+
return parameters
|
16
|
+
end
|
17
|
+
|
18
|
+
def ensure_country_is_set(country)
|
19
|
+
@parameters[:country] ||= country
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
24
|
end
|
data/lib/sevendigital/client.rb
CHANGED
@@ -1,124 +1,136 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
|
5
|
-
module Sevendigital
|
6
|
-
|
7
|
-
DEFAULT_CONFIGURATION = {
|
8
|
-
:api_url => "api.7digital.com",
|
9
|
-
:api_version => "1.2"
|
10
|
-
}
|
11
|
-
|
12
|
-
class Client
|
13
|
-
|
14
|
-
def load_configuration_from_yml(file_name, environment=nil)
|
15
|
-
plain_settings = YAML.load_file(file_name)
|
16
|
-
if (plain_settings["common"] || (environment && plain_settings[environment])) then
|
17
|
-
environment_settings = plain_settings["common"] || {}
|
18
|
-
environment_settings.update(plain_settings[environment]) if environment
|
19
|
-
environment_settings
|
20
|
-
else
|
21
|
-
plain_settings
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_configurations(configuration)
|
26
|
-
|
27
|
-
default_settings = Sevendigital::DEFAULT_CONFIGURATION
|
28
|
-
|
29
|
-
if (configuration.kind_of? String) then
|
30
|
-
yml_configuration_file = configuration
|
31
|
-
else
|
32
|
-
yml_configuration_file ="#{RAILS_ROOT}/config/sevendigital.yml" if defined?(RAILS_ROOT)
|
33
|
-
explicit_settings = configuration if configuration.kind_of? Hash
|
34
|
-
explicit_settings = configuration.marshal_dump if configuration.kind_of? OpenStruct
|
35
|
-
end
|
36
|
-
|
37
|
-
environment = defined?(RAILS_ENV) ? RAILS_ENV : nil
|
38
|
-
yml_settings = load_configuration_from_yml(yml_configuration_file, environment) if yml_configuration_file
|
39
|
-
|
40
|
-
settings = default_settings
|
41
|
-
settings.update(yml_settings) if yml_settings
|
42
|
-
settings.update(explicit_settings) if explicit_settings
|
43
|
-
|
44
|
-
return OpenStruct.new(settings)
|
45
|
-
end
|
46
|
-
|
47
|
-
#Code here
|
48
|
-
|
49
|
-
def initialize(configuration=nil, api_operator=nil)
|
50
|
-
@configuration = load_configurations(configuration)
|
51
|
-
@api_operator = api_operator || hire_api_operator
|
52
|
-
end
|
53
|
-
|
54
|
-
def hire_api_operator
|
55
|
-
@configuration.cache ? ApiOperatorCached.new(self, @configuration.cache) : ApiOperator.new(self)
|
56
|
-
end
|
57
|
-
|
58
|
-
def artist
|
59
|
-
@artist_manager ||= ArtistManager.new(self)
|
60
|
-
end
|
61
|
-
|
62
|
-
def artist_digestor
|
63
|
-
@artist_digestor ||= ArtistDigestor.new(self)
|
64
|
-
end
|
65
|
-
|
66
|
-
def release
|
67
|
-
@release_manager ||= ReleaseManager.new(self)
|
68
|
-
end
|
69
|
-
|
70
|
-
def release_digestor
|
71
|
-
@release_digestor ||= ReleaseDigestor.new(self)
|
72
|
-
end
|
73
|
-
|
74
|
-
def label_digestor
|
75
|
-
@label_digestor ||= LabelDigestor.new(self)
|
76
|
-
end
|
77
|
-
|
78
|
-
def format_digestor
|
79
|
-
@format_digestor ||= FormatDigestor.new(self)
|
80
|
-
end
|
81
|
-
|
82
|
-
def price_digestor
|
83
|
-
@price_digestor ||= PriceDigestor.new(self)
|
84
|
-
end
|
85
|
-
|
86
|
-
def pager_digestor
|
87
|
-
@pager_digestor ||= PagerDigestor.new(self)
|
88
|
-
end
|
89
|
-
|
90
|
-
def track
|
91
|
-
@track_manager ||= TrackManager.new(self)
|
92
|
-
end
|
93
|
-
|
94
|
-
def track_digestor
|
95
|
-
@track_digestor ||= TrackDigestor.new(self)
|
96
|
-
end
|
97
|
-
|
98
|
-
def api_response_digestor
|
99
|
-
@api_response_digestor ||= ApiResponseDigestor.new(self)
|
100
|
-
end
|
101
|
-
|
102
|
-
def chart_item_digestor
|
103
|
-
@chart_item_digestor ||= ChartItemDigestor.new(self)
|
104
|
-
end
|
105
|
-
|
106
|
-
def configuration
|
107
|
-
return @configuration
|
108
|
-
end
|
109
|
-
|
110
|
-
def operator
|
111
|
-
@api_operator
|
112
|
-
end
|
113
|
-
|
114
|
-
def country
|
115
|
-
@country || @configuration.country
|
116
|
-
end
|
117
|
-
|
118
|
-
def country=(country_code)
|
119
|
-
@country = country_code
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
end
|
1
|
+
require 'ostruct'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
|
5
|
+
module Sevendigital
|
6
|
+
|
7
|
+
DEFAULT_CONFIGURATION = {
|
8
|
+
:api_url => "api.7digital.com",
|
9
|
+
:api_version => "1.2"
|
10
|
+
}
|
11
|
+
|
12
|
+
class Client
|
13
|
+
|
14
|
+
def load_configuration_from_yml(file_name, environment=nil)
|
15
|
+
plain_settings = YAML.load_file(file_name)
|
16
|
+
if (plain_settings["common"] || (environment && plain_settings[environment])) then
|
17
|
+
environment_settings = plain_settings["common"] || {}
|
18
|
+
environment_settings.update(plain_settings[environment]) if environment
|
19
|
+
environment_settings
|
20
|
+
else
|
21
|
+
plain_settings
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_configurations(configuration)
|
26
|
+
|
27
|
+
default_settings = Sevendigital::DEFAULT_CONFIGURATION
|
28
|
+
|
29
|
+
if (configuration.kind_of? String) then
|
30
|
+
yml_configuration_file = configuration
|
31
|
+
else
|
32
|
+
yml_configuration_file ="#{RAILS_ROOT}/config/sevendigital.yml" if defined?(RAILS_ROOT)
|
33
|
+
explicit_settings = configuration if configuration.kind_of? Hash
|
34
|
+
explicit_settings = configuration.marshal_dump if configuration.kind_of? OpenStruct
|
35
|
+
end
|
36
|
+
|
37
|
+
environment = defined?(RAILS_ENV) ? RAILS_ENV : nil
|
38
|
+
yml_settings = load_configuration_from_yml(yml_configuration_file, environment) if yml_configuration_file
|
39
|
+
|
40
|
+
settings = default_settings
|
41
|
+
settings.update(yml_settings) if yml_settings
|
42
|
+
settings.update(explicit_settings) if explicit_settings
|
43
|
+
|
44
|
+
return OpenStruct.new(settings)
|
45
|
+
end
|
46
|
+
|
47
|
+
#Code here
|
48
|
+
|
49
|
+
def initialize(configuration=nil, api_operator=nil)
|
50
|
+
@configuration = load_configurations(configuration)
|
51
|
+
@api_operator = api_operator || hire_api_operator
|
52
|
+
end
|
53
|
+
|
54
|
+
def hire_api_operator
|
55
|
+
@configuration.cache ? ApiOperatorCached.new(self, @configuration.cache) : ApiOperator.new(self)
|
56
|
+
end
|
57
|
+
|
58
|
+
def artist
|
59
|
+
@artist_manager ||= ArtistManager.new(self)
|
60
|
+
end
|
61
|
+
|
62
|
+
def artist_digestor
|
63
|
+
@artist_digestor ||= ArtistDigestor.new(self)
|
64
|
+
end
|
65
|
+
|
66
|
+
def release
|
67
|
+
@release_manager ||= ReleaseManager.new(self)
|
68
|
+
end
|
69
|
+
|
70
|
+
def release_digestor
|
71
|
+
@release_digestor ||= ReleaseDigestor.new(self)
|
72
|
+
end
|
73
|
+
|
74
|
+
def label_digestor
|
75
|
+
@label_digestor ||= LabelDigestor.new(self)
|
76
|
+
end
|
77
|
+
|
78
|
+
def format_digestor
|
79
|
+
@format_digestor ||= FormatDigestor.new(self)
|
80
|
+
end
|
81
|
+
|
82
|
+
def price_digestor
|
83
|
+
@price_digestor ||= PriceDigestor.new(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def pager_digestor
|
87
|
+
@pager_digestor ||= PagerDigestor.new(self)
|
88
|
+
end
|
89
|
+
|
90
|
+
def track
|
91
|
+
@track_manager ||= TrackManager.new(self)
|
92
|
+
end
|
93
|
+
|
94
|
+
def track_digestor
|
95
|
+
@track_digestor ||= TrackDigestor.new(self)
|
96
|
+
end
|
97
|
+
|
98
|
+
def api_response_digestor
|
99
|
+
@api_response_digestor ||= ApiResponseDigestor.new(self)
|
100
|
+
end
|
101
|
+
|
102
|
+
def chart_item_digestor
|
103
|
+
@chart_item_digestor ||= ChartItemDigestor.new(self)
|
104
|
+
end
|
105
|
+
|
106
|
+
def configuration
|
107
|
+
return @configuration
|
108
|
+
end
|
109
|
+
|
110
|
+
def operator
|
111
|
+
@api_operator
|
112
|
+
end
|
113
|
+
|
114
|
+
def country
|
115
|
+
@country || @configuration.country
|
116
|
+
end
|
117
|
+
|
118
|
+
def country=(country_code)
|
119
|
+
@country = country_code
|
120
|
+
end
|
121
|
+
|
122
|
+
def verbose?
|
123
|
+
!(@verbose || @configuration.verbose).nil?
|
124
|
+
end
|
125
|
+
|
126
|
+
def very_verbose?
|
127
|
+
verbose? && (@verbose || @configuration.verbose).to_s == "very_verbose"
|
128
|
+
end
|
129
|
+
|
130
|
+
def verbose=(verbosity)
|
131
|
+
@verbose = verbosity
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|