second_curtain 0.1.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 +15 -0
- data/bin/second_shutter +46 -0
- data/lib/second_shutter/upload.rb +35 -0
- data/lib/second_shutter/upload_manager.rb +33 -0
- data/lib/second_shutter.rb +2 -0
- metadata +67 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                MjExMDFkNzNkZDY4MGE1MGEzMDRiMDRlODQ0MzBlYzJiZWUyNzk0Zg==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                ZTE5MWYzOTgzN2ZjZWMwMGRiZjM0ZWJkY2IwZTA0MTdmZjJmNDIzZA==
         | 
| 7 | 
            +
            SHA512:
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                NDJmZjYwMTY3NTI0ZjAwZjgzNThiZGEwNjMyNjk2OTdlNWVlZmYzZmQyZTAw
         | 
| 10 | 
            +
                NWJkNzRhYWY5ZmIxMzJlNjZlN2EwM2RiZmRiNTRmMzA2ZTFlMTc5ZDFhMTgx
         | 
| 11 | 
            +
                MjUwNWNiMjE5NWMwN2JhMDQ4NGJhYWQwZDc4OWQ4MmY4NTEyMDA=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                MGJmY2IzNDAwYmI2YjA3MjRlN2Q4MWY0N2MzYmU2MjU5OTI1OTQyZjYzNzQ5
         | 
| 14 | 
            +
                NGY1MzFlNWE5MDhhZWRmMTk0NmE4YThhZjQ4ZTZlZTRmYmMxYWFkNWEyNjI5
         | 
| 15 | 
            +
                ZTdkNWVlNzQ3MjdjZGI5N2M5ZjE5YjBmNzE2OTRhNGZkZjZjMTg=
         | 
    
        data/bin/second_shutter
    ADDED
    
    | @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'second_shutter'
         | 
| 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,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: second_curtain
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Ash Furrow
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-07-28 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 | 
            +
            - second_shutter
         | 
| 35 | 
            +
            extensions: []
         | 
| 36 | 
            +
            extra_rdoc_files: []
         | 
| 37 | 
            +
            files:
         | 
| 38 | 
            +
            - bin/second_shutter
         | 
| 39 | 
            +
            - lib/second_shutter.rb
         | 
| 40 | 
            +
            - lib/second_shutter/upload.rb
         | 
| 41 | 
            +
            - lib/second_shutter/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: 
         |