hiptest-publisher 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f43b16fba8918586730a65e4312b062c36b0b68d
4
- data.tar.gz: 996e1d9199c1e7163557a5625dad39f6d5a375d7
3
+ metadata.gz: f219529aaf89fce834dfffb2683f81de8a6c9eff
4
+ data.tar.gz: 401d0ddd19ec7883ade57f1522a44f2c846f1b12
5
5
  SHA512:
6
- metadata.gz: 79fb761dc2208ec15cccc08020853418088972797be6934cf96a2dea547ee35dc846a72eb614ad1b341ceb6d798c3ecb815bf05cf68d4d8118177400232155c3
7
- data.tar.gz: adca0ee51d099c0c2664aaf50b94c3531d44f549dbba800253ac893b0b46df94a8bfa35491f765b166e63f16714b79b7670cdb10efaa64605b6fafc242317755
6
+ metadata.gz: 7c79aba51a8f5fdee28125451b77ef75c1376d9211e809a7dc9e079b4e6ed3d36d87cb35aec33c568bd9d1980c429d273184e4f631f7411a39599ae20f2f5a7c
7
+ data.tar.gz: fbee9b6f63416cf08e764464bdeda95bf6e1ebf5ad245755e6d528339db650215f4cb0e8ddfd28f31d8452d3d191f4abb471a5e1011fd7931a891ccc65ac922e
@@ -36,9 +36,12 @@ module Hiptest
36
36
 
37
37
  def run
38
38
  normalize_cli_options!
39
- if CliOptionsChecker.new(@cli_options, reporter).bad_arguments?
39
+ begin
40
+ CliOptionsChecker.new(@cli_options, reporter).check!
41
+ rescue CliOptionError => e
42
+ puts e.message
40
43
  exit 1 if @exit_on_bad_arguments
41
- return
44
+ raise
42
45
  end
43
46
 
44
47
  if @cli_options.only == 'list'
@@ -1,107 +1,105 @@
1
+ require 'pathname'
1
2
 
2
-
3
-
4
- class CliOptionsChecker
5
- attr_reader :reporter, :cli_options
6
- def initialize(cli_options, reporter)
7
- @cli_options = cli_options
8
- @reporter = reporter
3
+ module Hiptest
4
+ class CliOptionError < StandardError
9
5
  end
10
6
 
11
- def bad_arguments?
12
- # ensure config file was readable if specified
13
- begin
14
- ParseConfig.new(cli_options.config) if present?(cli_options.config)
15
- rescue Errno::EACCES => err
16
- puts "Error with --config: the file \"#{cli_options.config}\" does not exist or is not readable"
17
- return true
7
+ class CliOptionsChecker
8
+ attr_reader :reporter, :cli_options
9
+ def initialize(cli_options, reporter)
10
+ @cli_options = cli_options
11
+ @reporter = reporter
18
12
  end
19
13
 
20
- if cli_options.only == 'list'
21
- return
22
- end
14
+ def check!
15
+ # ensure config file was readable if specified
16
+ begin
17
+ ParseConfig.new(cli_options.config) if present?(cli_options.config)
18
+ rescue Errno::EACCES => err
19
+ raise CliOptionError, "Error with --config: the file \"#{cli_options.config}\" does not exist or is not readable"
20
+ end
23
21
 
24
- unless cli_options.push.nil? || cli_options.push.empty?
25
- return
26
- end
22
+ if cli_options.only == 'list'
23
+ return
24
+ end
27
25
 
28
- # secret token
29
- if missing?(cli_options.token) || empty?(cli_options.token)
30
- puts "Missing argument --token: you must specify project secret token with --token=<project-token>"
31
- puts ""
32
- puts "The project secret token can be found on Hiptest in the settings section, under"
33
- puts "'Publication settings'. It is a sequence of numbers uniquely identifying your"
34
- puts "project."
35
- puts ""
36
- puts "Note that settings section is available only to administrators of the project."
37
- return true
38
- end
26
+ unless cli_options.push.nil? || cli_options.push.empty?
27
+ return
28
+ end
39
29
 
40
- unless numeric?(cli_options.token)
41
- puts "Invalid format --token=\"#{@cli_options.token}\": the project secret token must be numeric"
42
- return true
43
- end
30
+ # secret token
31
+ if missing?(cli_options.token) || empty?(cli_options.token)
32
+ raise CliOptionError, [
33
+ "Missing argument --token: you must specify project secret token with --token=<project-token>",
34
+ "",
35
+ "The project secret token can be found on Hiptest in the settings section, under",
36
+ "'Publication settings'. It is a sequence of numbers uniquely identifying your",
37
+ "project.",
38
+ "",
39
+ "Note that settings section is available only to administrators of the project.",
40
+ ].join("\n")
41
+ end
44
42
 
45
- # output directory
46
- parent = first_existing_parent(cli_options.output_directory)
47
- if !parent.writable?
48
- if parent.realpath === Pathname.new(cli_options.output_directory).cleanpath
49
- puts "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" is not writable"
50
- else
51
- puts "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" can not be created because \"#{parent.realpath}\" is not writable"
43
+ unless numeric?(cli_options.token)
44
+ raise CliOptionError, "Invalid format --token=\"#{@cli_options.token}\": the project secret token must be numeric"
52
45
  end
53
- return true
54
- elsif !parent.directory?
55
- puts "Error with --output-directory: the file \"#{@cli_options.output_directory}\" is not a directory"
56
- return true
57
- end
58
46
 
59
- # actionwords signature file
60
- if cli_options.actionwords_diff || cli_options.aw_deleted || cli_options.aw_created || cli_options.aw_renamed || cli_options.aw_signature_changed
61
- actionwords_signature_file = Pathname.new(cli_options.output_directory).join("actionwords_signature.yaml")
62
- if actionwords_signature_file.directory?
63
- puts "Bad Action Words signature file: the file \"#{actionwords_signature_file.realpath}\" is a directory"
64
- return true
65
- elsif !actionwords_signature_file.exist?
66
- full_path = File.expand_path(cli_options.output_directory)
67
- puts "Missing Action Words signature file: the file \"actionwords_signature.yaml\" could not be found in directory \"#{full_path}\""
68
- puts "Use --actionwords-signature to generate the file \"#{full_path}/actionwords_signature.yaml\""
69
- return true
47
+ # output directory
48
+ parent = first_existing_parent(cli_options.output_directory)
49
+ if !parent.writable?
50
+ if parent.realpath === Pathname.new(cli_options.output_directory).cleanpath
51
+ raise CliOptionError, "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" is not writable"
52
+ else
53
+ raise CliOptionError, "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" can not be created because \"#{parent.realpath}\" is not writable"
54
+ end
55
+ elsif !parent.directory?
56
+ raise CliOptionError, "Error with --output-directory: the file \"#{@cli_options.output_directory}\" is not a directory"
70
57
  end
71
- end
72
58
 
73
- # test run id
74
- if present?(cli_options.test_run_id) && !numeric?(cli_options.test_run_id)
75
- puts "Invalid format --test-run-id=\"#{@cli_options.test_run_id}\": the test run id must be numeric"
76
- return true
77
- end
59
+ # actionwords signature file
60
+ if cli_options.actionwords_diff || cli_options.aw_deleted || cli_options.aw_created || cli_options.aw_renamed || cli_options.aw_signature_changed
61
+ actionwords_signature_file = Pathname.new(cli_options.output_directory).join("actionwords_signature.yaml")
62
+ if actionwords_signature_file.directory?
63
+ raise CliOptionError, "Bad Action Words signature file: the file \"#{actionwords_signature_file.realpath}\" is a directory"
64
+ elsif !actionwords_signature_file.exist?
65
+ full_path = File.expand_path(cli_options.output_directory)
66
+ raise CliOptionError, [
67
+ "Missing Action Words signature file: the file \"actionwords_signature.yaml\" could not be found in directory \"#{full_path}\"",
68
+ "Use --actionwords-signature to generate the file \"#{full_path}/actionwords_signature.yaml\"",
69
+ ].join("\n")
70
+ end
71
+ end
78
72
 
79
- return false
80
- end
73
+ # test run id
74
+ if present?(cli_options.test_run_id) && !numeric?(cli_options.test_run_id)
75
+ raise CliOptionError, "Invalid format --test-run-id=\"#{@cli_options.test_run_id}\": the test run id must be numeric"
76
+ end
77
+ end
81
78
 
82
- private
79
+ private
83
80
 
84
- def numeric?(arg)
85
- arg =~ /^\d*$/
86
- end
81
+ def numeric?(arg)
82
+ arg =~ /^\d*$/
83
+ end
87
84
 
88
- def missing?(arg)
89
- arg.nil?
90
- end
85
+ def missing?(arg)
86
+ arg.nil?
87
+ end
91
88
 
92
- def empty?(arg)
93
- arg.strip.empty?
94
- end
89
+ def empty?(arg)
90
+ arg.strip.empty?
91
+ end
95
92
 
96
- def present?(arg)
97
- arg && !arg.strip.empty?
98
- end
93
+ def present?(arg)
94
+ arg && !arg.strip.empty?
95
+ end
99
96
 
100
- def first_existing_parent(path)
101
- pathname = Pathname.new(path)
102
- while !pathname.exist?
103
- pathname = pathname.parent
97
+ def first_existing_parent(path)
98
+ pathname = Pathname.new(path)
99
+ while !pathname.exist?
100
+ pathname = pathname.parent
101
+ end
102
+ pathname.realpath
104
103
  end
105
- pathname.realpath
106
104
  end
107
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptest-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiptest R&D
@@ -108,56 +108,56 @@ dependencies:
108
108
  name: ruby-handlebars
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - "~>"
112
112
  - !ruby/object:Gem::Version
113
113
  version: 0.0.2
114
114
  type: :runtime
115
115
  prerelease: false
116
116
  version_requirements: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - ">="
118
+ - - "~>"
119
119
  - !ruby/object:Gem::Version
120
120
  version: 0.0.2
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: pry
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">="
125
+ - - "~>"
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  type: :development
129
129
  prerelease: false
130
130
  version_requirements: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - ">="
132
+ - - "~>"
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: pry-byebug
137
137
  requirement: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - ">="
139
+ - - "~>"
140
140
  - !ruby/object:Gem::Version
141
- version: '0'
141
+ version: '3'
142
142
  type: :development
143
143
  prerelease: false
144
144
  version_requirements: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - ">="
146
+ - - "~>"
147
147
  - !ruby/object:Gem::Version
148
- version: '0'
148
+ version: '3'
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: pry-stack_explorer
151
151
  requirement: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - ">="
153
+ - - "~>"
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  type: :development
157
157
  prerelease: false
158
158
  version_requirements: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - ">="
160
+ - - "~>"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  - !ruby/object:Gem::Dependency