appscreens-io-uploader 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2efb8615be5ccd6b3a921d50c731ef7afa89d7fb
4
+ data.tar.gz: c277a537474f3d7cdd081e2832acb66a57c26ab9
5
+ SHA512:
6
+ metadata.gz: e51723d47714b9d091a06830f94b8e6543b24e853eba747d5e186a8413a43329af8ec8317801e319bea0be053bbc34495d280b26899fa7617e8797d36e94db25
7
+ data.tar.gz: 8b9a5404ceb57a09a524cc717d901a6a9865e4717b5612ea8ef981c5e20070d52d7e2d09b996f842d597568806194cab7d845705392262898300f957ef6e88b1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Daniel Griesser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ appscreens.io Uploader
2
+ ============
3
+
4
+ [![Twitter: @DanielGri](https://img.shields.io/badge/contact-@DanielGri-blue.svg?style=flat)](https://twitter.com/DanielGri)
5
+ [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/HazAT/appscreens-io-uploader/blob/master/LICENSE)
6
+ [![Gem](https://img.shields.io/gem/v/appscreens-io-uploader.svg?style=flat)](http://rubygems.org/gems/appscreens-io-uploader)
7
+
8
+
9
+ # Features
10
+
11
+ This gem uploads your app screenshots to [appscreens.io](https://appscreens.io), so you can conveniently style and translate them for the AppStore. It is built to easily integrate with [@KrauseFx](https://twitter.com/KrauseFx)'s [snapshot](https://github.com/fastlane/snapshot).
12
+
13
+ # Installation
14
+
15
+ Install the gem
16
+
17
+ sudo gem install appscreens-io-uploader
18
+
19
+ # Usage
20
+
21
+ Call ```appscreens-io-uploader``` in the forlder where your screenshots are located and pass the id of your project (the last part of the URL on https://appscreens.io/[project_id])
22
+
23
+ appscreens-io-uploader [project_id]
24
+
25
+ To upload screens with a different screensize than 5.5 inch use the --screenSize option (deliver string syntax use ```appscreens-io-uploader existing_project --help```)
26
+
27
+ appscreens-io-uploader [project_id] --screenSize=iOS-4.0-in
28
+
29
+ ## Uninstall
30
+
31
+ sudo gem uninstall appscreens-io-uploader
32
+ rm -rf ~/.appscreens-io-uploader
33
+
34
+ # Thanks
35
+ This gem is using pretty much the whole structure of [@KrauseFx](https://twitter.com/KrauseFx) [frameit](https://github.com/fastlane/frameit) and the [fastlane_core](https://github.com/fastlane/fastlane_core) for convenience.
36
+
37
+ # License
38
+ This project is licensed under the terms of the MIT license. See the LICENSE file.
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.push File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'appscreensIoUploader'
6
+ require 'commander'
7
+
8
+ HighLine.track_eof = false
9
+
10
+ class AppscreensIoUploaderApplication
11
+ include Commander::Methods
12
+
13
+ def run
14
+ program :version, AppscreensIoUploader::VERSION
15
+ program :description, 'Upload your screenshots to appscreens.io'
16
+ program :help, 'Author', 'Daniel Griesser <daniel.griesser.86@gmail.com>'
17
+ program :help, 'Website', 'https://github.com/HazAT/appscreens-io-uploader'
18
+ program :help, 'GitHub', 'https://github.com/HazAT/appscreens-io-uploader'
19
+ program :help_formatter, :compact
20
+
21
+ always_trace!
22
+
23
+ default_command :existing_project
24
+
25
+ command :existing_project do |c|
26
+ c.syntax = 'appscreensIoUploader existing_project'
27
+ c.description = "uploads the screenshots to your project on appscreens.io"
28
+ c.option '--screenSize STRING', String, 'screensize to upload iOS-5.5-in | iOS-4.7-in | iOS-4.0-in'
29
+
30
+ c.action do |args, options|
31
+ options.default :screenSize => Deliver::AppScreenshot::ScreenSize::IOS_55
32
+ AppscreensIoUploader::Runner.new.run('.', args[0], options.screenSize)
33
+ end
34
+ end
35
+
36
+ run!
37
+ end
38
+ end
39
+
40
+
41
+ begin
42
+ AppscreensIoUploaderApplication.new.run
43
+ end
@@ -0,0 +1,11 @@
1
+ require 'appscreensIoUploader/version'
2
+ require 'appscreensIoUploader/device_types'
3
+ require 'appscreensIoUploader/runner'
4
+ require 'appscreensIoUploader/screenshot'
5
+ require 'appscreensIoUploader/uploader'
6
+ #
7
+ require 'fastlane_core'
8
+ #
9
+ module AppscreensIoUploader
10
+ Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
11
+ end
@@ -0,0 +1,6 @@
1
+ module AppscreensIoUploader
2
+ module Orientation
3
+ PORTRAIT = "Vert"
4
+ LANDSCAPE = "Horz"
5
+ end
6
+ end
@@ -0,0 +1,51 @@
1
+ require 'deliver'
2
+ require 'fastimage'
3
+ require 'httmultiparty'
4
+
5
+ module AppscreensIoUploader
6
+ class Runner
7
+
8
+ def run(path, project_id, screensSize = Deliver::AppScreenshot::ScreenSize::IOS_55)
9
+ screenshots = Dir.glob("#{path}/**/*.{png,PNG}")
10
+
11
+ screenshots_to_upload = Array.new
12
+ prevHeight = 0
13
+ maxScreens = 5
14
+
15
+ if (project_id.length != 10)
16
+ Helper.log.error "No valid ProjectId '#{project_id}' must be exactly 10 chars (copy it from your appscreens.io URL)"
17
+ return
18
+ end
19
+
20
+ if screenshots.count > 0
21
+ Helper.log.info "Using '#{screensSize}' as ScreenSize"
22
+
23
+ screenshots.each do |full_path|
24
+ next if full_path.include?"_framed.png"
25
+ next if full_path.include?".itmsp/" # a package file, we don't want to modify that
26
+ next if full_path.include?"device_frames/" # these are the device frames the user is using
27
+
28
+ begin
29
+ screenshot = Screenshot.new(full_path)
30
+ if screensSize <= screenshot.screen_size && screenshots_to_upload.count < maxScreens
31
+ if !screenshot.is_portrait?
32
+ raise "appscreens.io only supports PORTRAIT Orientation for now"
33
+ end
34
+ if !screenshot.is_supported_screen_size?
35
+ raise "appscreens.io only supports 4.7inch,5inch and 5.5inch screen sizes"
36
+ end
37
+ screenshots_to_upload << screenshot
38
+ end
39
+ rescue => ex
40
+ Helper.log.error ex
41
+ end
42
+ end
43
+
44
+ uploader = Uploader.new
45
+ uploader.upload!(project_id, screenshots_to_upload)
46
+ else
47
+ Helper.log.error "Could not find screenshots"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,59 @@
1
+ module AppscreensIoUploader
2
+ # Represents one screenshot
3
+ class Screenshot
4
+ attr_accessor :path # path to the screenshot
5
+ attr_accessor :size # size in px array of 2 elements: height and width
6
+ attr_accessor :screen_size # deliver screen size type, is unique per device type, used in device_name
7
+
8
+ # path: Path to screenshot
9
+ # color: Color to use for the frame
10
+ def initialize(path)
11
+ raise "Couldn't find file at path '#{path}'".red unless File.exists?path
12
+ @path = path
13
+ @size = FastImage.size(path)
14
+
15
+ @screen_size = Deliver::AppScreenshot.calculate_screen_size(path)
16
+ end
17
+
18
+ def is_supported_screen_size?
19
+ sizes = Deliver::AppScreenshot::ScreenSize
20
+ case @screen_size
21
+ when sizes::IOS_55
22
+ return true
23
+ when sizes::IOS_47
24
+ return true
25
+ when sizes::IOS_40
26
+ return true
27
+ when sizes::IOS_35
28
+ return false
29
+ when sizes::IOS_IPAD
30
+ return false
31
+ when sizes::MAC
32
+ return false
33
+ end
34
+ end
35
+
36
+ # The name of the orientation of a screenshot. Used to find the correct template
37
+ def orientation_name
38
+ return Orientation::PORTRAIT if size[0] < size[1]
39
+ return Orientation::LANDSCAPE
40
+ end
41
+
42
+ def is_portrait?
43
+ return (orientation_name == Orientation::PORTRAIT)
44
+ end
45
+
46
+ def to_s
47
+ self.path
48
+ end
49
+
50
+ # Add the device frame, this will also call the method that adds the background + title
51
+ def frame!
52
+ if self.is_mac?
53
+ MacEditor.new.frame!(self)
54
+ else
55
+ Editor.new.frame!(self)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,35 @@
1
+ module AppscreensIoUploader
2
+
3
+ class Uploader
4
+ def upload!(project_id, screenshots)
5
+ base_uri = 'https://appscreens.io'
6
+ api_base_uri = base_uri + '/api/v1'
7
+ screens_uri = '/projects/' + project_id + '/screens'
8
+ #GET /projects/{project_id}/screens
9
+ #Fetch all screens of the project
10
+ response = HTTParty.get(api_base_uri + screens_uri)
11
+ if response.code == 200
12
+ screens = JSON.parse(response.body)
13
+ screens.each_with_index do |screen, index|
14
+ screenshot_path = screenshots[index].path
15
+ Helper.log.info "uploading screenshot #{screenshot_path}"
16
+ # POST /projects/{project_id}/screens/{screen_id}/image
17
+ upload_response = HTTMultiParty.post(api_base_uri + screens_uri + '/' + screen['id'] + '/image', :query => {
18
+ :image => File.new(screenshot_path)
19
+ })
20
+ if response.code == 200
21
+ Helper.log.info "successfully uploaded screenshot #{screenshot_path}".green
22
+ else
23
+ Helper.log.error "error while uploading screenshot #{screenshot_path} #{upload_response.body}"
24
+ end
25
+
26
+ end
27
+ else
28
+ Helper.log.error "not able to fetch your project, make sure it exsists under #{base_uri}/#{project_id}"
29
+ return
30
+ end
31
+
32
+ Helper.log.info "successfully uplopaded all your screens ... you can edit them under #{base_uri}/#{project_id}".green
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module AppscreensIoUploader
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appscreens-io-uploader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Griesser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httmultiparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.16
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.16
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastlane_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastimage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: deliver
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>'
60
+ - !ruby/object:Gem::Version
61
+ version: '0.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>'
67
+ - !ruby/object:Gem::Version
68
+ version: '0.3'
69
+ description: Upload your screenshots to https://appscreens.io
70
+ email:
71
+ - daniel.griesser.86@gmail.com
72
+ executables:
73
+ - appscreens-io-uploader
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - lib/appscreensIoUploader/device_types.rb
78
+ - lib/appscreensIoUploader/runner.rb
79
+ - lib/appscreensIoUploader/screenshot.rb
80
+ - lib/appscreensIoUploader/uploader.rb
81
+ - lib/appscreensIoUploader/version.rb
82
+ - lib/appscreensIoUploader.rb
83
+ - bin/appscreens-io-uploader
84
+ - README.md
85
+ - LICENSE
86
+ homepage: https://github.com/HazAT/appscreens-io-uploader
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 2.0.0
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.6
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Upload your screenshots to https://appscreens.io
110
+ test_files: []