danger-device_grid 0.1.0

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: d5fd52c8bcd519387f8ab072acc98ed1b90c70e5
4
+ data.tar.gz: ab837abae098f33c658fb399332d241eb4e7b291
5
+ SHA512:
6
+ metadata.gz: 221d09073214993693b09e8123b147a20d2962e1b538ec8516670b3e712a75de94dec9a5dda0a7b27421b6148b19285ec10a5db7076cf4f852890f2d1c3ca3c5
7
+ data.tar.gz: ec9b0c160787ebc1c801e61a8b52410243a9de071189cf73c514cad83900c90c736a396172947a2485c5813d42ae69f3d56b2802b27da5b8be3227e446489aee
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'danger'
7
+
8
+ gem 'rspec'
9
+ gem 'rubocop'
10
+ gem 'webmock'
11
+ gem 'pry'
12
+ end
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ end
13
+
14
+ desc 'Run RuboCop on the lib/specs directory'
15
+ RuboCop::RakeTask.new(:rubocop) do |task|
16
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
17
+ end
18
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'device_grid/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-device_grid'
8
+ spec.version = DeviceGrid::VERSION
9
+ spec.authors = ['Boris Bügling']
10
+ spec.email = ['boris@icculus.org']
11
+ spec.summary = %q{Danger plugin for the fastlane device grid.}
12
+ spec.homepage = 'https://github.com/fastlane/fastlane/device_grid'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'fastlane', '~> 1.94.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
@@ -0,0 +1 @@
1
+ require 'device_grid/gem_version'
@@ -0,0 +1 @@
1
+ require 'device_grid/plugin'
@@ -0,0 +1,3 @@
1
+ module DeviceGrid
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,99 @@
1
+ require 'fastlane'
2
+
3
+ module Danger
4
+ # A danger plugin: https://github.com/danger/danger
5
+ class DangerDeviceGrid < Plugin
6
+ # @param public_key: The key for the Appetize.io
7
+ # @param languages: Array of languages you want to see (e.g. [en, de])
8
+ # @param devices: Array of deviecs you want to see (e.g. ["iphone4s", "ipadair"])
9
+ # @param prefix_command: Prefix the `fastlane run appetize_viewing_url_generator` command with something
10
+ # this can be used to use `bundle exec`
11
+ def run(public_key: nil, languages: nil, devices: nil, prefix_command: nil)
12
+ # since we fetch the URL from the output we don't need colors
13
+ # this will only be changed in the danger sub-process
14
+ fastlane_colors_env = "FASTLANE_DISABLE_COLORS"
15
+ fastlane_colors_were_disabled = ENV.key?(fastlane_colors_env)
16
+ ENV[fastlane_colors_env] = "true"
17
+
18
+ devices ||= %w(iphone4s iphone5s iphone6s iphone6splus ipadair)
19
+ languages ||= ["en"]
20
+
21
+ prefix_command ||= ""
22
+
23
+ # To use the local fastlane instead of bundle
24
+ prefix_command = "./bin/" if FastlaneCore::Helper.test?
25
+
26
+ deep_link_matches = pr_body.match(/:link:\s(.*)/) # :link: emoji
27
+ deep_link = deep_link_matches[1] if deep_link_matches
28
+
29
+ markdown("<table>")
30
+ languages.each do |current_language|
31
+ markdown("<tr>")
32
+ markdown("<td>")
33
+ markdown("<b>#{current_language[0..1]}</b>")
34
+ markdown("</td>")
35
+
36
+ devices.each do |current_device|
37
+ markdown("<td>")
38
+
39
+ params = {
40
+ public_key: public_key,
41
+ language: current_language,
42
+ device: current_device
43
+ }
44
+ params[:launch_url] = deep_link if deep_link
45
+ params_str = params.map { |k, v| "#{k}:\"#{v}\"" }.join(" ")
46
+ url = Fastlane::Helper.backticks("#{prefix_command}fastlane run appetize_viewing_url_generator #{params_str}")
47
+ url = url.match(%r{Result:.*(https\:\/\/.*)})[1].strip
48
+
49
+ markdown("<a href='#{url}'>")
50
+ markdown("<p align='center'>")
51
+ markdown("<img height='130' src='#{url_for_device(current_device)}' />")
52
+ markdown("<br />")
53
+ markdown(beautiful_device_name(current_device))
54
+ markdown("</p>")
55
+ markdown("</a>")
56
+
57
+ markdown("</td>")
58
+ end
59
+ markdown("</tr>")
60
+ end
61
+ markdown("</table>")
62
+ ensure
63
+ ENV.delete(fastlane_colors_env) unless fastlane_colors_were_disabled
64
+ end
65
+
66
+ private
67
+
68
+ def beautiful_device_name(str)
69
+ return {
70
+ iphone4s: "iPhone 4s",
71
+ iphone5s: "iPhone 5s",
72
+ iphone6s: "iPhone 6s",
73
+ iphone6splus: "iPhone 6s Plus",
74
+ ipadair: "iPad Air",
75
+ iphone6: "iPhone 6",
76
+ iphone6plus: "iPhone 6 Plus",
77
+ ipadair2: "iPad Air 2",
78
+ nexus5: "Nexus 5",
79
+ nexus7: "Nexus 7",
80
+ nexus9: "Nexus 9"
81
+ }[str.to_sym] || str.to_s
82
+ end
83
+
84
+ def url_for_device(str)
85
+ str = str.to_sym
86
+ host = "https://raw.githubusercontent.com/fastlane/fastlane/#{Fastlane::VERSION}/fastlane/lib/fastlane/actions/device_grid/assets/"
87
+ return {
88
+ iphone4s: host + "iphone4s.png",
89
+ iphone5s: host + "iphone5s.png",
90
+ iphone6: host + "iphone6s.png",
91
+ iphone6s: host + "iphone6s.png",
92
+ iphone6plus: host + "iphone6splus.png",
93
+ iphone6splus: host + "iphone6splus.png",
94
+ ipadair: host + "ipadair.png",
95
+ ipadair2: host + "ipadair.png"
96
+ }[str] || ""
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,37 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ class Dangerfile
5
+ module DSL
6
+ class Plugin
7
+ attr_accessor :current_markdown
8
+
9
+ def pr_body # needed for the action
10
+ ""
11
+ end
12
+
13
+ def markdown(str)
14
+ @current_markdown ||= ""
15
+ @current_markdown += "#{str}\n"
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ describe Danger::DangerDeviceGrid do
22
+ it 'should be a plugin' do
23
+ expect(Danger::DangerDeviceGrid.new(nil)).to be_a Danger::Plugin
24
+ end
25
+
26
+ it "works" do
27
+ public_key = "1461233806"
28
+ dg = Danger::DangerDeviceGrid.new(Danger::Dangerfile::DSL::Plugin.new)
29
+ dg.run(languages: ['en', 'de'],
30
+ devices: ['iphone4s'],
31
+ public_key: public_key)
32
+
33
+ correct = File.read("spec/fixtures/device_grid_results.html").gsub("[[version]]", Fastlane::VERSION)
34
+ expect(dg.current_markdown).to eq(correct)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ <table>
2
+ <tr>
3
+ <td>
4
+ <b>en</b>
5
+ </td>
6
+ <td>
7
+ <a href='https://appetize.io/embed/1461233806?autoplay=true&orientation=portrait&device=iphone4s&deviceColor=black&scale=75&language=en'>
8
+ <p align='center'>
9
+ <img height='130' src='https://raw.githubusercontent.com/fastlane/fastlane/[[version]]/fastlane/lib/fastlane/actions/device_grid/assets/iphone4s.png' />
10
+ <br />
11
+ iPhone 4s
12
+ </p>
13
+ </a>
14
+ </td>
15
+ </tr>
16
+ <tr>
17
+ <td>
18
+ <b>de</b>
19
+ </td>
20
+ <td>
21
+ <a href='https://appetize.io/embed/1461233806?autoplay=true&orientation=portrait&device=iphone4s&deviceColor=black&scale=75&language=de'>
22
+ <p align='center'>
23
+ <img height='130' src='https://raw.githubusercontent.com/fastlane/fastlane/[[version]]/fastlane/lib/fastlane/actions/device_grid/assets/iphone4s.png' />
24
+ <br />
25
+ iPhone 4s
26
+ </p>
27
+ </a>
28
+ </td>
29
+ </tr>
30
+ </table>
@@ -0,0 +1,10 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'rspec'
8
+ require 'danger'
9
+
10
+ require 'danger_plugin'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-device_grid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Boris Bügling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fastlane
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.94.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.94.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - boris@icculus.org
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - Rakefile
64
+ - danger-device_grid.gemspec
65
+ - lib/danger_device_grid.rb
66
+ - lib/danger_plugin.rb
67
+ - lib/device_grid/gem_version.rb
68
+ - lib/device_grid/plugin.rb
69
+ - spec/device_grid_spec.rb
70
+ - spec/fixtures/device_grid_results.html
71
+ - spec/spec_helper.rb
72
+ homepage: https://github.com/fastlane/fastlane/device_grid
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.14
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Danger plugin for the fastlane device grid.
96
+ test_files:
97
+ - spec/device_grid_spec.rb
98
+ - spec/fixtures/device_grid_results.html
99
+ - spec/spec_helper.rb
100
+ has_rdoc: