Class: Backup2everbox::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/backup2everbox/cli.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :consumer_key => 'GW4YtvBpPwHfY0rCSf2xeOqn7tT0YH2O4zftXCOM',
  :consumer_secret => 'xlKLpZLVSe0Gk6q4w05PsDpzjEbV8SyE71exgz1i',
  :oauth_site => 'http://account.everbox.com',
  :fs_site => 'http://fs.everbox.com',
  :proxy => nil
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ CLI

Returns a new instance of CLI.



18
19
20
21
# File 'lib/backup2everbox/cli.rb', line 18

def initialize(opts={})
  opts ||= {}
  @options = DEFAULT_OPTIONS.merge(opts)
end

Class Method Details

.execute(stdout, stdin, stderr, arguments = []) ⇒ Object



14
15
16
# File 'lib/backup2everbox/cli.rb', line 14

def self.execute(stdout, stdin, stderr, arguments = [])
  self.new.execute(stdout, stdin, stderr, arguments)
end

Instance Method Details

#execute(stdout, stdin, stderr, arguments = []) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/backup2everbox/cli.rb', line 23

def execute(stdout, stdin, stderr, arguments = [])
  request_token = consumer.get_request_token
  url = request_token.authorize_url
  puts "open url in your browser: #{url}"
  Launchy.open(url)
  STDOUT.write "please input the verification code: "
  STDOUT.flush
  verification_code = STDIN.readline.strip
  access_token = request_token.get_access_token :oauth_verifier => verification_code
  puts
  puts "add following code to your ~/Backup/models/foo.rb"
  puts "#" * 50
  puts "  store_with Everbox do |eb|"
  puts "    eb.keep      = 7"
  puts "    eb.token     = '#{access_token.token}'"
  puts "    eb.secret    = '#{access_token.secret}'"
  puts "  end"
  puts "#" * 50
end