remote_files 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,10 @@ module RemoteFiles
14
14
  options[name] = value
15
15
  end
16
16
 
17
+ def to_sym
18
+ @identifier.to_sym
19
+ end
20
+
17
21
  def directory_name
18
22
  raise "You need to implement #{self.class.name}:#directory_name"
19
23
  end
@@ -45,7 +49,7 @@ module RemoteFiles
45
49
 
46
50
  file_identifier = CGI.unescape(matched[1])
47
51
 
48
- RemoteFiles::File.new(file_identifier, options.merge(:stored_in => [identifier]))
52
+ RemoteFiles::File.new(file_identifier, options.merge(:stored_in => [self]))
49
53
  end
50
54
  end
51
55
  end
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'fileutils'
2
3
 
3
4
  # This is good for use in deveopment
4
5
 
@@ -13,7 +14,11 @@ module RemoteFiles
13
14
  end
14
15
 
15
16
  def store!(file)
16
- (directory + file.identifier).open('w') do |f|
17
+ file_name = directory + file.identifier
18
+
19
+ FileUtils.mkdir_p(file_name.parent)
20
+
21
+ file_name.open('w') do |f|
17
22
  f.write(file.content)
18
23
  # what about content-type?
19
24
  end
@@ -24,7 +29,7 @@ module RemoteFiles
24
29
 
25
30
  RemoteFiles::File.new(identifier,
26
31
  :content => content,
27
- :stored_in => [self.identifier]
32
+ :stored_in => [self]
28
33
  # what about content-type? maybe use the mime-types gem?
29
34
  )
30
35
  rescue Errno::ENOENT => e
@@ -26,7 +26,7 @@ module RemoteFiles
26
26
  File.new(identifier,
27
27
  :content => fog_file.body,
28
28
  :content_type => fog_file.content_type,
29
- :stored_in => [self.identifier]
29
+ :stored_in => [self]
30
30
  )
31
31
  rescue Fog::Errors::Error, Excon::Errors::Error
32
32
  raise RemoteFiles::Error, $!.message, $!.backtrace
@@ -30,7 +30,7 @@ module RemoteFiles
30
30
  File.new(identifier,
31
31
  :content => data[identifier][:content],
32
32
  :content_type => data[identifier][:content_type],
33
- :stored_in => [self.identifier]
33
+ :stored_in => [self]
34
34
  )
35
35
  end
36
36
 
@@ -1,3 +1,3 @@
1
1
  module RemoteFiles
2
- VERSION = '1.5.0'
2
+ VERSION = '1.5.1'
3
3
  end
@@ -11,13 +11,13 @@ describe RemoteFiles::FileStore do
11
11
 
12
12
  describe '#store!' do
13
13
  before do
14
- @file = RemoteFiles::File.new('identifier', :content_type => 'text/plain', :content => 'content')
14
+ @file = RemoteFiles::File.new('foo/identifier', :content_type => 'text/plain', :content => 'content')
15
15
  end
16
16
 
17
17
  it 'should store the file on disk' do
18
18
  @store.store!(@file)
19
19
 
20
- file_path = @directory + 'identifier'
20
+ file_path = @directory + 'foo/identifier'
21
21
  file_path.exist?
22
22
 
23
23
  assert_equal 'content', file_path.read
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: 1.5.0
4
+ version: 1.5.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: 2012-11-06 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: 708350776970309851
151
+ hash: -2269373992954877805
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  none: false
154
154
  requirements:
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  segments:
159
159
  - 0
160
- hash: 708350776970309851
160
+ hash: -2269373992954877805
161
161
  requirements: []
162
162
  rubyforge_project:
163
163
  rubygems_version: 1.8.24