fog-local 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CONTRIBUTORS.md +1 -0
- data/README.md +5 -10
- data/lib/fog/bin/local.rb +2 -2
- data/lib/fog/local.rb +7 -7
- data/lib/fog/{storage/local → local}/models/directories.rb +4 -3
- data/lib/fog/{storage/local → local}/models/directory.rb +3 -8
- data/lib/fog/{storage/local → local}/models/file.rb +19 -10
- data/lib/fog/{storage/local → local}/models/files.rb +7 -3
- data/lib/fog/local/storage.rb +98 -1
- data/lib/fog/local/version.rb +1 -1
- data/tests/helper.rb +2 -1
- data/tests/local/models/directories_tests.rb +1 -1
- data/tests/local/models/directory_tests.rb +1 -1
- data/tests/local/models/file_tests.rb +70 -5
- data/tests/local/models/files_tests.rb +21 -0
- data/tests/local/storage_tests.rb +4 -4
- metadata +7 -8
- data/.ruby-version +0 -1
- data/lib/fog/storage/local.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b065f649b2b35609e1a2ae757ccb5036d2d9494
|
4
|
+
data.tar.gz: b72140031f1a364ce4917ed40975155302a7653c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d8e89df4684a9400e776872a780906e371d3feea6f0d5d3028d2e7e65b3a2211583e34cd563dfe98b20ca5d307e2ae83ec2cce9405e24ac054503dca24c192
|
7
|
+
data.tar.gz: 1340c09b2b5431deb708134546c7a21231ebc415a3e214e258b8682b7677609f3a4661dab000784ebf448012261d28e92a5a6408c02fc735f51be582cdacfad6
|
data/.travis.yml
CHANGED
data/CONTRIBUTORS.md
CHANGED
data/README.md
CHANGED
@@ -22,27 +22,22 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Initialise a `Fog::Storage` object
|
25
|
+
Initialise a `Fog::Local::Storage` object:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
|
29
|
-
storage = Fog::Storage.new({
|
30
|
-
:local_root => '~/fog',
|
31
|
-
:provider => 'Local'
|
32
|
-
})
|
33
|
-
|
28
|
+
storage = Fog::Local::Storage.new(local_root: '~/fog')
|
34
29
|
```
|
35
30
|
|
36
31
|
This can then be used like any other [Fog storage](http://fog.io/storage/).
|
37
32
|
|
38
33
|
```ruby
|
39
|
-
directory = storage.directories.create(:
|
40
|
-
directory.files.create(:
|
34
|
+
directory = storage.directories.create(key: 'data')
|
35
|
+
directory.files.create(body: 'Hello World!', key: 'hello_world.txt')
|
41
36
|
```
|
42
37
|
|
43
38
|
## Contributing
|
44
39
|
|
45
|
-
1. Fork it ( https://github.com/fog/fog-local/fork
|
40
|
+
1. Fork it ( https://github.com/fog/fog-local/fork)
|
46
41
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
42
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
43
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/fog/bin/local.rb
CHANGED
@@ -3,7 +3,7 @@ class Local < Fog::Bin
|
|
3
3
|
def class_for(key)
|
4
4
|
case key
|
5
5
|
when :storage
|
6
|
-
Fog::Storage
|
6
|
+
Fog::Local::Storage
|
7
7
|
else
|
8
8
|
raise ArgumentError, "Unsupported #{self} service: #{key}"
|
9
9
|
end
|
@@ -14,7 +14,7 @@ class Local < Fog::Bin
|
|
14
14
|
hash[key] = case key
|
15
15
|
when :storage
|
16
16
|
Fog::Logger.warning("Local[:storage] is not recommended, use Storage[:local] for portability")
|
17
|
-
Fog::Storage.new
|
17
|
+
Fog::Local::Storage.new
|
18
18
|
else
|
19
19
|
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
20
20
|
end
|
data/lib/fog/local.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'fog/core'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tempfile'
|
4
|
-
require File.expand_path('../local/version', __FILE__)
|
5
4
|
|
6
|
-
|
7
|
-
module Storage
|
8
|
-
autoload :Local, File.expand_path('../storage/local', __FILE__)
|
9
|
-
end
|
5
|
+
require 'fog/local/version'
|
10
6
|
|
7
|
+
module Fog
|
11
8
|
module Local
|
12
|
-
extend
|
9
|
+
extend Provider
|
13
10
|
|
14
|
-
|
11
|
+
autoload :Storage, 'fog/local/storage'
|
12
|
+
service :storage, :Storage
|
15
13
|
end
|
16
14
|
end
|
15
|
+
|
16
|
+
Fog::Storage::Local = Fog::Local::Storage # legacy compat
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Local
|
3
|
+
class Storage
|
4
4
|
class Directories < Fog::Collection
|
5
|
-
model
|
5
|
+
model Directory
|
6
6
|
|
7
7
|
def all
|
8
8
|
data = if ::File.directory?(service.local_root)
|
@@ -22,6 +22,7 @@ module Fog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
|
+
|
25
26
|
def create_directory(key, options)
|
26
27
|
options[:path] ? new(key: key + options[:path]) : new(key: key)
|
27
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Local
|
3
|
+
class Storage
|
4
4
|
class Directory < Fog::Model
|
5
5
|
identity :key
|
6
6
|
|
@@ -16,12 +16,7 @@ module Fog
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def files
|
19
|
-
@files ||=
|
20
|
-
Fog::Storage::Local::Files.new(
|
21
|
-
:directory => self,
|
22
|
-
:service => service
|
23
|
-
)
|
24
|
-
end
|
19
|
+
@files ||= Files.new(directory: self, service: service)
|
25
20
|
end
|
26
21
|
|
27
22
|
def public=(new_public)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Local
|
3
|
+
class Storage
|
4
4
|
class File < Fog::Model
|
5
5
|
identity :key, :aliases => 'Key'
|
6
6
|
|
@@ -54,14 +54,7 @@ module Fog
|
|
54
54
|
if dir_path == service.path_to(directory.key)
|
55
55
|
break
|
56
56
|
end
|
57
|
-
|
58
|
-
if ::File.directory?(dir_path)
|
59
|
-
Dir.chdir(dir_path)
|
60
|
-
if Dir.glob('*').empty?
|
61
|
-
Dir.rmdir(dir_path)
|
62
|
-
end
|
63
|
-
Dir.chdir(pwd)
|
64
|
-
end
|
57
|
+
rm_if_empty_dir(dir_path)
|
65
58
|
end
|
66
59
|
true
|
67
60
|
end
|
@@ -125,6 +118,22 @@ module Fog
|
|
125
118
|
IO.copy_stream(input_io, file)
|
126
119
|
end
|
127
120
|
end
|
121
|
+
|
122
|
+
def rm_if_empty_dir(dir_path)
|
123
|
+
if ::File.directory?(dir_path)
|
124
|
+
Dir.rmdir(dir_path) if dir_empty?(dir_path)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def dir_empty?(dir_path)
|
129
|
+
# NOTE: There’s Dir.empty?, but it is only available on Ruby 2.4+
|
130
|
+
|
131
|
+
# NOTE: `entries` will be empty on Windows, and contain . and .. on
|
132
|
+
# unix-like systems (macOS, Linux, BSD, …)
|
133
|
+
|
134
|
+
entries = Dir.entries(dir_path)
|
135
|
+
entries.empty? || entries.all? { |e| ['.', '..'].include?(e) }
|
136
|
+
end
|
128
137
|
end
|
129
138
|
end
|
130
139
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Local
|
3
|
+
class Storage
|
4
4
|
class Files < Fog::Collection
|
5
5
|
attribute :directory
|
6
6
|
|
7
|
-
model
|
7
|
+
model File
|
8
8
|
|
9
9
|
def all
|
10
10
|
requires :directory
|
@@ -71,6 +71,10 @@ module Fog
|
|
71
71
|
super({ :directory => directory }.merge!(attributes))
|
72
72
|
end
|
73
73
|
|
74
|
+
def is_truncated
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
74
78
|
private
|
75
79
|
|
76
80
|
def file_path(key)
|
data/lib/fog/local/storage.rb
CHANGED
@@ -1 +1,98 @@
|
|
1
|
-
|
1
|
+
module Fog
|
2
|
+
module Local
|
3
|
+
class Storage < Fog::Service
|
4
|
+
autoload :Directories, 'fog/local/models/directories'
|
5
|
+
autoload :Directory, 'fog/local/models/directory'
|
6
|
+
autoload :File, 'fog/local/models/file'
|
7
|
+
autoload :Files, 'fog/local/models/files'
|
8
|
+
|
9
|
+
requires :local_root
|
10
|
+
recognizes :endpoint, :scheme, :host, :port, :path
|
11
|
+
|
12
|
+
model_path 'fog/local/models'
|
13
|
+
collection :directories
|
14
|
+
model :directory
|
15
|
+
model :file
|
16
|
+
collection :files
|
17
|
+
|
18
|
+
require 'uri'
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
attr_reader :endpoint
|
22
|
+
|
23
|
+
def self.data
|
24
|
+
@data ||= Hash.new do |hash, key|
|
25
|
+
hash[key] = {}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.reset
|
30
|
+
@data = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(options={})
|
34
|
+
Fog::Mock.not_implemented
|
35
|
+
|
36
|
+
@local_root = ::File.expand_path(options[:local_root])
|
37
|
+
|
38
|
+
@endpoint = options[:endpoint] || build_endpoint_from_options(options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def data
|
42
|
+
self.class.data[@local_root]
|
43
|
+
end
|
44
|
+
|
45
|
+
def local_root
|
46
|
+
@local_root
|
47
|
+
end
|
48
|
+
|
49
|
+
def path_to(partial)
|
50
|
+
::File.join(@local_root, partial)
|
51
|
+
end
|
52
|
+
|
53
|
+
def reset_data
|
54
|
+
self.class.data.delete(@local_root)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def build_endpoint_from_options(options)
|
59
|
+
return unless options[:host]
|
60
|
+
|
61
|
+
URI::Generic.build(options).to_s
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Real
|
66
|
+
attr_reader :endpoint
|
67
|
+
|
68
|
+
def initialize(options={})
|
69
|
+
@local_root = ::File.expand_path(options[:local_root])
|
70
|
+
|
71
|
+
@endpoint = options[:endpoint] || build_endpoint_from_options(options)
|
72
|
+
end
|
73
|
+
|
74
|
+
def local_root
|
75
|
+
@local_root
|
76
|
+
end
|
77
|
+
|
78
|
+
def path_to(partial)
|
79
|
+
::File.join(@local_root, partial)
|
80
|
+
end
|
81
|
+
|
82
|
+
def copy_object(source_directory_name, source_object_name, target_directory_name, target_object_name, options={})
|
83
|
+
source_path = path_to(::File.join(source_directory_name, source_object_name))
|
84
|
+
target_path = path_to(::File.join(target_directory_name, target_object_name))
|
85
|
+
::FileUtils.mkdir_p(::File.dirname(target_path))
|
86
|
+
::FileUtils.copy_file(source_path, target_path)
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def build_endpoint_from_options(options)
|
91
|
+
return unless options[:host]
|
92
|
+
|
93
|
+
URI::Generic.build(options).to_s
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/fog/local/version.rb
CHANGED
data/tests/helper.rb
CHANGED
@@ -5,7 +5,8 @@ rescue LoadError => e
|
|
5
5
|
$stderr.puts "not recording test coverage: #{e.inspect}"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
9
|
+
require 'fog/local'
|
9
10
|
|
10
11
|
Bundler.require(:test)
|
11
12
|
require 'tmpdir'
|
@@ -3,7 +3,7 @@ Shindo.tests('Storage[:local] | directories', ["local"]) do
|
|
3
3
|
pending if Fog.mocking?
|
4
4
|
|
5
5
|
@options = { :local_root => Dir.mktmpdir('fog-tests') }
|
6
|
-
@collection = Fog::Storage
|
6
|
+
@collection = Fog::Local::Storage.new(@options).directories
|
7
7
|
|
8
8
|
collection_tests(@collection, {:key => "fogdirtests"}, true)
|
9
9
|
|
@@ -12,7 +12,7 @@ Shindo.tests('Storage[:local] | directory', ["local"]) do
|
|
12
12
|
|
13
13
|
tests('save') do
|
14
14
|
returns('directory') do
|
15
|
-
connection = Fog::Storage
|
15
|
+
connection = Fog::Local::Storage.new(@options)
|
16
16
|
connection.directories.create(:key => 'directory')
|
17
17
|
connection.directories.create(:key => 'directory').key
|
18
18
|
end
|
@@ -15,7 +15,7 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
15
15
|
returns('http://example.com/files/directory/file.txt') do
|
16
16
|
@options[:endpoint] = 'http://example.com/files'
|
17
17
|
|
18
|
-
connection = Fog::Storage
|
18
|
+
connection = Fog::Local::Storage.new(@options)
|
19
19
|
directory = connection.directories.new(:key => 'directory')
|
20
20
|
file = directory.files.new(:key => 'file.txt')
|
21
21
|
|
@@ -26,7 +26,7 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
26
26
|
returns(nil) do
|
27
27
|
@options[:endpoint] = nil
|
28
28
|
|
29
|
-
connection = Fog::Storage
|
29
|
+
connection = Fog::Local::Storage.new(@options)
|
30
30
|
directory = connection.directories.new(:key => 'directory')
|
31
31
|
file = directory.files.new(:key => 'file.txt')
|
32
32
|
|
@@ -37,7 +37,7 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
37
37
|
returns('http://example.com/files/my%20directory/my%20file.txt') do
|
38
38
|
@options[:endpoint] = 'http://example.com/files'
|
39
39
|
|
40
|
-
connection = Fog::Storage
|
40
|
+
connection = Fog::Local::Storage.new(@options)
|
41
41
|
directory = connection.directories.new(:key => 'my directory')
|
42
42
|
file = directory.files.new(:key => 'my file.txt')
|
43
43
|
|
@@ -48,7 +48,7 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
48
48
|
tests('#save') do
|
49
49
|
tests('creates non-existent subdirs') do
|
50
50
|
returns(true) do
|
51
|
-
connection = Fog::Storage
|
51
|
+
connection = Fog::Local::Storage.new(@options)
|
52
52
|
directory = connection.directories.new(:key => 'path1')
|
53
53
|
file = directory.files.new(:key => 'path2/file.rb', :body => "my contents")
|
54
54
|
file.save
|
@@ -57,7 +57,7 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
tests('with tempfile').returns('tempfile') do
|
60
|
-
connection = Fog::Storage
|
60
|
+
connection = Fog::Local::Storage.new(@options)
|
61
61
|
directory = connection.directories.create(:key => 'directory')
|
62
62
|
|
63
63
|
tempfile = Tempfile.new(['file', '.txt'])
|
@@ -76,4 +76,69 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
|
|
76
76
|
directory.files.get('tempfile.txt').body
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
tests('#destroy') do
|
81
|
+
# - removes dir if it contains no files
|
82
|
+
# - keeps dir if it contains non-hidden files
|
83
|
+
# - keeps dir if it contains hidden files
|
84
|
+
# - stays in the same directory
|
85
|
+
|
86
|
+
tests('removes enclosing dir if it is empty') do
|
87
|
+
returns(false) do
|
88
|
+
connection = Fog::Local::Storage.new(@options)
|
89
|
+
directory = connection.directories.new(:key => 'path1')
|
90
|
+
|
91
|
+
file = directory.files.new(:key => 'path2/file.rb', :body => "my contents")
|
92
|
+
file.save
|
93
|
+
file.destroy
|
94
|
+
|
95
|
+
File.exists?(@options[:local_root] + "/path1/path2")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
tests('keeps enclosing dir if it is not empty') do
|
100
|
+
returns(true) do
|
101
|
+
connection = Fog::Local::Storage.new(@options)
|
102
|
+
directory = connection.directories.new(:key => 'path1')
|
103
|
+
|
104
|
+
file = directory.files.new(:key => 'path2/file.rb', :body => "my contents")
|
105
|
+
file.save
|
106
|
+
|
107
|
+
file = directory.files.new(:key => 'path2/file2.rb', :body => "my contents")
|
108
|
+
file.save
|
109
|
+
file.destroy
|
110
|
+
|
111
|
+
File.exists?(@options[:local_root] + "/path1/path2")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
tests('keeps enclosing dir if contains only hidden files') do
|
116
|
+
returns(true) do
|
117
|
+
connection = Fog::Local::Storage.new(@options)
|
118
|
+
directory = connection.directories.new(:key => 'path1')
|
119
|
+
|
120
|
+
file = directory.files.new(:key => 'path2/.file.rb', :body => "my contents")
|
121
|
+
file.save
|
122
|
+
|
123
|
+
file = directory.files.new(:key => 'path2/.file2.rb', :body => "my contents")
|
124
|
+
file.save
|
125
|
+
file.destroy
|
126
|
+
|
127
|
+
File.exists?(@options[:local_root] + "/path1/path2")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
tests('it stays in the same directory') do
|
132
|
+
returns(Dir.pwd) do
|
133
|
+
connection = Fog::Local::Storage.new(@options)
|
134
|
+
directory = connection.directories.new(:key => 'path1')
|
135
|
+
|
136
|
+
file = directory.files.new(:key => 'path2/file2.rb', :body => "my contents")
|
137
|
+
file.save
|
138
|
+
file.destroy
|
139
|
+
|
140
|
+
Dir.pwd
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
79
144
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Shindo.tests('Storage[:local] | files', ["local"]) do
|
2
|
+
|
3
|
+
pending if Fog.mocking?
|
4
|
+
|
5
|
+
before do
|
6
|
+
@options = { :local_root => Dir.mktmpdir('fog-tests') }
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
FileUtils.remove_entry_secure(@options[:local_root]) if File.directory?(@options[:local_root])
|
11
|
+
end
|
12
|
+
|
13
|
+
tests("#is_truncated") do
|
14
|
+
returns(false) do
|
15
|
+
connection = Fog::Local::Storage.new(@options)
|
16
|
+
directory = connection.directories.create(:key => 'directory')
|
17
|
+
collection = directory.files
|
18
|
+
collection.is_truncated
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -13,7 +13,7 @@ Shindo.tests('Local | storage') do
|
|
13
13
|
tests('#endpoint') do
|
14
14
|
tests('when no endpoint is provided').
|
15
15
|
returns(nil) do
|
16
|
-
Fog::Storage
|
16
|
+
Fog::Local::Storage.new(@options).endpoint
|
17
17
|
end
|
18
18
|
|
19
19
|
tests('when no host is provided').
|
@@ -22,14 +22,14 @@ Shindo.tests('Local | storage') do
|
|
22
22
|
@options[:path] = '/files'
|
23
23
|
@options[:port] = 80
|
24
24
|
|
25
|
-
Fog::Storage
|
25
|
+
Fog::Local::Storage.new(@options).endpoint
|
26
26
|
end
|
27
27
|
|
28
28
|
tests('when endpoint is provided').
|
29
29
|
returns('http://example.com/files') do
|
30
30
|
@options[:endpoint] = 'http://example.com/files'
|
31
31
|
|
32
|
-
Fog::Storage
|
32
|
+
Fog::Local::Storage.new(@options).endpoint
|
33
33
|
end
|
34
34
|
|
35
35
|
tests('when at least host option is provided').
|
@@ -38,7 +38,7 @@ Shindo.tests('Local | storage') do
|
|
38
38
|
@options[:host] = 'example.com'
|
39
39
|
@options[:path] = '/files'
|
40
40
|
|
41
|
-
Fog::Storage
|
41
|
+
Fog::Local::Storage.new(@options).endpoint
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wesley Beary
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -85,7 +85,6 @@ extra_rdoc_files: []
|
|
85
85
|
files:
|
86
86
|
- ".gitignore"
|
87
87
|
- ".ruby-gemset"
|
88
|
-
- ".ruby-version"
|
89
88
|
- ".travis.yml"
|
90
89
|
- CONTRIBUTING.md
|
91
90
|
- CONTRIBUTORS.md
|
@@ -96,13 +95,12 @@ files:
|
|
96
95
|
- fog-local.gemspec
|
97
96
|
- lib/fog/bin/local.rb
|
98
97
|
- lib/fog/local.rb
|
98
|
+
- lib/fog/local/models/directories.rb
|
99
|
+
- lib/fog/local/models/directory.rb
|
100
|
+
- lib/fog/local/models/file.rb
|
101
|
+
- lib/fog/local/models/files.rb
|
99
102
|
- lib/fog/local/storage.rb
|
100
103
|
- lib/fog/local/version.rb
|
101
|
-
- lib/fog/storage/local.rb
|
102
|
-
- lib/fog/storage/local/models/directories.rb
|
103
|
-
- lib/fog/storage/local/models/directory.rb
|
104
|
-
- lib/fog/storage/local/models/file.rb
|
105
|
-
- lib/fog/storage/local/models/files.rb
|
106
104
|
- tests/helper.rb
|
107
105
|
- tests/helpers/collection_helper.rb
|
108
106
|
- tests/helpers/mock_helper.rb
|
@@ -111,6 +109,7 @@ files:
|
|
111
109
|
- tests/local/models/directories_tests.rb
|
112
110
|
- tests/local/models/directory_tests.rb
|
113
111
|
- tests/local/models/file_tests.rb
|
112
|
+
- tests/local/models/files_tests.rb
|
114
113
|
- tests/local/storage_tests.rb
|
115
114
|
- tests/watchr.rb
|
116
115
|
homepage: https://github.com/fog/fog-local
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2.0
|
data/lib/fog/storage/local.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Storage
|
3
|
-
class Local < Fog::Service
|
4
|
-
autoload :Directories, ::File.expand_path('../local/models/directories', __FILE__)
|
5
|
-
autoload :Directory, ::File.expand_path('../local/models/directory', __FILE__)
|
6
|
-
autoload :File, ::File.expand_path('../local/models/file', __FILE__)
|
7
|
-
autoload :Files, ::File.expand_path('../local/models/files', __FILE__)
|
8
|
-
|
9
|
-
requires :local_root
|
10
|
-
recognizes :endpoint, :scheme, :host, :port, :path
|
11
|
-
|
12
|
-
model_path 'fog/storage/local/models'
|
13
|
-
collection :directories
|
14
|
-
model :directory
|
15
|
-
model :file
|
16
|
-
collection :files
|
17
|
-
|
18
|
-
require 'uri'
|
19
|
-
|
20
|
-
class Mock
|
21
|
-
attr_reader :endpoint
|
22
|
-
|
23
|
-
def self.data
|
24
|
-
@data ||= Hash.new do |hash, key|
|
25
|
-
hash[key] = {}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.reset
|
30
|
-
@data = nil
|
31
|
-
end
|
32
|
-
|
33
|
-
def initialize(options={})
|
34
|
-
Fog::Mock.not_implemented
|
35
|
-
|
36
|
-
@local_root = ::File.expand_path(options[:local_root])
|
37
|
-
|
38
|
-
@endpoint = options[:endpoint] || build_endpoint_from_options(options)
|
39
|
-
end
|
40
|
-
|
41
|
-
def data
|
42
|
-
self.class.data[@local_root]
|
43
|
-
end
|
44
|
-
|
45
|
-
def local_root
|
46
|
-
@local_root
|
47
|
-
end
|
48
|
-
|
49
|
-
def path_to(partial)
|
50
|
-
::File.join(@local_root, partial)
|
51
|
-
end
|
52
|
-
|
53
|
-
def reset_data
|
54
|
-
self.class.data.delete(@local_root)
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
def build_endpoint_from_options(options)
|
59
|
-
return unless options[:host]
|
60
|
-
|
61
|
-
URI::Generic.build(options).to_s
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class Real
|
66
|
-
attr_reader :endpoint
|
67
|
-
|
68
|
-
def initialize(options={})
|
69
|
-
@local_root = ::File.expand_path(options[:local_root])
|
70
|
-
|
71
|
-
@endpoint = options[:endpoint] || build_endpoint_from_options(options)
|
72
|
-
end
|
73
|
-
|
74
|
-
def local_root
|
75
|
-
@local_root
|
76
|
-
end
|
77
|
-
|
78
|
-
def path_to(partial)
|
79
|
-
::File.join(@local_root, partial)
|
80
|
-
end
|
81
|
-
|
82
|
-
def copy_object(source_directory_name, source_object_name, target_directory_name, target_object_name, options={})
|
83
|
-
source_path = path_to(::File.join(source_directory_name, source_object_name))
|
84
|
-
target_path = path_to(::File.join(target_directory_name, target_object_name))
|
85
|
-
::FileUtils.mkdir_p(::File.dirname(target_path))
|
86
|
-
::FileUtils.copy_file(source_path, target_path)
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
def build_endpoint_from_options(options)
|
91
|
-
return unless options[:host]
|
92
|
-
|
93
|
-
URI::Generic.build(options).to_s
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|