cloud_file 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.lre ADDED
@@ -0,0 +1 @@
1
+ load "lib/cloud_file.rb"
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --drb
data/Gemfile ADDED
@@ -0,0 +1,39 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", ">= 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.2"
12
+ gem "jeweler", "~> 1.8.4"
13
+ #gem "rcov", ">= 0"
14
+ end
15
+
16
+ gem 'mharris_ext'
17
+
18
+ gem 'evernote_oauth'
19
+ gem 'dropbox-api'
20
+ gem 'google_drive'
21
+
22
+ gem 'lre'
23
+ gem 'nokogiri'
24
+ gem 'httparty'
25
+
26
+ group :test do
27
+ gem 'vcr'
28
+ gem 'webmock'
29
+ gem 'json'
30
+ gem 'spork'
31
+ end
32
+
33
+ gem 'guard'
34
+ gem 'guard-rspec'
35
+ gem 'guard-spork'
36
+
37
+ gem 'activesupport'
38
+
39
+ gem 'rb-fsevent', '~> 0.9.1'
data/Gemfile.lock ADDED
@@ -0,0 +1,128 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.11)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ addressable (2.3.2)
8
+ childprocess (0.3.7)
9
+ ffi (~> 1.0, >= 1.0.6)
10
+ coderay (1.0.8)
11
+ crack (0.3.1)
12
+ diff-lcs (1.1.3)
13
+ dropbox-api (0.3.2)
14
+ hashie
15
+ multi_json
16
+ oauth
17
+ evernote-thrift (1.23.1)
18
+ evernote_oauth (0.1.5)
19
+ evernote-thrift
20
+ oauth (>= 0.4.1)
21
+ facets (2.9.3)
22
+ faraday (0.8.4)
23
+ multipart-post (~> 1.1)
24
+ fattr (2.2.1)
25
+ ffi (1.3.1)
26
+ git (1.2.5)
27
+ google_drive (0.3.3)
28
+ nokogiri (>= 1.4.4, != 1.5.2, != 1.5.1)
29
+ oauth (>= 0.3.6)
30
+ oauth2 (>= 0.5.0)
31
+ guard (1.6.2)
32
+ listen (>= 0.6.0)
33
+ lumberjack (>= 1.0.2)
34
+ pry (>= 0.9.10)
35
+ terminal-table (>= 1.4.3)
36
+ thor (>= 0.14.6)
37
+ guard-rspec (1.2.1)
38
+ guard (>= 1.1)
39
+ guard-spork (1.4.2)
40
+ childprocess (>= 0.2.3)
41
+ guard (>= 1.1)
42
+ spork (>= 0.8.4)
43
+ hashie (1.2.0)
44
+ httparty (0.8.3)
45
+ multi_json (~> 1.0)
46
+ multi_xml
47
+ httpauth (0.2.0)
48
+ i18n (0.6.1)
49
+ jeweler (1.8.4)
50
+ bundler (~> 1.0)
51
+ git (>= 1.2.5)
52
+ rake
53
+ rdoc
54
+ json (1.7.6)
55
+ jwt (0.1.5)
56
+ multi_json (>= 1.0)
57
+ listen (0.7.2)
58
+ lre (0.3.0)
59
+ fattr
60
+ mharris_ext
61
+ watchr
62
+ lumberjack (1.0.2)
63
+ method_source (0.8.1)
64
+ mharris_ext (1.6.0)
65
+ facets
66
+ fattr
67
+ multi_json (1.5.0)
68
+ multi_xml (0.5.2)
69
+ multipart-post (1.1.5)
70
+ nokogiri (1.5.6)
71
+ oauth (0.4.7)
72
+ oauth2 (0.8.0)
73
+ faraday (~> 0.8)
74
+ httpauth (~> 0.1)
75
+ jwt (~> 0.1.4)
76
+ multi_json (~> 1.0)
77
+ rack (~> 1.2)
78
+ pry (0.9.11.4)
79
+ coderay (~> 1.0.5)
80
+ method_source (~> 0.8)
81
+ slop (~> 3.4)
82
+ rack (1.4.4)
83
+ rake (10.0.3)
84
+ rb-fsevent (0.9.1)
85
+ rdoc (3.12)
86
+ json (~> 1.4)
87
+ rspec (2.8.0)
88
+ rspec-core (~> 2.8.0)
89
+ rspec-expectations (~> 2.8.0)
90
+ rspec-mocks (~> 2.8.0)
91
+ rspec-core (2.8.0)
92
+ rspec-expectations (2.8.0)
93
+ diff-lcs (~> 1.1.2)
94
+ rspec-mocks (2.8.0)
95
+ slop (3.4.3)
96
+ spork (0.9.2)
97
+ terminal-table (1.4.5)
98
+ thor (0.17.0)
99
+ vcr (2.4.0)
100
+ watchr (0.7)
101
+ webmock (1.9.0)
102
+ addressable (>= 2.2.7)
103
+ crack (>= 0.1.7)
104
+
105
+ PLATFORMS
106
+ ruby
107
+
108
+ DEPENDENCIES
109
+ activesupport
110
+ bundler (~> 1.2)
111
+ dropbox-api
112
+ evernote_oauth
113
+ google_drive
114
+ guard
115
+ guard-rspec
116
+ guard-spork
117
+ httparty
118
+ jeweler (~> 1.8.4)
119
+ json
120
+ lre
121
+ mharris_ext
122
+ nokogiri
123
+ rb-fsevent (~> 0.9.1)
124
+ rdoc (~> 3.12)
125
+ rspec (>= 2.8.0)
126
+ spork
127
+ vcr
128
+ webmock
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'spork' do
2
+ #watch('lib/**/*.rb')
3
+ #watch('spec/**/*.rb')
4
+ watch("tmp/restart_spork.txt")
5
+ end
6
+
7
+ guard 'rspec', :cli => "--drb" do
8
+ watch(%r{^spec/.+_spec\.rb$})
9
+ watch(%r{^lib/(.+)\.rb$}) { "spec" } # { |m| "spec/lib/#{m[1]}_spec.rb" }
10
+ watch('spec/spec_helper.rb') { "spec" }
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Mike Harris
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = cloud_file
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to cloud_file
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Mike Harris. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cloud_file"
18
+ gem.homepage = "http://github.com/mharris717/cloud_file"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{cloudfile}
21
+ gem.description = %Q{cloudfile}
22
+ gem.email = "mharris717@gmail.com"
23
+ gem.authors = ["Mike Harris"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "cloud_file #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,117 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "cloud_file"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mike Harris"]
12
+ s.date = "2013-02-05"
13
+ s.description = "cloudfile"
14
+ s.email = "mharris717@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".lre",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "Guardfile",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "cloud_file.gemspec",
31
+ "lib/cloud_file.rb",
32
+ "lib/cloud_file/address.rb",
33
+ "lib/cloud_file/cloud_uri.rb",
34
+ "lib/cloud_file/cloud_uri/dsl.rb",
35
+ "lib/cloud_file/convertors.rb",
36
+ "lib/cloud_file/copy.rb",
37
+ "lib/cloud_file/file.rb",
38
+ "lib/cloud_file/outer_service.rb",
39
+ "lib/cloud_file/providers/dropbox.rb",
40
+ "lib/cloud_file/providers/evernote.rb",
41
+ "lib/cloud_file/providers/gdrive.rb",
42
+ "lib/cloud_file/providers/local.rb",
43
+ "lib/cloud_file/providers/memory.rb",
44
+ "lib/cloud_file/service.rb",
45
+ "lib/cloud_file/services.rb",
46
+ "spec/cassettes/most.yml",
47
+ "spec/cloud_file_spec.rb",
48
+ "spec/cloud_uri_spec.rb",
49
+ "spec/providers/memory_spec.rb",
50
+ "spec/spec_helper.rb",
51
+ "vol/copy_test.rb",
52
+ "vol/gsub_test.rb"
53
+ ]
54
+ s.homepage = "http://github.com/mharris717/cloud_file"
55
+ s.licenses = ["MIT"]
56
+ s.require_paths = ["lib"]
57
+ s.rubygems_version = "1.8.23"
58
+ s.summary = "cloudfile"
59
+
60
+ if s.respond_to? :specification_version then
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<mharris_ext>, [">= 0"])
65
+ s.add_runtime_dependency(%q<evernote_oauth>, [">= 0"])
66
+ s.add_runtime_dependency(%q<dropbox-api>, [">= 0"])
67
+ s.add_runtime_dependency(%q<google_drive>, [">= 0"])
68
+ s.add_runtime_dependency(%q<lre>, [">= 0"])
69
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
70
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
71
+ s.add_runtime_dependency(%q<guard>, [">= 0"])
72
+ s.add_runtime_dependency(%q<guard-rspec>, [">= 0"])
73
+ s.add_runtime_dependency(%q<guard-spork>, [">= 0"])
74
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
75
+ s.add_runtime_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
76
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
77
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
78
+ s.add_development_dependency(%q<bundler>, ["~> 1.2"])
79
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
80
+ else
81
+ s.add_dependency(%q<mharris_ext>, [">= 0"])
82
+ s.add_dependency(%q<evernote_oauth>, [">= 0"])
83
+ s.add_dependency(%q<dropbox-api>, [">= 0"])
84
+ s.add_dependency(%q<google_drive>, [">= 0"])
85
+ s.add_dependency(%q<lre>, [">= 0"])
86
+ s.add_dependency(%q<nokogiri>, [">= 0"])
87
+ s.add_dependency(%q<httparty>, [">= 0"])
88
+ s.add_dependency(%q<guard>, [">= 0"])
89
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
90
+ s.add_dependency(%q<guard-spork>, [">= 0"])
91
+ s.add_dependency(%q<activesupport>, [">= 0"])
92
+ s.add_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
93
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
94
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
95
+ s.add_dependency(%q<bundler>, ["~> 1.2"])
96
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
97
+ end
98
+ else
99
+ s.add_dependency(%q<mharris_ext>, [">= 0"])
100
+ s.add_dependency(%q<evernote_oauth>, [">= 0"])
101
+ s.add_dependency(%q<dropbox-api>, [">= 0"])
102
+ s.add_dependency(%q<google_drive>, [">= 0"])
103
+ s.add_dependency(%q<lre>, [">= 0"])
104
+ s.add_dependency(%q<nokogiri>, [">= 0"])
105
+ s.add_dependency(%q<httparty>, [">= 0"])
106
+ s.add_dependency(%q<guard>, [">= 0"])
107
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
108
+ s.add_dependency(%q<guard-spork>, [">= 0"])
109
+ s.add_dependency(%q<activesupport>, [">= 0"])
110
+ s.add_dependency(%q<rb-fsevent>, ["~> 0.9.1"])
111
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
112
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
113
+ s.add_dependency(%q<bundler>, ["~> 1.2"])
114
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
115
+ end
116
+ end
117
+
data/lib/cloud_file.rb ADDED
@@ -0,0 +1,108 @@
1
+ Bundler.require(:default)
2
+
3
+ class Object
4
+ def blank?
5
+ to_s.strip == ''
6
+ end
7
+ def present?
8
+ !blank?
9
+ end
10
+ end
11
+
12
+ module CloudFile
13
+ class << self
14
+ def open(*args,&b)
15
+ address = make_address(*args)
16
+ address.open(&b)
17
+ end
18
+
19
+ def make_address(*args)
20
+ if args.first.kind_of?(::CloudFile::Address)
21
+ args.first
22
+ elsif args.length == 3
23
+ user,provider,loc = *args
24
+ ::CloudFile::Address.make(:user => user, :provider => provider, :loc => loc)
25
+ elsif args.length == 1 && args.first.kind_of?(Hash)
26
+ ::CloudFile::Address.make(args.first)
27
+ elsif args.length == 1 && args.first.kind_of?(String) && args.first =~ /:\/\//
28
+ ::CloudFile::Address.parse(args.first)
29
+ else
30
+ raise "can't make address"
31
+ end
32
+ end
33
+
34
+ def copy(source,target,format=nil)
35
+ #source = ::CloudFile::Address.make(source) if source.kind_of?(Hash)
36
+ #target = ::CloudFile::Address.make(target) if target.kind_of?(Hash)
37
+
38
+ #source = make_address(source)
39
+ #target = make_address(target)
40
+
41
+ #puts source.inspect
42
+ #puts target.inspect
43
+
44
+ copy = ::CloudFile::Copy.new(:source => source, :target => target, :format => format)
45
+ copy.run!
46
+ end
47
+
48
+ def files(*args)
49
+ address = make_address(*args)
50
+ address.files
51
+ end
52
+
53
+ def read(*args)
54
+ res = nil
55
+ open(*args) do |f|
56
+ res = f.read
57
+ end
58
+ res
59
+ end
60
+
61
+ def write(*args)
62
+ val = args.pop
63
+ res = nil
64
+ open(*args) do |f|
65
+ f.write val
66
+ end
67
+ res
68
+ end
69
+ end
70
+ end
71
+
72
+ class Tokens
73
+ class << self
74
+ fattr(:instance) { new }
75
+ def method_missing(sym,*args,&b)
76
+ instance.send(sym,*args,&b)
77
+ end
78
+ end
79
+ fattr(:raw) do
80
+ File.read("/code/explore/multiauth/lib/tokens.json")
81
+ end
82
+ fattr(:list) do
83
+ require 'json'
84
+ JSON.parse raw
85
+ end
86
+ def get_token(provider)
87
+ list.select { |x| x['provider'] == provider.to_s }.first['access_token']
88
+ end
89
+ def user
90
+ require 'ostruct'
91
+ res = OpenStruct.new(:identities => [])
92
+ list.each do |ident|
93
+ res.identities << OpenStruct.new(ident)
94
+ end
95
+ res
96
+ end
97
+ end
98
+
99
+ require 'active_support/core_ext/hash/indifferent_access'
100
+
101
+ files = []
102
+ files += %w(address convertors copy file service services cloud_uri)
103
+ files += %w(dropbox evernote gdrive local memory).map { |x| "providers/#{x}" }
104
+ files.each do |f|
105
+ file = File.expand_path(File.dirname(__FILE__)) + "/cloud_file/#{f}.rb"
106
+ #puts "loading #{file}"
107
+ load file
108
+ end