diffend 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile.lock +1 -1
- data/lib/diffend.rb +3 -2
- data/lib/diffend/config/fetcher.rb +92 -9
- data/lib/diffend/config/validator.rb +25 -0
- data/lib/diffend/errors.rb +12 -0
- data/lib/diffend/voting/versions/remote.rb +0 -2
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a7edc516bd408637e9a48744eaa24aef9aaec48eb31c975d2640e3a222f672
|
4
|
+
data.tar.gz: ced39bedfb9898395d49657e416b09e15d0bf9f9c15dab4f042c619004bb04df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 891292dea2577d6b6b0b3b28d96589354bb73e7ca71beba535781c5bbc2388ffa897510d9a0d1ee68643076845600715c786320f32e6ed11eb5a03807c7ec9ff
|
7
|
+
data.tar.gz: 0f84201f7550bbfa9a84e2be1c4c423087271d3b7a40b76ea9a4f0d80f50f350915dfd6500df8186a8e68861bf23f9c68d94ec3879261daa0bb8ddf0d3870b17
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/lib/diffend.rb
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
].each(&method(:require))
|
6
6
|
|
7
7
|
%w[
|
8
|
+
errors
|
8
9
|
config/fetcher
|
9
10
|
config/file_finder
|
11
|
+
config/validator
|
10
12
|
commands
|
11
|
-
errors
|
12
13
|
voting
|
13
14
|
].each { |file| require "diffend/#{file}" }
|
14
15
|
|
@@ -21,7 +22,7 @@
|
|
21
22
|
# Diffend main namespace
|
22
23
|
module Diffend
|
23
24
|
# Current plugin version
|
24
|
-
VERSION = '0.2.
|
25
|
+
VERSION = '0.2.17'
|
25
26
|
# Diffend homepage
|
26
27
|
HOMEPAGE = 'https://diffend.io'
|
27
28
|
|
@@ -7,22 +7,105 @@ module Diffend
|
|
7
7
|
module Config
|
8
8
|
# Class responsible for fetching the config from .diffend.yml
|
9
9
|
module Fetcher
|
10
|
+
# All the errors for missing keys in the configuration file
|
11
|
+
MISSING_KEY_ERRORS = [
|
12
|
+
Errors::ProjectIdMissingInConfigurationFile,
|
13
|
+
Errors::ShareableIdMissingInConfigurationFile,
|
14
|
+
Errors::ShareableKeyMissingInConfigurationFile,
|
15
|
+
Errors::BuildPathMissingInConfigurationFile
|
16
|
+
].freeze
|
17
|
+
|
10
18
|
class << self
|
11
19
|
# @param build_path [String] path of the current build
|
20
|
+
#
|
12
21
|
# @return [OpenStruct] open struct with config details
|
22
|
+
#
|
13
23
|
# @example
|
14
24
|
# details = Fetcher.new.call('./')
|
15
25
|
# details.build_path #=> './'
|
16
26
|
def call(build_path)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
27
|
+
build(build_path)
|
28
|
+
rescue Errors::MissingConfigurationFile
|
29
|
+
Bundler.ui.error(build_missing_error_message(build_path))
|
30
|
+
exit 1
|
31
|
+
rescue Errors::EmptyConfigurationFile
|
32
|
+
Bundler.ui.error(build_empty_error_message(build_path))
|
33
|
+
exit 1
|
34
|
+
rescue Errors::MalformedConfigurationFile
|
35
|
+
Bundler.ui.error(build_malformed_error_message(build_path))
|
36
|
+
exit 1
|
37
|
+
rescue *MISSING_KEY_ERRORS => e
|
38
|
+
Bundler.ui.error(build_missing_key_error_message(e))
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# @param build_path [String] path of the current build
|
45
|
+
#
|
46
|
+
# @return [OpenStruct] open struct with config details
|
47
|
+
def build(build_path)
|
48
|
+
content = ERB.new(
|
49
|
+
File.read(
|
50
|
+
FileFinder.call(build_path)
|
51
|
+
)
|
52
|
+
).result
|
53
|
+
|
54
|
+
raise Errors::EmptyConfigurationFile if content.empty?
|
55
|
+
|
56
|
+
OpenStruct.new(parse_file(content).merge(build_path: build_path))
|
57
|
+
.tap(&Validator.method(:call))
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_file(content)
|
61
|
+
YAML.safe_load(content)
|
62
|
+
rescue Psych::SyntaxError
|
63
|
+
raise Errors::MalformedConfigurationFile
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param build_path [String] path of the current build
|
67
|
+
#
|
68
|
+
# @return [String] missing configuration file message
|
69
|
+
def build_missing_error_message(build_path)
|
70
|
+
<<~MSG
|
71
|
+
\nWe were unable to locate Diffend configuration file.\n
|
72
|
+
Please make sure that .diffend.yml is present in #{build_path} folder.\n
|
73
|
+
MSG
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String] empty configuration file message
|
77
|
+
def build_empty_error_message
|
78
|
+
<<~MSG
|
79
|
+
\nYour Diffend configuration file is empty.\n
|
80
|
+
Please re-setup.\n
|
81
|
+
MSG
|
82
|
+
end
|
83
|
+
|
84
|
+
# @return [String] malformed configuration file message
|
85
|
+
def build_malformed_error_message
|
86
|
+
<<~MSG
|
87
|
+
\nYour Diffend configuration file is malformed.\n
|
88
|
+
Please re-setup.\n
|
89
|
+
MSG
|
90
|
+
end
|
91
|
+
|
92
|
+
# @return [String] malformed configuration file message
|
93
|
+
def build_missing_key_error_message(exception)
|
94
|
+
missing_key = missing_key_from_exception(exception)
|
95
|
+
|
96
|
+
<<~MSG
|
97
|
+
\nYour Diffend configuration file is missing #{missing_key} key.\n
|
98
|
+
Please re-setup.\n
|
99
|
+
MSG
|
100
|
+
end
|
101
|
+
|
102
|
+
def missing_key_from_exception(exception)
|
103
|
+
case exception
|
104
|
+
when Errors::ProjectIdMissingInConfigurationFile then 'project_id'
|
105
|
+
when Errors::ShareableIdMissingInConfigurationFile then 'shareable_id'
|
106
|
+
when Errors::ShareableKeyMissingInConfigurationFile then 'shareable_key'
|
107
|
+
when Errors::BuildPathMissingInConfigurationFile then 'build_path'
|
108
|
+
end
|
26
109
|
end
|
27
110
|
end
|
28
111
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Module for all the components related to setting up the config
|
5
|
+
module Config
|
6
|
+
# Class responsible for validating the config from .diffend.yml
|
7
|
+
module Validator
|
8
|
+
class << self
|
9
|
+
# @param config [OpenStruct] path of the current build
|
10
|
+
def call(config)
|
11
|
+
raise Errors::ProjectIdMissingInConfigurationFile if missing?(config, 'project_id')
|
12
|
+
raise Errors::ShareableIdMissingInConfigurationFile if missing?(config, 'shareable_id')
|
13
|
+
raise Errors::ShareableKeyMissingInConfigurationFile if missing?(config, 'shareable_key')
|
14
|
+
raise Errors::BuildPathMissingInConfigurationFile if missing?(config, 'build_path')
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def missing?(config, key)
|
20
|
+
config.public_send(key).nil? || config.public_send(key).empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/diffend/errors.rb
CHANGED
@@ -7,6 +7,18 @@ module Diffend
|
|
7
7
|
BaseError = Class.new(StandardError)
|
8
8
|
# Raised when we couldn't find a valid configuration file
|
9
9
|
MissingConfigurationFile = Class.new(BaseError)
|
10
|
+
# Raised when configuration file is empty
|
11
|
+
EmptyConfigurationFile = Class.new(BaseError)
|
12
|
+
# Raised when configuration file is malformed
|
13
|
+
MalformedConfigurationFile = Class.new(BaseError)
|
14
|
+
# Raised when project_id is missing in configuration file
|
15
|
+
ProjectIdMissingInConfigurationFile = Class.new(BaseError)
|
16
|
+
# Raised when shareable_id is missing in configuration file
|
17
|
+
ShareableIdMissingInConfigurationFile = Class.new(BaseError)
|
18
|
+
# Raised when shareable_key is missing in configuration file
|
19
|
+
ShareableKeyMissingInConfigurationFile = Class.new(BaseError)
|
20
|
+
# Raised when build_path is missing in configuration file
|
21
|
+
BuildPathMissingInConfigurationFile = Class.new(BaseError)
|
10
22
|
# When unsupported response returned from the endpoint
|
11
23
|
UnsupportedResponse = Class.new(BaseError)
|
12
24
|
# When unsupported action returned from the endpoint
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Pajor
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
9MmF6uCQa1EjK2p8tYT0MnbHrFkoehxdX4VO9y99GAkhZyJNKPYPtyAUFV27sT2V
|
35
35
|
LfCJRk4ifKIN/FUCwDSn8Cz0m6oH265q0p6wdzI6qrWOjP8tGOMBTA==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2020-
|
37
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: bundler
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/diffend/commands.rb
|
95
95
|
- lib/diffend/config/fetcher.rb
|
96
96
|
- lib/diffend/config/file_finder.rb
|
97
|
+
- lib/diffend/config/validator.rb
|
97
98
|
- lib/diffend/errors.rb
|
98
99
|
- lib/diffend/voting.rb
|
99
100
|
- lib/diffend/voting/request.rb
|
metadata.gz.sig
CHANGED
Binary file
|