pencilcase_teams_shipit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b099dd84ba7fad53a6819ced5c27f1d7917a1a6e
4
+ data.tar.gz: aba01f2e63654ff1105f99a7d542d9b4ab454e2c
5
+ SHA512:
6
+ metadata.gz: ccdb55b08f4b26de379d2fadd0046fe48e9dab3b08885096f8512cdf57ba85f87450cac0b2cc17d3e91e16a49e6b714e53c54cac9aafbc17220c1a778cf52e68
7
+ data.tar.gz: 3946bc22220f2566685f060ac724eb6a57e1e7e2ab8f111998c2b3064b0c6b56e853b331706ac9f1e58543ad75f2a8560d0b253105b0581f56c012d0eb381d35
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1 @@
1
+ 2.2.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pencilcase_shipit.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robots and Pencils
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Pencilcase Teams :: Shipit
2
+
3
+ SHIP IT! To your Pencilcase Teams
4
+
5
+ ## Installation
6
+
7
+ Install yourself a little shipping magic.
8
+
9
+ ```sh
10
+ gem install pencilcase_shipit
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ We are expecting that somewhere you have a PENCILCASE_UUID and a PENCILCASE_TOKEN in your ENV.
16
+
17
+ Then you just
18
+
19
+ ```sh
20
+ shipit path_to_file
21
+ ```
22
+
23
+ If they are not in your path, then you need to set them with the command
24
+
25
+ ```sh
26
+ PENCILCASE_UUID="XXXX-XXX-XXXX" PENCILCASE_TOKEN="1337DEADBEEF1337" shipit path_to_file
27
+ ```
28
+
29
+ If you are testing you should also set ```PENCILCASE_URL="http://pencilcase.dev/api/v1"``` when you run the command
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/pencilcase_shipit/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pencilcase_teams_shipit"
4
+ require 'colorize'
5
+
6
+ args = ARGV.dup
7
+ ARGV.clear
8
+
9
+ title = args.shift.strip rescue nil
10
+ bundle_id = args.shift.strip rescue nil
11
+ file_path = args.shift.strip rescue nil
12
+ uuid = args.shift.strip rescue nil
13
+ token = args.shift.strip rescue nil
14
+
15
+ if title && bundle_id && file_path && (uuid || ENV['PENCILCASE_UUID']) && (token || ENV['PENCILCASE_TOKEN'])
16
+ api = PencilcaseTeamsShipit::API.new((uuid || ENV['PENCILCASE_UUID']), (token || ENV['PENCILCASE_TOKEN']))
17
+ exit(1) unless api.upload(title, bundle_id, file_path)
18
+ else
19
+ puts "USAGE:".colorize(:green)
20
+ puts " PENCILCASE_TOKEN=\"TOKEN\" shipit \"Title of App\" your.app.bundle.id \"./path/to/file\"".colorize(:light_blue)
21
+ puts "or if you've set PENCILCASE_TOKEN as ENV vars then you can just"
22
+ puts " shipit \"Title of App\" your.app.bundle.id \"./path/to/file\"".colorize(:light_blue)
23
+ puts ""
24
+ puts "Remember that your TOKEN is TEAM specific and that a new bundle id will make a new item.".colorize(:green)
25
+ puts ""
26
+ end
@@ -0,0 +1,6 @@
1
+ require "pencilcase_teams_shipit/version"
2
+ require "pencilcase_teams_shipit/api"
3
+
4
+ module PencilcaseTeamsShipit
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,100 @@
1
+ require 'rest_client'
2
+ require 'colorize'
3
+ require 'json'
4
+
5
+ module PencilcaseTeamsShipit
6
+ class API
7
+ def self.pencilcase_url
8
+ ENV['PENCILCASE_URL'] ? ENV['PENCILCASE_URL'] : 'https://teams.pencilcase.io/api/v1'
9
+ end
10
+
11
+ def initialize(key, token)
12
+ @key = key
13
+ @token = token
14
+ end
15
+
16
+ def upload(title, bundle_id, filename)
17
+ if File.exists?(filename)
18
+ response = self.obtain_upload_url(filename)
19
+ return if response.nil?
20
+ item_details = JSON.parse(response)
21
+
22
+ puts "Uploading new version of #{bundle_id}".colorize(:green)
23
+ response = self.upload_version(item_details, filename)
24
+ return false if response.nil?
25
+
26
+ puts "Confirming upload of #{bundle_id}".colorize(:green)
27
+ metadata = self.confirm_upload(title, bundle_id, item_details['uuid'], filename)
28
+ return false if metadata.nil?
29
+
30
+ puts "Verifying metadata".colorize(:green)
31
+ if self.check_metadata(metadata, filename)
32
+ puts "Success".colorize(:green)
33
+ true
34
+ else
35
+ puts "ERROR!".colorize(:red)
36
+ false
37
+ end
38
+ else
39
+ puts "ERROR: The file that you've specified does not exist".colorize(:red)
40
+ false
41
+ end
42
+ end
43
+
44
+ def obtain_upload_url(filename)
45
+ options = { filename: filename}
46
+ begin
47
+ response = RestClient.post(PencilcaseTeamsShipit::API::pencilcase_url + "/shipit", options, {"X-Pencilcase-UUID" => @key, "X-PencilCase-Token" => @token})
48
+ rescue Exception => e
49
+ puts e.message.colorize(:red)
50
+ response = nil
51
+ end
52
+ end
53
+
54
+ def upload_version(options, file)
55
+ begin
56
+ response = RestClient.post options['url'], options['fields'].merge(file: File.new("#{file}", 'rb')), {}
57
+ rescue Exception => e
58
+ puts e.message.colorize(:red)
59
+ response = nil
60
+ end
61
+ end
62
+
63
+ def confirm_upload(title, bundle_id, uuid, filename)
64
+ options = {
65
+ title: title,
66
+ bundle_id: bundle_id,
67
+ uuid: uuid
68
+ }
69
+ response = RestClient.put(PencilcaseTeamsShipit::API::pencilcase_url + "/shipit", options, {"X-PencilCase-UUID" => @key, "X-PencilCase-Token" => @token})
70
+ metadata = JSON.parse(response)
71
+ end
72
+
73
+ def check_metadata(metadata, filename)
74
+ s3_size = metadata['content_length']
75
+ s3_md5 = metadata['etag']
76
+
77
+ if s3_size && s3_md5
78
+ size = File.size filename
79
+ if size == s3_size
80
+ puts "#{s3_size} matches #{size}".colorize(:green)
81
+ else
82
+ puts "ERROR: #{s3_size} did not match #{size}".colorize(:red)
83
+ return false
84
+ end
85
+
86
+ md5 = Digest::MD5.file(filename).hexdigest
87
+ if "\"#{md5}\"" == s3_md5
88
+ puts "#{s3_md5} matches \"#{md5}\"".colorize(:green)
89
+ else
90
+ puts "ERROR: #{s3_md5} did not match \"#{md5}\"".colorize(:red)
91
+ return false
92
+ end
93
+ true
94
+ else
95
+ puts "ERROR: uploaded file did not match!"
96
+ false
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,3 @@
1
+ module PencilcaseTeamsShipit
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pencilcase_teams_shipit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pencilcase_teams_shipit"
8
+ spec.version = PencilcaseTeamsShipit::VERSION
9
+ spec.authors = ["Mark Madsen", "Robots and Pencils"]
10
+ spec.email = ["gems@robotsandpencils.com"]
11
+ spec.summary = "SHIPIT!"
12
+ spec.description = ""
13
+ spec.homepage = "https://www.pencilcase.io"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["shipit"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "rest-client"
22
+ spec.add_runtime_dependency "colorize"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pencilcase_teams_shipit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Madsen
8
+ - Robots and Pencils
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-10-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: colorize
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ description: ''
71
+ email:
72
+ - gems@robotsandpencils.com
73
+ executables:
74
+ - shipit
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".ruby-version"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/shipit
85
+ - lib/pencilcase_teams_shipit.rb
86
+ - lib/pencilcase_teams_shipit/api.rb
87
+ - lib/pencilcase_teams_shipit/version.rb
88
+ - pencilcase_teams_shipit.gemspec
89
+ homepage: https://www.pencilcase.io
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: SHIPIT!
113
+ test_files: []