second_curtain 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDY0ZDVlNDY1MDRmMWYzNGE3NTAwZDUwYmQ5M2M2MjcyNTI4YTFjOQ==
4
+ NTNiMzEzMDRlOWI1OGU2OGQxMjIwM2MxNDA4OTQzNmZlNjQ5ZDAxZg==
5
5
  data.tar.gz: !binary |-
6
- YTA0ZDI3ZDZlM2U0ZmJmNDI4YTI5OWNmZjVhNjMxNjhiMTUxNGRiZg==
6
+ MzBmMTNlMTU4NTliNTE2ZWQ1NWY2OGI4ODE4ZDUxZmVkY2MxNmRlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTUzOTNhMWZkNjY1NmIxZGEwNjE3NGEwMDI2MmI3YjNjN2NkYTI2YzgzYTcz
10
- NWZlOGNkZTI5OWUyMzZmZTFjOTZhMDZmMjFlYmUzM2ZlNzhkZDUwYzJlNGEy
11
- ZjFlOTczNTM3N2FkZmY3ZjFkMjFmNDk3ZGQ4YzlkMmMwY2NmYjI=
9
+ ZWE4NTRhZjAyMmJkOTBhOGUyM2UzMWU0OTNlZjEyNDUzNWQ2MzczNTA0ODRh
10
+ ZDFiNWVlNWQ0YTBkYzI4NmUyZGNiZmU1NWQwNDk5NThlZDhmNjUyYWRjZmQ3
11
+ OWNhYWEyYmY4YWRiMmMyMjQ0NWY5YjYzOWM4ZjJlYTAwZjlhODU=
12
12
  data.tar.gz: !binary |-
13
- M2EwMDRmODI2ZDFhYTcyOTJhMWRmNGY1MzE4NDk4NjUxYTQxNDk2MDM3YzY0
14
- Mzg3YzUyMjIxNTA2ZDlmOWFlZjFjZmU3MzAwOWNkZTYwYjAxZTM2ZjU1Y2Fh
15
- YWNkOTE1M2Y3YzEwOTE2Yzk1M2NkMmI3Y2ZmYWMwMzdmYjk5ZTU=
13
+ NWMzYjk2ODI3OGNjMGU2YzM1YzA1MmQ3ODAyNjUzNTFmMGZiNWZkNGFmOWRk
14
+ NGE5MjIxNjBiZDdlMWQwMjNhN2JkNTM2MmI5NjVkY2E1YzNjZjA3M2Q4NzY4
15
+ NWYwY2EyODZlMDdlM2Q2YTg0MDE4NTc4NGYzZTk3MjE0MjM5ZGQ=
data/bin/second_curtain CHANGED
@@ -2,45 +2,57 @@
2
2
 
3
3
  require 'second_curtain'
4
4
 
5
+ input = []
6
+
7
+ ARGF.each_line do |line|
8
+ input.push(line)
9
+ print line
10
+ end
11
+
5
12
  bucket_name = ENV['UPLOAD_IOS_SNAPSHOT_BUCKET_NAME']
6
13
 
7
14
  if bucket_name == nil
8
- abort "error: bucket name must be specified in environment UPLOAD_IOS_SNAPSHOT_BUCKET_NAME variable"
15
+ abort "error: Second Curtain bucket name must be specified in environment UPLOAD_IOS_SNAPSHOT_BUCKET_NAME variable".red
9
16
  end
10
17
 
11
18
  aws_key = ENV['AWS_ACCESS_KEY_ID']
12
19
  aws_secret = ENV['AWS_SECRET_ACCESS_KEY']
13
20
  if aws_key == nil || aws_secret == nil
14
- abort "error: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be defined as environment variables"
21
+ abort "error: Second Curtain AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be defined as environment variables".red
15
22
  end
16
23
 
17
24
  path_prefix = ENV['UPLOAD_IOS_SNAPSHOT_BUCKET_PREFIX'] || '/'
18
25
  if !path_prefix.end_with?('/')
19
- path_prefix += '/'
26
+ path_prefix += '/'
27
+ end
28
+
29
+ folder_name = ENV['UPLOAD_IOS_SNAPSHOT_FOLDER_NAME']
30
+ if !folder_name
31
+ folder_name = ENV['TRAVIS_JOB_ID']
32
+ end
33
+
34
+ if !folder_name
35
+ now = DateTime.now()
36
+ folder_name = now.strftime('%Y-%m-%d--%H-%M')
20
37
  end
21
38
 
22
39
  s3 = AWS::S3.new
23
40
  bucket = s3.buckets[bucket_name]
24
41
  manager = UploadManager.new(bucket, path_prefix)
25
42
 
26
- ARGF.each_line do |line|
27
- if line.start_with?('ksdiff')
28
- parts = line.split(/"/)
29
- if (parts.count >= 4)
30
- expected_path = parts[1]
31
- actual_path = parts[3]
32
- manager.enqueue_upload(expected_path, actual_path)
33
- end
34
- end
35
-
36
- # Print the line normally, saving output for the end
37
- print line
43
+ input.each do |line|
44
+ if line.start_with?('ksdiff')
45
+ parts = line.split(/"/)
46
+ if (parts.count >= 4)
47
+ expected_path = parts[1]
48
+ actual_path = parts[3]
49
+ manager.enqueue_upload(expected_path, actual_path)
50
+ end
51
+ end
38
52
  end
39
53
 
40
- now = DateTime.now()
41
- folder_name = now.strftime('%Y-%m-%d--%H-%M')
42
54
 
43
55
  failures_address = manager.upload(folder_name)
44
56
  if failures_address
45
- $stderr.puts "Failures: " + failures_address
57
+ $stderr.puts "Failures: " + failures_address
46
58
  end
@@ -4,32 +4,32 @@ require 'pathname'
4
4
  require 'uri'
5
5
 
6
6
  class Upload
7
- attr_reader :expected_path
8
- attr_reader :actual_path
9
- attr_accessor :uploaded_expected_url
10
- attr_accessor :uploaded_actual_url
7
+ attr_reader :expected_path
8
+ attr_reader :actual_path
9
+ attr_accessor :uploaded_expected_url
10
+ attr_accessor :uploaded_actual_url
11
11
 
12
- def initialize(expected_path, actual_path)
13
- @expected_path = expected_path
14
- @actual_path = actual_path
15
- end
12
+ def initialize(expected_path, actual_path)
13
+ @expected_path = expected_path
14
+ @actual_path = actual_path
15
+ end
16
16
 
17
- def upload(bucket, path)
18
- abort unless bucket
19
- abort unless path
17
+ def upload(bucket, path)
18
+ abort unless bucket
19
+ abort unless path
20
20
 
21
- expected_filename = Pathname.new(@expected_path).basename.to_s
22
- expected_object = bucket.objects[path + "/" + expected_filename]
23
- expected_object.write(:file => @expected_path)
24
- @uploaded_expected_url = expected_object.url_for(:read)
21
+ expected_filename = Pathname.new(@expected_path).basename.to_s
22
+ expected_object = bucket.objects[path + "/" + expected_filename]
23
+ expected_object.write(:file => @expected_path)
24
+ @uploaded_expected_url = expected_object.url_for(:read)
25
25
 
26
- actual_filename = Pathname.new(@actual_path).basename.to_s
27
- actual_object = bucket.objects[path + "/" + actual_filename]
28
- actual_object.write(:file => @actual_path)
29
- @uploaded_actual_url = actual_object.url_for(:read)
30
- end
26
+ actual_filename = Pathname.new(@actual_path).basename.to_s
27
+ actual_object = bucket.objects[path + "/" + actual_filename]
28
+ actual_object.write(:file => @actual_path)
29
+ @uploaded_actual_url = actual_object.url_for(:read)
30
+ end
31
31
 
32
- def to_html
33
- "<li><a href='#{ @uploaded_expected_url.to_s }'>Expected</a>, <a href='#{ @uploaded_actual_url.to_s }'>Actual</li>"
34
- end
32
+ def to_html
33
+ "<li><a href='#{ @uploaded_expected_url.to_s }'>Expected</a>, <a href='#{ @uploaded_actual_url.to_s }'>Actual</li>"
34
+ end
35
35
  end
@@ -2,32 +2,32 @@ require 'aws-sdk'
2
2
  require 'upload'
3
3
 
4
4
  class UploadManager
5
- def initialize (bucket, path_prefix)
6
- abort "error: must supply an S3 bucket" unless bucket
7
- abort "error: must supply a path prefix of at least '/'" unless path_prefix
5
+ def initialize (bucket, path_prefix)
6
+ abort "error: Second Curtain must supply an S3 bucket".red unless bucket
7
+ abort "error: Second Curtain must supply a path prefix of at least '/'".re unless path_prefix
8
8
 
9
- @uploads = []
10
- @path_prefix = path_prefix
11
- @bucket = bucket
12
- end
9
+ @uploads = []
10
+ @path_prefix = path_prefix
11
+ @bucket = bucket
12
+ end
13
13
 
14
- def enqueue_upload(expected_path, actual_path)
15
- @uploads.push(Upload.new(expected_path, actual_path))
16
- end
14
+ def enqueue_upload(expected_path, actual_path)
15
+ @uploads.push(Upload.new(expected_path, actual_path))
16
+ end
17
17
 
18
- def upload(folder_name)
19
- return nil unless @uploads.count > 0
18
+ def upload(folder_name)
19
+ return nil unless @uploads.count > 0
20
20
 
21
- @uploads.each do |upload|
22
- upload.upload(@bucket, @path_prefix)
23
- end
21
+ @uploads.each do |upload|
22
+ upload.upload(@bucket, @path_prefix)
23
+ end
24
24
 
25
- index_object = @bucket.objects[@path_prefix + folder_name + "/index.html"]
26
- index_object.write(to_html)
27
- index_object.url_for(:read).to_s
28
- end
25
+ index_object = @bucket.objects[@path_prefix + folder_name + "/index.html"]
26
+ index_object.write(to_html)
27
+ index_object.url_for(:read).to_s
28
+ end
29
29
 
30
- def to_html
31
- "<html><body>#{@uploads.map(&:to_html).join}</body></html>"
32
- end
30
+ def to_html
31
+ "<html><body>#{@uploads.map(&:to_html).join}</body></html>"
32
+ end
33
33
  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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Furrow
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.48'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colored
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
27
41
  description: ! "\n If you're using the cool FBSnapshotTestCase to test your iOS view
28
42
  logic, awesome! Even better if you have continuous integration, like on Travis,
29
43
  to automate running those tests!\n\n Wouldn't it be awesome if we could upload