Skip to content

Commit

Permalink
Use subconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Mar 4, 2015
1 parent 0e6f2e9 commit da9e788
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/purdie/ingester.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Dotenv.load

module Purdie
module Ingester
attr_reader :config, :subconfig

def initialize config
@config = config
@subconfig = @config['services'][Purdie.basename self]
Expand All @@ -26,7 +30,7 @@ def write
if self.has_items?
FileUtils.mkdir_p @config['output-dir']

File.open "#{@config['output-dir']}/#{@config['services'][self.class.name.split('::')[-1]]['output-file']}", 'w' do |f|
File.open "#{@config['output-dir']}/#{@subconfig['output-file']}", 'w' do |f|
f.write self.to_yaml
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/purdie/services/soundcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SoundCloud

def all_tracks
@all_tracks ||= begin
url = "#{@config['services'][self.class.name.split('::')[-1]]['host']}/users/#{ENV['SOUNDCLOUD_USER_ID']}/tracks?client_id=#{ENV['SOUNDCLOUD_CLIENT_ID']}"
url = "#{@subconfig['host']}/users/#{ENV['SOUNDCLOUD_USER_ID']}/tracks?client_id=#{ENV['SOUNDCLOUD_CLIENT_ID']}"
response = HTTParty.get url
JSON.parse response.body
end
Expand Down
4 changes: 1 addition & 3 deletions lib/purdie/services/vimeo.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require 'purdie'

Dotenv.load

module Purdie
module Services
class Vimeo
Expand All @@ -10,7 +8,7 @@ class Vimeo
def get url
@id = Purdie.get_id url

target = "#{@config['services'][self.class.name.split('::')[-1]]['host']}/videos/#{@id}"
target = "#{@subconfig['host']}/videos/#{@id}"
headers = {
'Authorization' => "bearer #{ENV['VIMEO_BEARER_TOKEN']}",
'Accept' => 'application/json'
Expand Down

0 comments on commit da9e788

Please sign in to comment.