dropbox-api-kilgore5 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ require "spec_helper"
2
+
3
+ describe Dropbox::API::File do
4
+
5
+ before do
6
+ @client = Dropbox::Spec.instance
7
+ @filename = "#{Dropbox::Spec.test_dir}/spec-test-#{Time.now.to_i}.txt"
8
+ @file = @client.upload @filename, "spec file"
9
+ end
10
+
11
+ after do
12
+ # @file.delete
13
+ end
14
+
15
+ describe "#copy" do
16
+
17
+ it "copies the file properly" do
18
+ new_filename = @filename + ".copied"
19
+ @file.copy new_filename
20
+ @file.path.should == new_filename
21
+ end
22
+
23
+ end
24
+
25
+ describe "#move" do
26
+
27
+ it "moves the file properly" do
28
+ new_filename = @filename + ".copied"
29
+ @file.move new_filename
30
+ @file.path.should == new_filename
31
+ end
32
+
33
+ end
34
+
35
+ describe "#destroy" do
36
+
37
+ it "destroys the file properly" do
38
+ @file.destroy
39
+ @file.is_deleted.should == true
40
+ end
41
+
42
+ end
43
+
44
+ describe "#revisions" do
45
+
46
+ it "retrieves all revisions as an Array of File objects" do
47
+ @client.upload @file.path, "Updated content"
48
+
49
+ revisions = @file.revisions
50
+ revisions.size.should == 2
51
+ revisions.collect { |f| f.class }.should == [Dropbox::API::File, Dropbox::API::File]
52
+ end
53
+
54
+ end
55
+
56
+ describe "#restore" do
57
+
58
+ it "restores the file to a specific revision" do
59
+ old_rev = @file.rev
60
+
61
+ @client.upload @file.path, "Updated content"
62
+
63
+ file = @filename.split('/').last
64
+
65
+ found = @client.find(@file.path)
66
+
67
+ found.rev.should_not == old_rev
68
+
69
+ newer_rev = found.rev
70
+
71
+ @file.restore(old_rev)
72
+
73
+ found = @client.find(@file.path)
74
+
75
+ found.rev.should_not == old_rev
76
+ found.rev.should_not == newer_rev
77
+
78
+ end
79
+
80
+ end
81
+
82
+ describe "#share_url" do
83
+
84
+ it "returns an Url object" do
85
+
86
+ result = @file.share_url
87
+ result.should be_an_instance_of(Dropbox::API::Object)
88
+ result.keys.sort.should == ['expires', 'url']
89
+
90
+ end
91
+
92
+ end
93
+
94
+ describe "#copy_ref" do
95
+
96
+ it "returns a copy_ref object" do
97
+
98
+ result = @file.copy_ref
99
+ result.should be_an_instance_of(Dropbox::API::Object)
100
+ result.keys.sort.should == ['copy_ref', 'expires']
101
+
102
+ end
103
+
104
+ end
105
+
106
+ describe "#direct_url" do
107
+
108
+ it "returns an Url object" do
109
+
110
+ result = @file.direct_url
111
+ result.should be_an_instance_of(Dropbox::API::Object)
112
+ result.keys.sort.should == ['expires', 'url']
113
+
114
+ end
115
+
116
+ end
117
+
118
+ describe "#download" do
119
+
120
+ it "should download the file" do
121
+ @file.download.should == 'spec file'
122
+ end
123
+
124
+ end
125
+
126
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe Dropbox::API::OAuth do
4
+
5
+ describe ".consumer" do
6
+
7
+ it "raises an error if config options are not provided" do
8
+ Dropbox::API::Config.stub!(:app_key).and_return(nil)
9
+ lambda {
10
+ Dropbox::API::OAuth.consumer :main
11
+ }.should raise_error(Dropbox::API::Error::Config)
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ describe Dropbox::API::File do
5
+
6
+ before do
7
+ @io = StringIO.new
8
+ @client = Dropbox::Spec.instance
9
+ @filename = "#{Dropbox::Spec.test_dir}/spec-test-#{Time.now.to_i}.jpg"
10
+ jpeg = File.read("spec/fixtures/dropbox.jpg")
11
+ @file = @client.upload @filename, jpeg
12
+ end
13
+
14
+ describe "#thumbnail" do
15
+
16
+ it "downloads a thumbnail" do
17
+ result = @file.thumbnail
18
+
19
+ @io << result
20
+ @io.rewind
21
+
22
+ jpeg = JPEG.new(@io)
23
+ jpeg.height.should == 64
24
+ jpeg.width.should == 64
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path("../../lib", __FILE__)
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter 'spec'
6
+ end
7
+ require 'dropbox-api'
8
+ require 'rspec'
9
+
10
+ # If you wand to change the json, you can do it here
11
+ # I still believe yajl is the best :) - marcinbunsch
12
+ MultiJson.engine= :yajl
13
+
14
+ module Dropbox
15
+ Spec = Hashie::Mash.new
16
+ end
17
+
18
+ Dir.glob("#{File.dirname(__FILE__)}/support/*.rb").each { |f| require f }
19
+
20
+ # Clean up after specs, remove test-directory
21
+ RSpec.configure do |config|
22
+ config.after(:all) do
23
+ test_dir = Dropbox::Spec.instance.find(Dropbox::Spec.test_dir)
24
+ test_dir.destroy unless test_dir.is_deleted?
25
+ end
26
+ end
27
+
@@ -0,0 +1,15 @@
1
+ require "yaml"
2
+
3
+ config = YAML.load_file "spec/connection.yml"
4
+
5
+ Dropbox::API::Config.app_key = config['app_key']
6
+ Dropbox::API::Config.app_secret = config['app_secret']
7
+ Dropbox::API::Config.mode = config['mode']
8
+
9
+ Dropbox::Spec.token = config['token']
10
+ Dropbox::Spec.secret = config['secret']
11
+
12
+ Dropbox::Spec.namespace = Time.now.to_i
13
+ Dropbox::Spec.instance = Dropbox::API::Client.new(:token => Dropbox::Spec.token,
14
+ :secret => Dropbox::Spec.secret)
15
+ Dropbox::Spec.test_dir = "test-#{Time.now.to_i}"
@@ -0,0 +1,39 @@
1
+ class JPEG
2
+ attr_reader :width, :height, :bits
3
+
4
+ def initialize(file)
5
+ examine(file)
6
+ end
7
+
8
+ private
9
+ def examine(io)
10
+ raise 'malformed JPEG' unless io.getbyte == 0xFF && io.getbyte == 0xD8 # SOI
11
+
12
+ class << io
13
+ def readint; (getbyte << 8) + getbyte; end
14
+ def readframe; read(readint - 2); end
15
+ def readsof; [readint, getbyte, readint, readint, getbyte]; end
16
+ def next
17
+ c = getbyte while c != 0xFF
18
+ c = getbyte while c == 0xFF
19
+ c
20
+ end
21
+ end
22
+
23
+ while marker = io.next
24
+ case marker
25
+ when 0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF # SOF markers
26
+ length, @bits, @height, @width, components = io.readsof
27
+ raise 'malformed JPEG' unless length == 8 + components * 3
28
+ when 0xD9, 0xDA
29
+ break # EOI, SOS
30
+ when 0xFE
31
+ @comment = io.readframe # COM
32
+ when 0xE1
33
+ io.readframe # APP1, contains EXIF tag
34
+ else
35
+ io.readframe # ignore frame
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dropbox-api-kilgore5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Bunsch, John Royall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: oauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: To deliver a more Rubyesque experience when using the DropBox API.
56
+ email:
57
+ - marcin@futuresimple.com, johnroyall7@yahoo.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - Gemfile
65
+ - LICENSE
66
+ - README.markdown
67
+ - Rakefile
68
+ - dropbox-api-kilgore5.gemspec
69
+ - lib/dropbox-api.rb
70
+ - lib/dropbox-api/client.rb
71
+ - lib/dropbox-api/client/files.rb
72
+ - lib/dropbox-api/client/raw.rb
73
+ - lib/dropbox-api/connection.rb
74
+ - lib/dropbox-api/connection/requests.rb
75
+ - lib/dropbox-api/objects/delta.rb
76
+ - lib/dropbox-api/objects/dir.rb
77
+ - lib/dropbox-api/objects/file.rb
78
+ - lib/dropbox-api/objects/fileops.rb
79
+ - lib/dropbox-api/objects/object.rb
80
+ - lib/dropbox-api/tasks.rb
81
+ - lib/dropbox-api/util/config.rb
82
+ - lib/dropbox-api/util/error.rb
83
+ - lib/dropbox-api/util/oauth.rb
84
+ - lib/dropbox-api/util/response.rb
85
+ - lib/dropbox-api/util/util.rb
86
+ - lib/dropbox-api/version.rb
87
+ - spec/connection.sample.yml
88
+ - spec/fixtures/dropbox.jpg
89
+ - spec/lib/dropbox-api/client_spec.rb
90
+ - spec/lib/dropbox-api/connection_spec.rb
91
+ - spec/lib/dropbox-api/dir_spec.rb
92
+ - spec/lib/dropbox-api/file_spec.rb
93
+ - spec/lib/dropbox-api/oauth_spec.rb
94
+ - spec/lib/dropbox-api/thumbnail_spec.rb
95
+ - spec/spec_helper.rb
96
+ - spec/support/config.rb
97
+ - spec/support/jpeg.rb
98
+ homepage: http://github.com/kilgore5/dropbox-api
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project: dropbox-api
117
+ rubygems_version: 2.1.4
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A Ruby client for the DropBox REST API.
121
+ test_files:
122
+ - spec/connection.sample.yml
123
+ - spec/fixtures/dropbox.jpg
124
+ - spec/lib/dropbox-api/client_spec.rb
125
+ - spec/lib/dropbox-api/connection_spec.rb
126
+ - spec/lib/dropbox-api/dir_spec.rb
127
+ - spec/lib/dropbox-api/file_spec.rb
128
+ - spec/lib/dropbox-api/oauth_spec.rb
129
+ - spec/lib/dropbox-api/thumbnail_spec.rb
130
+ - spec/spec_helper.rb
131
+ - spec/support/config.rb
132
+ - spec/support/jpeg.rb