second_curtain 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/CHANGELOG +4 -0
- data/lib/second_curtain/path_utils.rb +21 -0
- data/lib/second_curtain/upload.rb +6 -5
- data/lib/second_curtain/upload_manager.rb +3 -2
- data/second_curtain.gemspec +1 -1
- data/spec/second_shutter/path_utils_spec.rb +32 -0
- data/spec/second_shutter/upload_spec.rb +2 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5fabcd6cadb0d6ce87051406d8f56f7e2aa01e2
|
4
|
+
data.tar.gz: 6b5fb2e39c035d03252f292517abafcd7b182a66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d44d903cb8be3f133d2dcea9db5de598b7d78127d1ead3a8bc9bbf6ec7c4e6fecbc53a249ac543c0cb672f39276aec4d8c38010fb973ee4d448a2dc5bab0338
|
7
|
+
data.tar.gz: e8e2d625cd39dbdac828e689c9ff4f78da7adb236cfab89d54743e91e39603972eb1baf516563e91f826fd15a217eb3023b2f10e6007b541e889665756620133
|
data/CHANGELOG
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
class PathUtils
|
2
|
+
|
3
|
+
# Returns a path composed of components, without leading and trailing slashes
|
4
|
+
def self.pathWithComponents(components)
|
5
|
+
path = ""
|
6
|
+
|
7
|
+
for component in components do
|
8
|
+
path = self.sanitizePathComponent(path + "/" + self.sanitizePathComponent(component))
|
9
|
+
end
|
10
|
+
|
11
|
+
return path
|
12
|
+
end
|
13
|
+
|
14
|
+
:private
|
15
|
+
|
16
|
+
# Takes a path component and strips leading and trailing slashes
|
17
|
+
def self.sanitizePathComponent(component)
|
18
|
+
# Remove leading and trailing slash
|
19
|
+
component.gsub(/^\//, "").chomp("/")
|
20
|
+
end
|
21
|
+
end
|
@@ -2,6 +2,7 @@ require 'aws-sdk-v1'
|
|
2
2
|
require 'date'
|
3
3
|
require 'pathname'
|
4
4
|
require 'uri'
|
5
|
+
require 'second_curtain/path_utils'
|
5
6
|
|
6
7
|
class Upload
|
7
8
|
attr_reader :expected_path
|
@@ -19,13 +20,13 @@ class Upload
|
|
19
20
|
abort unless path
|
20
21
|
|
21
22
|
expected_filename = Pathname.new(@expected_path).basename.to_s
|
22
|
-
expected_object = bucket.objects[path
|
23
|
+
expected_object = bucket.objects[PathUtils.pathWithComponents([path, expected_filename])]
|
23
24
|
expected_object.write(:file => @expected_path)
|
24
|
-
@uploaded_expected_url =
|
25
|
+
@uploaded_expected_url = expected_filename
|
25
26
|
|
26
27
|
actual_filename = Pathname.new(@actual_path).basename.to_s
|
27
|
-
actual_object = bucket.objects[path
|
28
|
+
actual_object = bucket.objects[PathUtils.pathWithComponents([path, actual_filename])]
|
28
29
|
actual_object.write(:file => @actual_path)
|
29
|
-
@uploaded_actual_url =
|
30
|
+
@uploaded_actual_url = actual_filename
|
30
31
|
end
|
31
|
-
end
|
32
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'aws-sdk-v1'
|
2
2
|
require 'second_curtain/upload'
|
3
3
|
require 'second_curtain/web_preview'
|
4
|
+
require 'second_curtain/path_utils'
|
4
5
|
|
5
6
|
class UploadManager
|
6
7
|
def initialize (bucket, path_prefix)
|
@@ -20,11 +21,11 @@ class UploadManager
|
|
20
21
|
return nil unless @uploads.count > 0
|
21
22
|
|
22
23
|
@uploads.each do |upload|
|
23
|
-
upload.upload(@bucket, @path_prefix)
|
24
|
+
upload.upload(@bucket, PathUtils.pathWithComponents([@path_prefix, folder_name]))
|
24
25
|
end
|
25
26
|
|
26
27
|
preview = WebPreview.new(@uploads)
|
27
|
-
index_object = @bucket.objects[@path_prefix
|
28
|
+
index_object = @bucket.objects[PathUtils.pathWithComponents([@path_prefix, folder_name, "index.html"])]
|
28
29
|
index_object.write(preview.generate_html)
|
29
30
|
index_object.public_url.to_s
|
30
31
|
end
|
data/second_curtain.gemspec
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require './lib/second_curtain/path_utils.rb'
|
2
|
+
|
3
|
+
describe PathUtils do
|
4
|
+
before(:each) do
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "composing a path" do
|
8
|
+
it "yields a concatenation of these components without leading and trailing slashes" do
|
9
|
+
expect(PathUtils.pathWithComponents(["component1", "component2"])).to eq("component1/component2")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "yields a concatenation of these components without leading and trailing slashes" do
|
13
|
+
expect(PathUtils.pathWithComponents(["/component1/component1b/", "/component2/"])).to eq("component1/component1b/component2")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "yields an empty string when called without components" do
|
17
|
+
expect(PathUtils.pathWithComponents([])).to eq("")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "yields a string without leading slash when called with an empty first component" do
|
21
|
+
expect(PathUtils.pathWithComponents(["", "/component2"])).to eq("component2")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "yields a string without trailing slash when called with an empty last component" do
|
25
|
+
expect(PathUtils.pathWithComponents(["component1", ""])).to eq("component1")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "yields an empty string when called with a single slash" do
|
29
|
+
expect(PathUtils.pathWithComponents(["/"])).to eq("")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -21,14 +21,12 @@ describe Upload do
|
|
21
21
|
expect(bucket).to receive(:objects).twice.and_return(doubles)
|
22
22
|
|
23
23
|
expect(expected_double).to receive(:write).with(anything)
|
24
|
-
expect(expected_double).to receive(:public_url).and_return("http://exmaple.com/1.png")
|
25
24
|
expect(actual_double).to receive(:write).with(anything)
|
26
|
-
expect(actual_double).to receive(:public_url).and_return("http://exmaple.com/2.png")
|
27
25
|
|
28
26
|
upload = Upload.new('/path/to/expected.png', '/path/to/actual.png')
|
29
27
|
upload.upload(bucket, path)
|
30
28
|
|
31
|
-
expect(upload.uploaded_expected_url).to eq("
|
32
|
-
expect(upload.uploaded_actual_url).to eq("
|
29
|
+
expect(upload.uploaded_expected_url).to eq("expected.png")
|
30
|
+
expect(upload.uploaded_actual_url).to eq("actual.png")
|
33
31
|
end
|
34
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: second_curtain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-v1
|
@@ -360,6 +360,7 @@ files:
|
|
360
360
|
- lib/second_curtain.rb
|
361
361
|
- lib/second_curtain/kaleidoscope_command.rb
|
362
362
|
- lib/second_curtain/parser.rb
|
363
|
+
- lib/second_curtain/path_utils.rb
|
363
364
|
- lib/second_curtain/template.mustache.html
|
364
365
|
- lib/second_curtain/test_suite.rb
|
365
366
|
- lib/second_curtain/upload.rb
|
@@ -370,6 +371,7 @@ files:
|
|
370
371
|
- spec/sample_output.txt
|
371
372
|
- spec/second_shutter/kaleidoscope_command_spec.rb
|
372
373
|
- spec/second_shutter/parser_spec.rb
|
374
|
+
- spec/second_shutter/path_utils_spec.rb
|
373
375
|
- spec/second_shutter/test_suite_spec.rb
|
374
376
|
- spec/second_shutter/upload_manager_spec.rb
|
375
377
|
- spec/second_shutter/upload_spec.rb
|