chemlab 0.4.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +8 -0
  3. data/bin/chemlab +10 -0
  4. data/bin/chemlab-suite +1 -0
  5. data/bin/chemlab-test +1 -0
  6. data/lib/chemlab.rb +27 -17
  7. data/lib/chemlab/attributable.rb +16 -10
  8. data/lib/chemlab/cli/fixtures/new_library/.gitignore +63 -0
  9. data/lib/chemlab/cli/fixtures/new_library/Gemfile +5 -0
  10. data/lib/chemlab/cli/fixtures/new_library/README.md.erb +1 -0
  11. data/lib/chemlab/cli/fixtures/new_library/lib/new_library.rb.erb +7 -0
  12. data/lib/chemlab/cli/fixtures/new_library/lib/page/sample.rb.erb +9 -0
  13. data/lib/chemlab/cli/fixtures/new_library/new_library.gemspec.erb +23 -0
  14. data/lib/chemlab/cli/fixtures/new_library/spec/integration/page/sample_spec.rb.erb +17 -0
  15. data/lib/chemlab/cli/fixtures/new_library/spec/unit/page/sample_spec.rb.erb +19 -0
  16. data/lib/chemlab/cli/generator.rb +46 -0
  17. data/lib/chemlab/cli/generator/templates/page.erb +3 -0
  18. data/lib/chemlab/cli/new_library.rb +62 -0
  19. data/lib/chemlab/cli/stub.erb +66 -0
  20. data/lib/chemlab/cli/stubber.rb +74 -0
  21. data/lib/chemlab/component.rb +78 -8
  22. data/lib/chemlab/configuration.rb +60 -12
  23. data/lib/chemlab/element.rb +4 -0
  24. data/lib/chemlab/page.rb +19 -1
  25. data/lib/chemlab/runtime/browser.rb +13 -18
  26. data/lib/chemlab/runtime/env.rb +13 -9
  27. data/lib/chemlab/runtime/logger.rb +16 -13
  28. data/lib/chemlab/version.rb +1 -1
  29. data/lib/tasks/generate.rake +22 -0
  30. data/lib/tasks/generate_stubs.rake +20 -0
  31. data/lib/tasks/help.rake +24 -0
  32. data/lib/tasks/new.rake +19 -0
  33. data/lib/tasks/version.rake +8 -0
  34. metadata +113 -57
  35. data/lib/chemlab/api_fabricator.rb +0 -134
  36. data/lib/chemlab/resource.rb +0 -169
  37. data/lib/chemlab/runtime/api_client.rb +0 -18
  38. data/lib/chemlab/support/api.rb +0 -71
  39. data/lib/chemlab/support/logging.rb +0 -176
  40. data/lib/chemlab/support/repeater.rb +0 -65
  41. data/lib/chemlab/support/waiter.rb +0 -39
@@ -1,23 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logger'
4
- require 'forwardable'
5
-
6
3
  module Chemlab
7
4
  module Runtime
5
+ # Logger module
8
6
  module Logger
9
- extend SingleForwardable
10
-
11
- def_delegators :logger, :debug, :info, :warn, :error, :fatal, :unknown
7
+ # Log something to a stream
8
+ # @param [Any] obj Any object that responds to #to_s
9
+ # @param [Symbol] type The type of message logged
10
+ # @param [Hash] args Any additional arguments
11
+ # @example
12
+ # log('something', :info) #=> logs INFO :: something, to $stdout
13
+ # log('error', :err) #=> logs ERR :: error, to $stderr
14
+ # log('important', :important, stream: $stderr) #=> logs IMPO :: important, to $stderr
15
+ # log('to file', :info, stream: File.open('file.txt', 'w')) #=> logs INFO :: to file, to the file.txt file
16
+ def log(obj, type = :info, **args)
17
+ raise ArgumentError, "Cannot log #{obj} as it does not respond to to_s!" unless obj.respond_to?(:to_s)
12
18
 
13
- singleton_class.module_eval do
14
- attr_writer :logger
19
+ args[:stream] = type.match?(/(err(or)?|warn(ing)?)/) ? $stderr : $stdout
15
20
 
16
- def logger
17
- @logger ||= ::Logger.new(Runtime::Env.log_destination).tap do |logger|
18
- logger.level = Runtime::Env.debug? ? ::Logger::DEBUG : ::Logger::ERROR
19
- end
20
- end
21
+ prefix = Time.now.strftime('%Y-%m-%d %H:%M:%S / ')
22
+ prefix << type[0..3].upcase << "\t:: " # we only want the prefix to be four chars long
23
+ args[:stream].puts(prefix << obj.to_s)
21
24
  end
22
25
  end
23
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chemlab
4
- VERSION = '0.4.0'
4
+ VERSION = '0.7.1'
5
5
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ desc <<-DESCRIPTION
4
+ Generate something
5
+
6
+ Arguments: WHAT NAME [ARGS]
7
+ Examples:
8
+ - generate page Login path=/users/sign_in
9
+ Generates a page library
10
+ Notes:
11
+ - [ARGS] will be in form key=value separated by `=`
12
+ DESCRIPTION
13
+ task :generate do |_, args|
14
+ require_relative '../chemlab/cli/generator'
15
+
16
+ raise ArgumentError, 'Please specify what to generate and the name' if args.size < 2
17
+
18
+ what = args.shift
19
+ name = args.shift
20
+
21
+ Chemlab::CLI::Generator.generate(what, name, args)
22
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :generate do
4
+ desc <<-DESCRIPTION
5
+ Generate page library stubs
6
+
7
+ Arguments: PATH
8
+ Examples:
9
+ - generate:stubs qa/page/login.rb
10
+ Generate stubs for a specific page library
11
+ - generate:stubs qa/page
12
+ Generates stubs for all page libraries in `qa/page`
13
+ DESCRIPTION
14
+ task :stubs do |_, path|
15
+ puts "Doin some stubbin in #{path}"
16
+
17
+ require_relative '../chemlab/cli/stubber'
18
+ Chemlab::CLI::Stubber.stub_all(path)
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+
5
+ desc 'Show the help'
6
+ task '--help' do
7
+ usage = +%(Usage: #{$PROGRAM_NAME} TASK\n)
8
+
9
+ Rake.application.tasks.each do |task|
10
+ usage += %(#{task.name.bold}: #{task.comment}\n)
11
+
12
+ next unless task.full_comment && task.full_comment != task.comment
13
+
14
+ # standardize and colorize the description
15
+ full_comment = task.full_comment.gsub(/(Arguments|Examples|Notes):/, '\1:'.underline)
16
+
17
+ # remove the short description and the newlines
18
+ full_comment = full_comment[task.comment.size + 2..]
19
+
20
+ usage += %(#{full_comment}\n\n)
21
+ end
22
+
23
+ $stdout.puts usage
24
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ desc <<-DESCRIPTION
4
+ Scaffold a new Chemlab Library
5
+
6
+ Arguments: PATH
7
+ Examples:
8
+ - new my-library
9
+ Scaffolds a new Chemlab Library in the `my-library` directory.
10
+ This will fail if the PATH already exists
11
+ DESCRIPTION
12
+ task 'new' do |_, args|
13
+ require_relative '../chemlab/cli/new_library'
14
+
15
+ library = args.first
16
+
17
+ warn "NOTE: Only creating #{library}" if args.size > 1
18
+ Chemlab::CLI::NewLibrary.scaffold(library)
19
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ desc 'Shows the version'
4
+ task '--version' do
5
+ require_relative '../chemlab/version'
6
+
7
+ $stdout.puts %(#{$PROGRAM_NAME} version #{Chemlab::VERSION})
8
+ end
metadata CHANGED
@@ -1,214 +1,270 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chemlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: debase
14
+ name: climate_control
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.4.1
19
+ version: 1.0.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.4.1
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: faker
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 1.6.6
33
+ version: 1.10.9
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '1.6'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.6.6
40
+ version: 1.10.9
47
41
  - !ruby/object:Gem::Dependency
48
- name: pry-byebug
42
+ name: pry
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 3.5.1
47
+ version: 0.14.1
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: 3.5.1
54
+ version: 0.14.1
61
55
  - !ruby/object:Gem::Dependency
62
- name: ruby-debug-ide
56
+ name: rspec
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: 0.7.0
61
+ version: '3.7'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: 0.7.0
68
+ version: '3.7'
75
69
  - !ruby/object:Gem::Dependency
76
- name: timecop
70
+ name: rspec-parameterized
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
73
  - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: 0.9.1
75
+ version: 0.4.2
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: 0.9.1
82
+ version: 0.4.2
89
83
  - !ruby/object:Gem::Dependency
90
- name: rspec
84
+ name: rubocop
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '3.7'
89
+ version: 1.14.0
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: '3.7'
96
+ version: 1.14.0
103
97
  - !ruby/object:Gem::Dependency
104
- name: rspec-retry
98
+ name: rubocop-rspec
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
101
  - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: 0.6.1
103
+ version: 2.3.0
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: 0.6.1
110
+ version: 2.3.0
117
111
  - !ruby/object:Gem::Dependency
118
- name: rspec_junit_formatter
112
+ name: yard
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: 0.4.1
117
+ version: 0.9.26
124
118
  type: :development
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: 0.4.1
124
+ version: 0.9.26
131
125
  - !ruby/object:Gem::Dependency
132
- name: nokogiri
126
+ name: activesupport-inflector
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - "~>"
136
130
  - !ruby/object:Gem::Version
137
- version: 1.10.9
138
- type: :development
131
+ version: '0.1'
132
+ type: :runtime
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
136
  - - "~>"
143
137
  - !ruby/object:Gem::Version
144
- version: 1.10.9
138
+ version: '0.1'
145
139
  - !ruby/object:Gem::Dependency
146
- name: rake
140
+ name: colorize
147
141
  requirement: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - "~>"
150
144
  - !ruby/object:Gem::Version
151
- version: 12.3.0
145
+ version: '0.8'
152
146
  type: :runtime
153
147
  prerelease: false
154
148
  version_requirements: !ruby/object:Gem::Requirement
155
149
  requirements:
156
150
  - - "~>"
157
151
  - !ruby/object:Gem::Version
158
- version: 12.3.0
152
+ version: '0.8'
159
153
  - !ruby/object:Gem::Dependency
160
- name: selenium-webdriver
154
+ name: i18n
161
155
  requirement: !ruby/object:Gem::Requirement
162
156
  requirements:
163
157
  - - "~>"
164
158
  - !ruby/object:Gem::Version
165
- version: '3.12'
159
+ version: '1.8'
166
160
  type: :runtime
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - "~>"
171
165
  - !ruby/object:Gem::Version
172
- version: '3.12'
166
+ version: '1.8'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '12'
174
+ - - "<"
175
+ - !ruby/object:Gem::Version
176
+ version: '14'
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '12'
184
+ - - "<"
185
+ - !ruby/object:Gem::Version
186
+ version: '14'
187
+ - !ruby/object:Gem::Dependency
188
+ name: selenium-webdriver
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '3'
194
+ - - "<"
195
+ - !ruby/object:Gem::Version
196
+ version: '5'
197
+ type: :runtime
198
+ prerelease: false
199
+ version_requirements: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '3'
204
+ - - "<"
205
+ - !ruby/object:Gem::Version
206
+ version: '5'
173
207
  - !ruby/object:Gem::Dependency
174
208
  name: watir
175
209
  requirement: !ruby/object:Gem::Requirement
176
210
  requirements:
177
- - - "~>"
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '6'
214
+ - - "<"
178
215
  - !ruby/object:Gem::Version
179
- version: '6.17'
216
+ version: '8'
180
217
  type: :runtime
181
218
  prerelease: false
182
219
  version_requirements: !ruby/object:Gem::Requirement
183
220
  requirements:
184
- - - "~>"
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '6'
224
+ - - "<"
185
225
  - !ruby/object:Gem::Version
186
- version: '6.17'
226
+ version: '8'
187
227
  description:
188
228
  email:
189
229
  - quality@gitlab.com
190
- executables: []
230
+ executables:
231
+ - chemlab
191
232
  extensions: []
192
233
  extra_rdoc_files: []
193
234
  files:
235
+ - Rakefile
236
+ - bin/chemlab
237
+ - bin/chemlab-suite
238
+ - bin/chemlab-test
194
239
  - lib/chemlab.rb
195
- - lib/chemlab/api_fabricator.rb
196
240
  - lib/chemlab/attributable.rb
241
+ - lib/chemlab/cli/fixtures/new_library/.gitignore
242
+ - lib/chemlab/cli/fixtures/new_library/Gemfile
243
+ - lib/chemlab/cli/fixtures/new_library/README.md.erb
244
+ - lib/chemlab/cli/fixtures/new_library/lib/new_library.rb.erb
245
+ - lib/chemlab/cli/fixtures/new_library/lib/page/sample.rb.erb
246
+ - lib/chemlab/cli/fixtures/new_library/new_library.gemspec.erb
247
+ - lib/chemlab/cli/fixtures/new_library/spec/integration/page/sample_spec.rb.erb
248
+ - lib/chemlab/cli/fixtures/new_library/spec/unit/page/sample_spec.rb.erb
249
+ - lib/chemlab/cli/generator.rb
250
+ - lib/chemlab/cli/generator/templates/page.erb
251
+ - lib/chemlab/cli/new_library.rb
252
+ - lib/chemlab/cli/stub.erb
253
+ - lib/chemlab/cli/stubber.rb
197
254
  - lib/chemlab/component.rb
198
255
  - lib/chemlab/configuration.rb
199
256
  - lib/chemlab/element.rb
200
257
  - lib/chemlab/page.rb
201
- - lib/chemlab/resource.rb
202
- - lib/chemlab/runtime/api_client.rb
203
258
  - lib/chemlab/runtime/browser.rb
204
259
  - lib/chemlab/runtime/env.rb
205
260
  - lib/chemlab/runtime/logger.rb
206
- - lib/chemlab/support/api.rb
207
- - lib/chemlab/support/logging.rb
208
- - lib/chemlab/support/repeater.rb
209
- - lib/chemlab/support/waiter.rb
210
261
  - lib/chemlab/version.rb
211
- homepage: https://about.gitlab.com
262
+ - lib/tasks/generate.rake
263
+ - lib/tasks/generate_stubs.rake
264
+ - lib/tasks/help.rake
265
+ - lib/tasks/new.rake
266
+ - lib/tasks/version.rake
267
+ homepage: https://about.gitlab.com/
212
268
  licenses:
213
269
  - MIT
214
270
  metadata: {}
@@ -220,14 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
276
  requirements:
221
277
  - - ">="
222
278
  - !ruby/object:Gem::Version
223
- version: '0'
279
+ version: 2.7.2
224
280
  required_rubygems_version: !ruby/object:Gem::Requirement
225
281
  requirements:
226
282
  - - ">="
227
283
  - !ruby/object:Gem::Version
228
284
  version: '0'
229
285
  requirements: []
230
- rubygems_version: 3.0.6
286
+ rubygems_version: 3.1.4
231
287
  signing_key:
232
288
  specification_version: 4
233
289
  summary: Automation framework built by GitLab, for the world.