Class: Dropbox::Session
- Inherits:
-
Object
- Object
- Dropbox::Session
- Defined in:
- lib/dummy_dropbox.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account ⇒ Object
- #authorize(options = {}) ⇒ Object
- #authorize_url(*args) ⇒ Object
- #authorized? ⇒ Boolean
-
#download(path, options = {}) ⇒ Object
API methods.
-
#initialize(oauth_key, oauth_secret, options = {}) ⇒ Session
constructor
A new instance of Session.
- #list(path, options = {}) ⇒ Object
- #metadata(path, options = {}) ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize(oauth_key, oauth_secret, options = {}) ⇒ Session
Returns a new instance of Session.
15 16 17 18 19 |
# File 'lib/dummy_dropbox.rb', line 15 def initialize(oauth_key, oauth_secret, ={}) @ssl = false @consumer = OpenStruct.new( :key => "dummy key consumer" ) @request_token = "dummy request token" end |
Class Method Details
Instance Method Details
#account ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/dummy_dropbox.rb', line 90 def account response = <<-RESPONSE { "country": "", "display_name": "John Q. User", "quota_info": { "shared": 37378890, "quota": 62277025792, "normal": 263758550 }, "uid": "174" } RESPONSE return JSON.parse(response).symbolize_keys_recursively.to_struct_recursively end |
#authorize(options = {}) ⇒ Object
25 26 27 |
# File 'lib/dummy_dropbox.rb', line 25 def (={}) return true end |
#authorize_url(*args) ⇒ Object
21 22 23 |
# File 'lib/dummy_dropbox.rb', line 21 def (*args) return 'dummy url' end |
#authorized? ⇒ Boolean
29 30 31 |
# File 'lib/dummy_dropbox.rb', line 29 def return true end |
#download(path, options = {}) ⇒ Object
API methods
45 46 47 |
# File 'lib/dummy_dropbox.rb', line 45 def download(path, ={}) File.read( "#{Dropbox.files_root_path}/#{path}" ) end |
#list(path, options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/dummy_dropbox.rb', line 65 def list(path, ={}) result = [] Dir["#{Dropbox.files_root_path}/#{path}/**"].each do |element_path| element_path.gsub!( "#{Dropbox.files_root_path}/", '' ) element = OpenStruct.new( :icon => 'folder', :'directory?' => File.directory?( "#{Dropbox.files_root_path}/#{element_path}" ), :path => element_path, :thumb_exists => false, :modified => Time.parse( '2010-01-01 10:10:10' ), :revision => 1, :bytes => 0, :is_dir => File.directory?( "#{Dropbox.files_root_path}/#{element_path}" ), :size => '0 bytes' ) result << element end return result end |
#metadata(path, options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dummy_dropbox.rb', line 49 def (path, ={}) response = <<-RESPONSE { "thumb_exists": false, "bytes": "#{File.size( "#{Dropbox.files_root_path}/#{path}" )}", "modified": "Tue, 04 Nov 2008 02:52:28 +0000", "path": "#{path}", "is_dir": #{File.directory?( "#{Dropbox.files_root_path}/#{path}" )}, "size": "566.0KB", "root": "dropbox", "icon": "page_white_acrobat" } RESPONSE return (JSON.parse(response).symbolize_keys_recursively).to_struct_recursively end |
#serialize ⇒ Object
33 34 35 |
# File 'lib/dummy_dropbox.rb', line 33 def serialize return 'dummy serial' end |