fog-local 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c69d946b2a7de10fc8195037b60dded5185f7bf0
4
- data.tar.gz: b9fff78f47860cde5aa0523f3837c734a47caeec
3
+ metadata.gz: 6de6094d73b2a0014751ef203cc33a8d590ce990
4
+ data.tar.gz: cfa04eef4ac8c4a770416c898c06ac16878b9dca
5
5
  SHA512:
6
- metadata.gz: 7d4bd0e20c6d480fffd203ca649d324eea3dee6354ed8fe7637ad6482496d9690c82f57259afcccb7b2c70192e377fef566fbe6c1216caa1508b35fa812cbaed
7
- data.tar.gz: 858ebc527c24c03434d0e831168a6227c6c0d0b33a9324e851e714f25666e8ea6cc0fe7e6fb18b58875b9abd64ebfa03270dd4dd569038b7819da96a72846f61
6
+ metadata.gz: 06ab581be51ec5b35aaf9490b8009875adb9144e984969f7ae2847523ad34b3a9e174779cf7471a6c5610ba7f6c41da84223c6c0b907abe4f6e11babd612e153
7
+ data.tar.gz: f2df07d4bb2ff57f19eed3663560050fd864c56eb443414f0ad20ba76bc7b58e96a943ed62c3860ff32be8870875106a98a07b0a011ba81a9eb34fb00bd4ed58
@@ -0,0 +1 @@
1
+ fog-local
@@ -0,0 +1 @@
1
+ 2.2.0
data/Rakefile CHANGED
@@ -3,6 +3,8 @@ require "bundler/gem_tasks"
3
3
  task :default => :test
4
4
 
5
5
  mock = ENV['FOG_MOCK'] || 'false'
6
+
7
+ desc "Run tests"
6
8
  task :test do
7
9
  sh("export FOG_MOCK=#{mock} && bundle exec shindont")
8
10
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Local
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -98,15 +98,12 @@ module Fog
98
98
  raise unless ::File.directory?(dir_path)
99
99
  end
100
100
  end
101
- file = ::File.new(path, 'wb')
102
- if body.is_a?(String)
103
- file.write(body)
104
- elsif body.kind_of? ::File and ::File.exist?(body.path)
101
+ if body.kind_of? ::File and ::File.exist?(body.path)
105
102
  FileUtils.cp(body.path, path)
106
103
  else
107
- file.write(body.read)
104
+ write_file(path, body)
108
105
  end
109
- file.close
106
+
110
107
  merge_attributes(
111
108
  :content_length => Fog::Storage.get_body_size(body),
112
109
  :last_modified => ::File.mtime(path)
@@ -123,6 +120,15 @@ module Fog
123
120
  def path
124
121
  service.path_to(::File.join(directory.key, key))
125
122
  end
123
+
124
+ def write_file(path, content)
125
+ input_io = StringIO.new(content) if content.is_a?(String)
126
+ input_io ||= content
127
+
128
+ ::File.open(path, 'wb') do |file|
129
+ IO.copy_stream(input_io, file)
130
+ end
131
+ end
126
132
  end
127
133
  end
128
134
  end
@@ -37,15 +37,16 @@ module Fog
37
37
  :key => key,
38
38
  :last_modified => ::File.mtime(path)
39
39
  }
40
- if block_given?
41
- file = ::File.open(path)
42
- while (chunk = file.read(Excon::CHUNK_SIZE)) && yield(chunk); end
43
- file.close
44
- new(data)
45
- else
46
- body = ::File.read(path)
47
- new(data.merge!(:body => body))
40
+
41
+ body = ""
42
+ ::File.open(path) do |file|
43
+ while (chunk = file.read(Excon::CHUNK_SIZE)) && (!block_given? || (block_given? && yield(chunk)))
44
+ body << chunk
45
+ end
48
46
  end
47
+ data.merge!(:body => body) if !block_given?
48
+
49
+ new(data)
49
50
  else
50
51
  nil
51
52
  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.2.1
4
+ version: 0.3.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: 2015-04-10 00:00:00.000000000 Z
12
+ date: 2016-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -78,6 +78,8 @@ extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
80
  - ".gitignore"
81
+ - ".ruby-gemset"
82
+ - ".ruby-version"
81
83
  - ".travis.yml"
82
84
  - CONTRIBUTING.md
83
85
  - CONTRIBUTORS.md
@@ -128,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
130
  version: '0'
129
131
  requirements: []
130
132
  rubyforge_project:
131
- rubygems_version: 2.4.5
133
+ rubygems_version: 2.4.6
132
134
  signing_key:
133
135
  specification_version: 4
134
136
  summary: Module for the 'fog' gem to support local filesystem storage.