upload-ios-snapshot-test-case 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzZjNzMxNTgzMmFjMDlmNTU2YmE5ODJlMjFhYzQyOTc4Y2QxNDg5YQ==
5
+ data.tar.gz: !binary |-
6
+ MGNlOTQ1MjY4MDdjYTU4NzE1NjMxZWY3ZTY1OWMwZDhlNGI0N2NjNQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YWM1ODExMDM3NThkZmRhMjRhOGIzOTgzMTRhMWI3MGM4MTk5ODkyZjc4ZTNi
10
+ ZTQ2ODNjMjJlOTBkYzU4ODZlYjU2NWZlNTUwYWRjMmEzMDIxZjQ0YmU1ZWIx
11
+ NzIzMjdkOWE3YmVkYzNjNGFhMDQxNGEwMDJlMTQwMDdhYjZlZGU=
12
+ data.tar.gz: !binary |-
13
+ OWE2ZDk1ZTBiNTA3Yjg3YmE1YTZmNjA0OTFmNjJlNzBmNThmZDM3MTUwNTg3
14
+ ZDY5MDNlYTlhNWEwNjc1Nzg1MTI3OGI0MDZhNTdlY2ZkMmRiNWI1MWRmNDM1
15
+ OTUwNTkwNjU1ZWNiNzk5MGZlN2EyZjJiYjZmMDE4NmM1YWQzOTE=
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'upload-ios-snapshot-test-case'
4
+
5
+ bucket_name = ENV['UPLOAD_IOS_SNAPSHOT_BUCKET_NAME']
6
+
7
+ if bucket_name == nil
8
+ abort "error: bucket name must be specified in environment UPLOAD_IOS_SNAPSHOT_BUCKET_NAME variable"
9
+ end
10
+
11
+ aws_key = ENV['AWS_ACCESS_KEY_ID']
12
+ aws_secret = ENV['AWS_SECRET_ACCESS_KEY']
13
+ 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"
15
+ end
16
+
17
+ path_prefix = ENV['UPLOAD_IOS_SNAPSHOT_BUCKET_PREFIX'] || '/'
18
+ if !path_prefix.end_with?('/')
19
+ path_prefix += '/'
20
+ end
21
+
22
+ s3 = AWS::S3.new
23
+ bucket = s3.buckets[bucket_name]
24
+ manager = UploadManager.new(bucket, path_prefix)
25
+
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
38
+ end
39
+
40
+ now = DateTime.now()
41
+ folder_name = now.strftime('%Y-%m-%d--%H-%M')
42
+
43
+ failures_address = manager.upload(folder_name)
44
+ if failures_address
45
+ $stderr.puts "Failures: " + failures_address
46
+ end
@@ -0,0 +1,2 @@
1
+ require 'upload'
2
+ require 'upload_manager'
@@ -0,0 +1,35 @@
1
+ require 'aws-sdk'
2
+ require 'date'
3
+ require 'pathname'
4
+ require 'uri'
5
+
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
11
+
12
+ def initialize(expected_path, actual_path)
13
+ @expected_path = expected_path
14
+ @actual_path = actual_path
15
+ end
16
+
17
+ def upload(bucket, path)
18
+ abort unless bucket
19
+ abort unless path
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)
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
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
35
+ end
@@ -0,0 +1,33 @@
1
+ require 'aws-sdk'
2
+ require 'upload'
3
+
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
8
+
9
+ @uploads = []
10
+ @path_prefix = path_prefix
11
+ @bucket = bucket
12
+ end
13
+
14
+ def enqueue_upload(expected_path, actual_path)
15
+ @uploads.push(Upload.new(expected_path, actual_path))
16
+ end
17
+
18
+ def upload(folder_name)
19
+ return nil unless @uploads.count > 0
20
+
21
+ @uploads.each do |upload|
22
+ upload.upload(@bucket, @path_prefix)
23
+ end
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
29
+
30
+ def to_html
31
+ "<html><body>#{@uploads.map(&:to_html).join}</body></html>"
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upload-ios-snapshot-test-case
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ash Furrow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.48'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.48'
27
+ description: ! "\n If you're using the cool FBSnapshotTestCase to test your iOS view
28
+ logic, awesome! Even better if you have continuous integration, like on Travis,
29
+ to automate running those tests!\n\n Wouldn't it be awesome if we could upload
30
+ the failing test snapshots somewhere, so we can see exactly what's wrong? That's
31
+ what this project is going to do. Once it's finished.\n "
32
+ email: ash@ashfurrow.com
33
+ executables:
34
+ - upload-ios-snapshot-test-case
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - bin/upload-ios-snapshot-test-case
39
+ - lib/upload-ios-snapshot-test-case.rb
40
+ - lib/upload.rb
41
+ - lib/upload_manager.rb
42
+ homepage: https://github.com/AshFurrow/upload-ios-snapshot-test-case
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.2.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Upload failing iOS snapshot tests cases to S3.
66
+ test_files: []
67
+ has_rdoc: