roger_sneakpeek 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e26f638dda0e0fe64af0a78029613d59d2990f2b
4
+ data.tar.gz: 3c50c9a6d809cdea4f743708eb9d760dc12f5b1c
5
+ SHA512:
6
+ metadata.gz: 43f2c8cee49dee0287fc67bc8f5d7595ff69e98ada941578fb3503d4a00a758915eee96e533fcddbf627a8f12765734fec1514b048943bca01b40d8721fa4e68
7
+ data.tar.gz: a3110412a15d20822e2d759467f26d1d8cc178cc3bb338926ef009a1e0003270898f9ab49f2716be109d366fd1dda1a17dcd2bc396907457fd2ac9127c7a3eba
@@ -0,0 +1,47 @@
1
+ LineLength:
2
+ Description: 'Limit lines to 100 characters.'
3
+ Max: 100
4
+ Enabled: true
5
+
6
+ StringLiterals:
7
+ EnforcedStyle: double_quotes
8
+ Enabled: true
9
+
10
+ Style/DotPosition:
11
+ EnforcedStyle: trailing
12
+ Enabled: true
13
+
14
+ Metrics/MethodLength:
15
+ CountComments: false # count full line comments?
16
+ Max: 20
17
+
18
+ Metrics/AbcSize:
19
+ Max: 20
20
+
21
+ Style/ClassAndModuleChildren:
22
+ EnforcedStyle: compact
23
+ Enabled: false
24
+
25
+ # By default, the rails cops are not run. Override in project or home
26
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
27
+ Rails:
28
+ Enabled: false
29
+
30
+ # Disabled cops
31
+ Metrics/ClassLength:
32
+ Enabled: false
33
+
34
+ Metrics/ModuleLength:
35
+ Enabled: false
36
+
37
+ Style/EachWithObject:
38
+ Enabled: false
39
+
40
+ Style/AccessorMethodName:
41
+ Enabled: false
42
+
43
+ Lint/AssignmentInCondition:
44
+ Enabled: false
45
+
46
+ Style/SingleLineBlockParams:
47
+ Enabled: false
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1
4
+ First workable version
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ roger_sneakpeek (0.0.1)
5
+ faraday (~> 0.8.11)
6
+ roger (~> 1.5, >= 1.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.2.0)
12
+ faraday (0.8.11)
13
+ multipart-post (~> 1.2.0)
14
+ hpricot (0.8.4)
15
+ metaclass (0.0.4)
16
+ mime-types (2.99.1)
17
+ mocha (1.1.0)
18
+ metaclass (~> 0.0.1)
19
+ multipart-post (1.2.0)
20
+ parser (2.3.0.1)
21
+ ast (~> 2.2)
22
+ power_assert (0.2.7)
23
+ powerpack (0.1.1)
24
+ rack (1.6.4)
25
+ rainbow (2.0.0)
26
+ rake (10.5.0)
27
+ redcarpet (3.3.4)
28
+ roger (1.6.0)
29
+ hpricot (= 0.8.4)
30
+ mime-types (~> 2.2)
31
+ rack (>= 1.0.0)
32
+ redcarpet (>= 3.1.1)
33
+ test_construct (~> 2.0)
34
+ thor (~> 0.19.0)
35
+ tilt (~> 2.0.1)
36
+ rubocop (0.36.0)
37
+ parser (>= 2.3.0.0, < 3.0)
38
+ powerpack (~> 0.1)
39
+ rainbow (>= 1.99.1, < 3.0)
40
+ ruby-progressbar (~> 1.7)
41
+ ruby-progressbar (1.7.5)
42
+ test-unit (3.1.5)
43
+ power_assert
44
+ test_construct (2.0.1)
45
+ thor (0.19.1)
46
+ tilt (2.0.2)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ mocha (~> 1.1.0)
53
+ rake
54
+ roger_sneakpeek!
55
+ rubocop
56
+ test-unit
57
+ thor (~> 0)
58
+
59
+ BUNDLED WITH
60
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Digitpant, Flurin Egger
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.
22
+
@@ -0,0 +1,21 @@
1
+ Roger Sneakpeek
2
+ ============
3
+
4
+ Upload current release to the Sneakpeek preview server.
5
+
6
+ ## Installation
7
+ * Add ```gem 'roger_sneakpeek'``` to your Gemfile
8
+
9
+ * Add this to your Mockupfile:
10
+ ```
11
+ mockup.release do |r|
12
+ r.finalize :sneakpeek,
13
+ project: "PROJECT_NAME",
14
+ gitlab_project: GITLAB_NAMESPACE_AND_PROJECT,
15
+ ci_only: false, # Only set this if you want to upload sneakpeek from your dev machine
16
+ end
17
+ ```
18
+
19
+ ## License
20
+
21
+ This project is released under the [MIT license](LICENSE).
@@ -0,0 +1,9 @@
1
+ require "rake/testtask"
2
+ require "rubocop/rake_task"
3
+
4
+ task default: [:rubocop]
5
+
6
+ desc "Run rubocop"
7
+ task :rubocop do
8
+ RuboCop::RakeTask.new
9
+ end
@@ -0,0 +1,6 @@
1
+ # Eslint plugin
2
+ module RogerSneakpeek
3
+ end
4
+
5
+ require File.dirname(__FILE__) + "/roger_sneakpeek/finalizer"
6
+ require File.dirname(__FILE__) + "/roger_sneakpeek/version"
@@ -0,0 +1,125 @@
1
+ require "shellwords"
2
+ require "roger/test"
3
+ require "tempfile"
4
+ require "faraday"
5
+ require "uri"
6
+ require "json"
7
+
8
+ require File.dirname(__FILE__) + "/git"
9
+
10
+ module RogerSneakpeek
11
+ # Finalizer to zip and upload release
12
+ class Finalizer < Roger::Release::Finalizers::Base
13
+ attr_reader :release, :current_options
14
+
15
+ def call(release, call_options = {})
16
+ options = {
17
+ zip: "zip",
18
+ project: nil,
19
+ gitlab_project: nil,
20
+ ci_only: true,
21
+ sneakpeek_api_url: "http://api.peek.digitpaint.nl"
22
+ }.update(@options)
23
+
24
+ options.update(call_options) if call_options
25
+
26
+ unless options[:project]
27
+ fail ArgumentError, "You must specify a project to RogerSneakpeek"
28
+ end
29
+
30
+ unless options[:gitlab_project]
31
+ fail ArgumentError, "You must specify a gitlab_project to RogerSneakpeek"
32
+ end
33
+
34
+ # If we run in ci_only mode and are not in CI we stop.
35
+ return if options[:ci_only] && !ENV["CI"]
36
+
37
+ @release = release
38
+ @current_options = options
39
+
40
+ check_zip_command
41
+
42
+ release.log(self, "Starting upload to Sneakpeek")
43
+ upload_release zip_release
44
+ end
45
+
46
+ protected
47
+
48
+ def zip_command(*args)
49
+ ([Shellwords.escape(current_options[:zip])] + args).join(" ")
50
+ end
51
+
52
+ def check_zip_command
53
+ `#{zip_command} -v`
54
+ rescue Errno::ENOENT
55
+ raise "Could not find zip in #{zip_command.inspect}"
56
+ end
57
+
58
+ def git(*args)
59
+ cmd = Shellwords.join([current_options[:git]] + args)
60
+ `#{cmd}`
61
+ end
62
+
63
+ def zip_release
64
+ zip_path = Dir::Tmpname.create ["release", ".zip"] {}
65
+ ::Dir.chdir(release.build_path) do
66
+ command = zip_command("-r", "-9", Shellwords.escape(zip_path), "./*")
67
+ output = `#{command}`
68
+ fail "Could not generate zipfile\n#{output}" if $CHILD_STATUS.to_i != 0
69
+ end
70
+
71
+ zip_path
72
+ end
73
+
74
+ def upload_release(zip_path)
75
+ git = Git.new(path: release.project.path)
76
+
77
+ data = perform_upload(
78
+ sneakpeek_url(git),
79
+ zip_path,
80
+ sha: git.sha,
81
+ gitlab_project: current_options[:gitlab_project]
82
+ )
83
+
84
+ release.log(self, "Sneakpeek url: #{data['url']}") if data
85
+ ensure
86
+ File.unlink zip_path
87
+ end
88
+
89
+ def sneakpeek_url(git)
90
+ project = current_options[:project]
91
+ case
92
+ when git.tag
93
+ "/projects/#{project}/tags/#{URI.escape(git.tag)}"
94
+ when git.branch
95
+ "/projects/#{project}/branches/#{URI.escape(git.branch)}"
96
+ else
97
+ fail "Current project is neither on a tag nor a branch"
98
+ end
99
+ end
100
+
101
+ def perform_upload(url, zip_path, params)
102
+ conn = Faraday.new(current_options[:sneakpeek_api_url]) do |f|
103
+ f.request :multipart
104
+ f.request :url_encoded
105
+ f.adapter :net_http
106
+ end
107
+
108
+ data = params.dup
109
+ data[:file] = Faraday::UploadIO.new(zip_path, "application/zip")
110
+
111
+ result = conn.post(url, data)
112
+
113
+ case result.status
114
+ when 201
115
+ JSON.parse(result.body)
116
+ when 422
117
+ fail "Upload to Sneakpeek failed with error: #{response.body[:error]}"
118
+ else
119
+ fail "Upload to Sneakpeek failed with unknown error (status: #{result.status})"
120
+ end
121
+ end
122
+ end
123
+ end
124
+
125
+ Roger::Release::Finalizers.register(:sneakpeek, RogerSneakpeek::Finalizer)
@@ -0,0 +1,54 @@
1
+ module RogerSneakpeek
2
+ # Get relevant git info
3
+ class Git < Roger::Release::Scm::Git
4
+ def tag
5
+ get_scm_data if @_sha.nil?
6
+ @_tag
7
+ end
8
+
9
+ def sha
10
+ get_scm_data if @_sha.nil?
11
+ @_sha
12
+ end
13
+
14
+ # Will return current branch
15
+ def branch
16
+ get_scm_data if @_sha.nil?
17
+ @_branch
18
+ end
19
+
20
+ protected
21
+
22
+ def get_scm_data(ref = @config[:ref])
23
+ super(ref)
24
+
25
+ @_tag = scm_tag(ref) || nil
26
+ @_branch = scm_branch(ref) || nil
27
+ @_sha = scm_sha(ref) || nil
28
+ end
29
+
30
+ def scm_tag(ref)
31
+ return nil unless File.exist?(git_dir)
32
+
33
+ tag = `git --git-dir=#{safe_git_dir} describe --tags #{ref} 2>&1`
34
+
35
+ tag.strip if $CHILD_STATUS.to_i == 0
36
+ end
37
+
38
+ def scm_branch(ref)
39
+ return nil unless File.exist?(git_dir)
40
+
41
+ branch = `git --git-dir=#{safe_git_dir} rev-parse --abbrev-ref #{ref} 2>&1`
42
+
43
+ branch.strip if $CHILD_STATUS.to_i == 0
44
+ end
45
+
46
+ def scm_sha(ref)
47
+ return nil unless File.exist?(git_dir)
48
+
49
+ sha = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:"%H" -s 2>&1`
50
+
51
+ sha.strip if $CHILD_STATUS.to_i == 0
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,4 @@
1
+ # Roger main namespace
2
+ module RogerSneakpeek
3
+ VERSION = "0.0.1".freeze
4
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/roger_sneakpeek/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.authors = ["Flurin Egger"]
7
+ s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
8
+ s.name = "roger_sneakpeek"
9
+ s.version = RogerSneakpeek::VERSION
10
+ s.homepage = "https://github.com/digitpaint/roger_sneakpeek"
11
+
12
+ s.summary = "Deployment of releases to Sneakpeek server as Roger finalizer"
13
+ s.description = <<-EOF
14
+ Will upload the current release to the Sneakpeek server.
15
+ EOF
16
+ s.licenses = ["MIT"]
17
+
18
+ s.date = Time.now.strftime("%Y-%m-%d")
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency "roger", "~> 1.5", ">= 1.0.0"
24
+ s.add_dependency "faraday", "~> 0.8.11"
25
+
26
+ s.add_development_dependency "rubocop", [">= 0"]
27
+ s.add_development_dependency "rake", [">= 0"]
28
+ s.add_development_dependency "test-unit", [">= 0"]
29
+ s.add_development_dependency "thor", ["~> 0"]
30
+ s.add_development_dependency "mocha", ["~> 1.1.0"]
31
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roger_sneakpeek
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Flurin Egger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: roger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.5'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.11
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.8.11
47
+ - !ruby/object:Gem::Dependency
48
+ name: rubocop
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: test-unit
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: thor
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: mocha
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ version: 1.1.0
117
+ description: |2
118
+ Will upload the current release to the Sneakpeek server.
119
+ email:
120
+ - info@digitpaint.nl
121
+ - flurin@digitpaint.nl
122
+ executables: []
123
+ extensions: []
124
+ extra_rdoc_files: []
125
+ files:
126
+ - .rubocop.yml
127
+ - CHANGELOG.md
128
+ - Gemfile
129
+ - Gemfile.lock
130
+ - LICENSE
131
+ - README.md
132
+ - Rakefile
133
+ - lib/roger_sneakpeek.rb
134
+ - lib/roger_sneakpeek/finalizer.rb
135
+ - lib/roger_sneakpeek/git.rb
136
+ - lib/roger_sneakpeek/version.rb
137
+ - roger_sneakpeek.gemspec
138
+ homepage: https://github.com/digitpaint/roger_sneakpeek
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.2.2
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Deployment of releases to Sneakpeek server as Roger finalizer
162
+ test_files: []