s3itch_client 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
+ - 2.0.0
7
8
  - jruby-18mode
8
9
  - jruby-19mode
9
10
  - rbx-18mode
@@ -1,3 +1,3 @@
1
1
  module S3itchClient
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/s3itch_client.rb CHANGED
@@ -20,7 +20,7 @@ module S3itchClient
20
20
  password = options[:password]
21
21
 
22
22
  if File.exists?(filepath) && !File.directory?(filepath)
23
- uniq_name = build_unique_name(filepath, options[:parameterize])
23
+ uniq_name = build_unique_name(filepath, options[:parameterize], options[:use_timestamp_suffix])
24
24
 
25
25
  uri.path = "/#{uniq_name}"
26
26
 
@@ -49,15 +49,19 @@ module S3itchClient
49
49
  end
50
50
  end
51
51
 
52
- def self.build_unique_name(filepath, to_param=false)
52
+ def self.build_unique_name(filepath, to_param=false, use_timestamp_suffix=false)
53
53
  filename = File.basename(filepath)
54
54
  extname = File.extname(filename)
55
55
  basename = File.basename(filename, extname)
56
56
 
57
- # Ruby 1.8.7 compatibility
58
- uuid = SecureRandom.respond_to?(:uuid) ? SecureRandom.uuid : SecureRandom.hex
57
+ suffix = if use_timestamp_suffix
58
+ Time.now.to_i.to_s(36)
59
+ else
60
+ # Ruby 1.8.7 compatibility
61
+ SecureRandom.respond_to?(:uuid) ? SecureRandom.uuid : SecureRandom.hex
62
+ end
59
63
 
60
- uniq_name = "#{basename}_#{uuid}"
64
+ uniq_name = "#{basename}_#{suffix}"
61
65
  uniq_name = parameterize(uniq_name) if to_param
62
66
  uniq_name << extname
63
67
 
@@ -33,6 +33,12 @@ describe S3itchClient do
33
33
  name.should match(/\Akitten_[\da-z-]{32,36}\.jpeg\z/)
34
34
  end
35
35
 
36
+ it "uses a timestamp instead of a UUID if required to" do
37
+ name = S3itchClient.build_unique_name(kitten_path, false, true)
38
+ name.should match(/\Akitten_[\da-z]+\.jpeg\z/)
39
+ name.should_not match(/\Akitten_[\da-z-]{32,36}\.jpeg\z/)
40
+ end
41
+
36
42
  it "URI encodes the file name" do
37
43
  name = S3itchClient.build_unique_name("/tmp/cute kitten.jpeg")
38
44
  name.should match(/\Acute%20kitten_[\da-z-]{32,36}\.jpeg\z/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3itch_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.6.1
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.6.1
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :development
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
@@ -56,7 +56,7 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
@@ -141,24 +141,24 @@ require_paths:
141
141
  required_ruby_version: !ruby/object:Gem::Requirement
142
142
  none: false
143
143
  requirements:
144
- - - ! '>='
144
+ - - '>='
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: -3640099612951680876
149
+ hash: 2323134864524827593
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements:
153
- - - ! '>='
153
+ - - '>='
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  segments:
157
157
  - 0
158
- hash: -3640099612951680876
158
+ hash: 2323134864524827593
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 1.8.24
161
+ rubygems_version: 1.8.25
162
162
  signing_key:
163
163
  specification_version: 3
164
164
  summary: Upload files to S3 via your own s3itch instance