dummy_dropbox 0.0.1 → 0.0.2

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.
data/Manifest CHANGED
@@ -1,8 +1,9 @@
1
1
  Manifest
2
- README.md
2
+ README.rdoc
3
3
  Rakefile
4
4
  lib/dummy_dropbox.rb
5
5
  test/dummy_dropbox_test.rb
6
6
  test/fixtures/dropbox/file1.txt
7
7
  test/fixtures/dropbox/folder1/file2.txt
8
8
  test/fixtures/dropbox/folder1/file3.txt
9
+ test/fixtures/file.txt
@@ -4,9 +4,9 @@ http://farm5.static.flickr.com/4136/4925714505_3a3a0a6134_o.jpg
4
4
 
5
5
  <b>I can image a Dropbox session, just for testing.</b>
6
6
 
7
- Very simple library for mocking the (dropbox ruby gem)[http://rubygems.org/gems/dropbox].
7
+ Very simple library for mocking the dropbox_ruby_gem[http://rubygems.org/gems/dropbox].
8
8
 
9
- So you can test your application without making real calls to Dropbox API.
9
+ You can test your application without making real calls to Dropbox API using a *local* *folder* to fake a Dropbox account.
10
10
 
11
11
 
12
12
  == Install
@@ -21,7 +21,7 @@ So you can test your application without making real calls to Dropbox API.
21
21
  # Optional:
22
22
  # Point where your local folder structure is located.
23
23
  # It will be used as if the real Dropbox structure was been reading.
24
- DropboxDummy.root_path = <your_local_folder>
24
+ DummyDropbox.root_path = <your_local_folder>
25
25
 
26
26
  session = Dropbox::Session.new('key', 'secret')
27
27
  assert_equal( File.read( "<your_local_folder>/file1.txt" ) , @session.download( '/file1.txt' ) )
@@ -33,6 +33,8 @@ See the *test* folder.
33
33
 
34
34
  The status of this dummy implementation is not very much completed, I just implemented enough for my proposes.
35
35
 
36
+ Please fork it and complete the holes as you need it, them send me your pull request.
37
+
36
38
 
37
39
  == Credits
38
40
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('dummy_dropbox', '0.0.1') do |p|
5
+ Echoe.new('dummy_dropbox', '0.0.2') do |p|
6
6
  p.description = "Dummy monkey patching for the dropbox ruby gem: http://rubygems.org/gems/dropbox"
7
7
  p.url = "http://github.com/fguillen/DummyDropbox"
8
8
  p.author = "Fernando Guillen"
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dummy_dropbox}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fernando Guillen"]
9
- s.date = %q{2010-08-25}
9
+ s.date = %q{2011-01-26}
10
10
  s.description = %q{Dummy monkey patching for the dropbox ruby gem: http://rubygems.org/gems/dropbox}
11
11
  s.email = %q{fguillen.mail@gmail.com}
12
- s.extra_rdoc_files = ["README.md", "lib/dummy_dropbox.rb"]
13
- s.files = ["Manifest", "README.md", "Rakefile", "lib/dummy_dropbox.rb", "test/dummy_dropbox_test.rb", "test/fixtures/dropbox/file1.txt", "test/fixtures/dropbox/folder1/file2.txt", "test/fixtures/dropbox/folder1/file3.txt", "dummy_dropbox.gemspec"]
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/dummy_dropbox.rb"]
13
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/dummy_dropbox.rb", "test/dummy_dropbox_test.rb", "test/fixtures/dropbox/file1.txt", "test/fixtures/dropbox/folder1/file2.txt", "test/fixtures/dropbox/folder1/file3.txt", "test/fixtures/file.txt", "dummy_dropbox.gemspec"]
14
14
  s.homepage = %q{http://github.com/fguillen/DummyDropbox}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Dummy_dropbox", "--main", "README.md"]
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Dummy_dropbox", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{dummy_dropbox}
18
18
  s.rubygems_version = %q{1.3.7}
data/lib/dummy_dropbox.rb CHANGED
@@ -46,6 +46,20 @@ module Dropbox
46
46
  File.read( "#{Dropbox.files_root_path}/#{path}" )
47
47
  end
48
48
 
49
+ def create_folder(path, options={})
50
+ FileUtils.mkdir( "#{Dropbox.files_root_path}/#{path}" )
51
+
52
+ return self.metadata( path )
53
+ end
54
+
55
+ # TODO: the original gem method allow a lot of types for 'local_path' parameter
56
+ # this dummy version only allows a file_path
57
+ def upload(local_file_path, remote_folder_path, options={})
58
+ FileUtils.cp( local_file_path, "#{Dropbox.files_root_path}/#{remote_folder_path}/" )
59
+
60
+ return self.metadata( "#{remote_folder_path}/#{File.basename(local_file_path)}" )
61
+ end
62
+
49
63
  def metadata(path, options={})
50
64
  response = <<-RESPONSE
51
65
  {
@@ -26,4 +26,24 @@ class DummyDropboxTest < Test::Unit::TestCase
26
26
  assert_equal(['/file1.txt', '/folder1'], @session.list('').map{ |e| e.path } )
27
27
  assert_equal(['folder1/file2.txt', 'folder1/file3.txt'], @session.list('folder1').map{ |e| e.path } )
28
28
  end
29
+
30
+ def test_create_folder
31
+ FileUtils.rm_r( "#{DummyDropbox.root_path}/tmp_folder" ) if File.exists?( "#{DummyDropbox.root_path}/tmp_folder" )
32
+ metadata = @session.create_folder '/tmp_folder'
33
+ assert( File.directory?( "#{DummyDropbox.root_path}/tmp_folder" ) )
34
+ assert( metadata.directory? )
35
+
36
+ FileUtils.rm_r( "#{DummyDropbox.root_path}/tmp_folder" )
37
+ end
38
+
39
+ def test_upload
40
+ FileUtils.rm_r( "#{DummyDropbox.root_path}/file.txt" ) if File.exists?( "#{DummyDropbox.root_path}/file.txt" )
41
+ metadata = @session.upload( "#{File.dirname(__FILE__)}/fixtures/file.txt", '/' )
42
+ assert_equal(
43
+ File.read( "#{File.dirname(__FILE__)}/fixtures/file.txt" ),
44
+ File.read( "#{DummyDropbox.root_path}/file.txt" )
45
+ )
46
+ assert( !metadata.directory? )
47
+ FileUtils.rm_r( "#{DummyDropbox.root_path}/file.txt" )
48
+ end
29
49
  end
@@ -0,0 +1 @@
1
+ file content
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dummy_dropbox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Fernando Guillen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-25 00:00:00 +02:00
18
+ date: 2011-01-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -39,17 +39,18 @@ executables: []
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - README.md
42
+ - README.rdoc
43
43
  - lib/dummy_dropbox.rb
44
44
  files:
45
45
  - Manifest
46
- - README.md
46
+ - README.rdoc
47
47
  - Rakefile
48
48
  - lib/dummy_dropbox.rb
49
49
  - test/dummy_dropbox_test.rb
50
50
  - test/fixtures/dropbox/file1.txt
51
51
  - test/fixtures/dropbox/folder1/file2.txt
52
52
  - test/fixtures/dropbox/folder1/file3.txt
53
+ - test/fixtures/file.txt
53
54
  - dummy_dropbox.gemspec
54
55
  has_rdoc: true
55
56
  homepage: http://github.com/fguillen/DummyDropbox
@@ -62,7 +63,7 @@ rdoc_options:
62
63
  - --title
63
64
  - Dummy_dropbox
64
65
  - --main
65
- - README.md
66
+ - README.rdoc
66
67
  require_paths:
67
68
  - lib
68
69
  required_ruby_version: !ruby/object:Gem::Requirement