Class: CloudDoor::OneDrive
- Inherits:
-
CloudStorage
- Object
- CloudStorage
- CloudDoor::OneDrive
- Defined in:
- lib/cloud_door/onedrive.rb
Constant Summary collapse
- ROOT_ID =
user root file_id
'me/skydrive'
- LOGIN_COMPONENTS =
onedrive login site components
{ 'account_text_name' => 'login', 'password_text_name' => 'passwd', 'signin_button_id' => 'idSIButton9', 'accept_button_id' => 'idBtn_Accept' }
- TIME_PROPERTY_PAT =
/_time$/
- STORAGE_NAME =
'OneDrive'
Constants inherited from CloudStorage
CloudStorage::ABSTRACT_METHODS, CloudStorage::PARENT_DIR_PAT, CloudStorage::PICK_METHODS
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file_id ⇒ Object
Returns the value of attribute file_id.
-
#file_list ⇒ Object
Returns the value of attribute file_list.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#mkdir_name ⇒ Object
Returns the value of attribute mkdir_name.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#token ⇒ Object
Returns the value of attribute token.
-
#up_file_name ⇒ Object
Returns the value of attribute up_file_name.
Attributes inherited from CloudStorage
Instance Method Summary collapse
-
#initialize(session_id = nil) ⇒ OneDrive
constructor
A new instance of OneDrive.
- #load_token ⇒ Object
- #login(login_account, login_password) ⇒ Object
- #refresh_token ⇒ Object
Methods inherited from CloudStorage
#assign_upload_file_name, #change_directory, #configuration_init?, #delete_file, #download_file, #file?, #file_exist?, #has_file?, #isset_account?, #make_directory, #method_missing, #reset_token, #show_account, #show_configuration, #show_current_directory, #show_files, #show_property, #show_storage_name, #show_user, #update_account, #update_configuration, #upload_file
Constructor Details
#initialize(session_id = nil) ⇒ OneDrive
Returns a new instance of OneDrive.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cloud_door/onedrive.rb', line 24 def initialize(session_id = nil) @config = Config.new('onedrive') @account = Account.new('onedrive', @config.data_path) @token = Token.new('onedrive_token', @config.data_path, session_id) @file_list = FileList.new('onedrive_list', @config.data_path, session_id) @file_id = nil @root_id = ROOT_ID @storage_name = STORAGE_NAME @session_id = session_id @client = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CloudDoor::CloudStorage
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
10 11 12 |
# File 'lib/cloud_door/onedrive.rb', line 10 def account @account end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/cloud_door/onedrive.rb', line 10 def config @config end |
#file_id ⇒ Object
Returns the value of attribute file_id.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def file_id @file_id end |
#file_list ⇒ Object
Returns the value of attribute file_list.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def file_list @file_list end |
#file_name ⇒ Object
Returns the value of attribute file_name.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def file_name @file_name end |
#mkdir_name ⇒ Object
Returns the value of attribute mkdir_name.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def mkdir_name @mkdir_name end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def parent_id @parent_id end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def token @token end |
#up_file_name ⇒ Object
Returns the value of attribute up_file_name.
8 9 10 |
# File 'lib/cloud_door/onedrive.rb', line 8 def up_file_name @up_file_name end |
Instance Method Details
#load_token ⇒ Object
36 37 38 39 40 41 |
# File 'lib/cloud_door/onedrive.rb', line 36 def load_token token_file = File.basename(@token.token_file) @token = Token.load_token(token_file, @config.data_path, @session_id) @client = OneDriveApi.new(@token.access_token) @token end |
#login(login_account, login_password) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cloud_door/onedrive.rb', line 53 def login(login_account, login_password) @account.login_account = login_account @account.login_password = login_password url = login_browser info = request_get_token(url) raise NoDataException if info.nil? @session_id = reset_token(info) @client = OneDriveApi.new(@token.access_token) items = pull_files @file_list.delete_file @file_list.write_file_list(items) if @config.session_use? @session_id else true end rescue => e handle_exception(e) end |
#refresh_token ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/cloud_door/onedrive.rb', line 43 def refresh_token raise TokenClassException unless @token.is_a?(Token) info = request_refresh_token raise NoDataException if info.nil? @token.set_attributes(info) @token.write_token rescue => e handle_exception(e) end |