Class: Smug::InitCommand
Instance Method Summary collapse
Methods included from Utils
#method_missing, #status_message
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Smug::Utils
Instance Method Details
#exec ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/smugsync/init.rb', line 7 def exec # need to request access token from the user request_token = oauth_consumer.get_request_token # TODO: explain what happens better puts <<-EOS Authorize app at: #{request_token.}&Access=Full&Permissions=Modify Press Enter when finished EOS gets access_token = nil begin access_token = request_token.get_access_token rescue OAuth::Unauthorized $stderr.puts "Fatal: Could not authorize with SmugMug. Run 'smug init' again." exit(-1) end config = { :access_token => { :secret => access_token.secret, :token => access_token.token } } Smug::Config::create_config_dir File.open(Smug::Config::config_file_name(Smug::Config::ACCESS_TOKEN_CONFIG_FILE), "w+") do |f| f.puts JSON.pretty_generate(config) end puts "Initialized SmugMug folder and authorized with SmugMug" end |