Created
August 5, 2014 15:26
-
-
Save paulingham/974fbf8237cbe8e4ac19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## config/initializers/viddler.rb | |
Viddler.configure do |c| | |
c.api_key = '', | |
c.username = '', | |
c.password = '' | |
end | |
## None rails | |
class Viddler | |
def self.configure | |
yield(Configuration.instance) | |
end | |
class Authenticate | |
def self.login! | |
new.login | |
end | |
def login | |
client.authenticate!(username, password) | |
# may need to return the client here | |
# depending on what gets returned above | |
# if it doesn't return client, return it below | |
end | |
private | |
def api_key | |
Configuration.instance.api_key | |
end | |
def username | |
Configuration.instance.username | |
end | |
def password | |
Configuration.instance.password | |
end | |
def client | |
@client ||= Viddler::Client.new(api_key) | |
end | |
end | |
class Configuration | |
include Singleton | |
attr_accessor :api_key, :username, :password | |
end | |
class Upload | |
def initialize(client) | |
@client = client | |
end | |
def prepare | |
# let this deal with ['upload']['endpoint'] and | |
# ['upload']['token'] | |
UploadPreparer.prepare | |
end | |
def upload(args, file) | |
UploadPerformer.upload(args, file) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment