remote_files 2.0.0 → 2.0.1

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.
@@ -18,7 +18,7 @@ module RemoteFiles
18
18
 
19
19
  FileUtils.mkdir_p(file_name.parent)
20
20
 
21
- file_name.open('w') do |f|
21
+ file_name.open('wb') do |f|
22
22
  if file.content.respond_to?(:read)
23
23
  while blk = file.content.read(2048)
24
24
  f << blk
@@ -35,7 +35,7 @@ module RemoteFiles
35
35
  def url(identifier)
36
36
  case options[:provider]
37
37
  when 'AWS'
38
- "https://s3.amazonaws.com/#{directory_name}/#{Fog::AWS.escape(identifier)}"
38
+ "https://#{aws_host}/#{directory_name}/#{Fog::AWS.escape(identifier)}"
39
39
  when 'Rackspace'
40
40
  "https://storage.cloudfiles.com/#{directory_name}/#{Fog::Rackspace.escape(identifier, '/')}"
41
41
  else
@@ -77,6 +77,15 @@ module RemoteFiles
77
77
 
78
78
  protected
79
79
 
80
+ def aws_host
81
+ case options[:region]
82
+ when nil, 'us-east-1'
83
+ 's3.amazonaws.com'
84
+ else
85
+ "s3-#{options[:region]}.amazonaws.com"
86
+ end
87
+ end
88
+
80
89
  def lookup_directory
81
90
  connection.directories.get(directory_name)
82
91
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteFiles
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -95,6 +95,14 @@ describe RemoteFiles::FogStore do
95
95
  it 'should return an S3 url' do
96
96
  @store.url('identifier').must_equal('https://s3.amazonaws.com/directory/identifier')
97
97
  end
98
+
99
+ describe 'in a different region' do
100
+ before { @store.options[:region] = 'us-west-1' }
101
+
102
+ it 'should return an S3 url' do
103
+ @store.url('identifier').must_equal('https://s3-us-west-1.amazonaws.com/directory/identifier')
104
+ end
105
+ end
98
106
  end
99
107
 
100
108
  describe 'for CloudFiles connections' do
@@ -161,7 +169,7 @@ describe RemoteFiles::FogStore do
161
169
  @store.directory.files.create(
162
170
  :body => 'content',
163
171
  :content_type => 'text/plain',
164
- :key => 'identifier',
172
+ :key => 'identifier'
165
173
  )
166
174
  end
167
175
 
@@ -1,13 +1,16 @@
1
1
  require 'bundler/setup'
2
2
 
3
- require 'debugger'
3
+ begin
4
+ require 'debugger'
5
+ rescue LoadError => e
6
+ end
4
7
 
5
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
9
  require 'remote_files'
7
10
 
8
11
  require 'minitest/autorun'
9
12
 
10
- require 'mocha'
13
+ require 'mocha/setup'
11
14
 
12
15
  Fog.mock!
13
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
12
+ date: 2013-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -147,15 +147,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  - - ! '>='
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
+ segments:
151
+ - 0
152
+ hash: 2260676373008999041
150
153
  required_rubygems_version: !ruby/object:Gem::Requirement
151
154
  none: false
152
155
  requirements:
153
156
  - - ! '>='
154
157
  - !ruby/object:Gem::Version
155
158
  version: '0'
159
+ segments:
160
+ - 0
161
+ hash: 2260676373008999041
156
162
  requirements: []
157
163
  rubyforge_project:
158
- rubygems_version: 1.8.24
164
+ rubygems_version: 1.8.25
159
165
  signing_key:
160
166
  specification_version: 3
161
167
  summary: The purpose of the library is to implement a simple interface for uploading