screengem 0.16.0 → 0.17.0

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
  SHA256:
3
- metadata.gz: '05882b1d14fcb9e81a7b940a395de8e34167d0652ee564800be2cb5b784633d6'
4
- data.tar.gz: 91ba212fd5c24bb7b1ddae9b79a4504aca3f1d8cba2949a16aaf5691091b9420
3
+ metadata.gz: a9311c4efbaf425f5cb08c89cb7ec0df2408ce296e8df1725fc63ce073c27878
4
+ data.tar.gz: 8ef3d9d8f9b4e7b3fb28ef55b1f5a084e96d0e32b84178cee531d27143926e54
5
5
  SHA512:
6
- metadata.gz: 4203bdfd6d5d28f387bcbb5df19a02f318e73465f5b845103d8e3c365dfbb3a91999b8897b3f93aa48956c2a3b36b54e57dd6e95a4bdd930cf2bca56707680a0
7
- data.tar.gz: 6a16b7076d33d3eeeb80c30c7b1fc5a107524a5ca0d93fd308eebb10092ee43ce206e63a7466154f4ec7fb9a7151c36b884f4e121fdc203caf2cd6dd43b1b80d
6
+ metadata.gz: 9e391d87bc90efc2153fb3cbfcd094d51c9676f94a7371111494a8d174b83f9a12d703a562470ae18be9533156f20b954286a003c1a8832947841599c57d62a1
7
+ data.tar.gz: 548acebf1c946d4235a908a6c6f5d50a1f520bbf20373a8625254613f3fc58ad1f60300a82a6038d180d9f0a11deb3808925531381165b88dba3b8bb3d46a33c
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
- require: rubocop-rspec
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
2
5
 
3
6
  AllCops:
4
7
  NewCops: enable
@@ -48,6 +51,10 @@ RSpec/DescribedClass:
48
51
  RSpec/ExampleLength:
49
52
  Max: 20
50
53
 
54
+ RSpec/FilePath:
55
+ Exclude:
56
+ - spec/screengem/concerns/*_spec.rb
57
+
51
58
  RSpec/MultipleMemoizedHelpers:
52
59
  Max: 8
53
60
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## main (unreleased)
4
4
 
5
+ ## 0.17.0 (2022-10-11)
6
+
7
+ ### Breaking Changes
8
+
9
+ * Drop support for dampening
10
+
5
11
  ## 0.16.0 (2022-08-03)
6
12
 
7
13
  * Allow actor to recall with a default
data/README.md CHANGED
@@ -53,19 +53,6 @@ when no exception is thrown and negatively when an exception is thrown.
53
53
 
54
54
  [RSpec expectations](https://github.com/rspec/rspec-expectations) are available in all questions and are the recommended way to implement a question.
55
55
 
56
- ## Dampening
57
-
58
- It sometimes makes sense to slow down the automation. This is known as dampening.
59
-
60
- To enable and configure dampening perform the following steps:
61
-
62
- 1. Create a sample dampening configuration `screengem generate --root features_screenplay`
63
- 1. Tweak the sample dampening configuration
64
- 1. Promote the sample dampening configuration `cp ./features_screenplay/dampen_configuration.yml.sample ./features_screenplay/dampen_configuration.yml`
65
- 1. Enable dampening `export APPLY_DAMPENING=1`
66
-
67
- To stop dampening, run `unset APPLY_DAMPENING`
68
-
69
56
  ## Installation
70
57
 
71
58
  Add this line to your application's Gemfile:
@@ -9,22 +9,13 @@ module Screengem
9
9
  def self.configure
10
10
  self.configuration ||= Screengem::Configuration.new
11
11
 
12
- yield(configuration)
12
+ yield(configuration) if block_given?
13
13
  end
14
14
 
15
15
  #
16
16
  # Configuration for the Screengem gem.
17
17
  #
18
18
  class Configuration
19
- # The name of the YAML file that is used to configure dampening.
20
- attr_accessor :dampen_configuration_filename
21
-
22
- # The top level key in the YAML file that is used to configure dampening.
23
- attr_accessor :dampen_configuration_root
24
-
25
- # A boolean that specifies that dampening is to be applied.
26
- attr_accessor :apply_dampening
27
-
28
19
  # A string that namespaces questions classes (used by the QuestionFactory).
29
20
  attr_accessor :question_scope
30
21
 
@@ -32,20 +23,8 @@ module Screengem
32
23
  attr_accessor :task_scope
33
24
 
34
25
  def initialize
35
- self.apply_dampening = false
36
-
37
- self.dampen_configuration_root = "default"
38
-
39
26
  self.question_scope = "Questions"
40
27
  self.task_scope = "Tasks"
41
28
  end
42
-
43
- def apply_dampening?
44
- apply_dampening
45
- end
46
-
47
- def dampen_configuration_sample_filename
48
- "#{dampen_configuration_filename}.sample"
49
- end
50
29
  end
51
30
  end
@@ -24,8 +24,6 @@ module Screengem
24
24
 
25
25
  class QuestionError < ::Screengem::Question
26
26
  include FactoryCreationError
27
-
28
- skip_dampening
29
27
  end
30
28
 
31
29
  private
@@ -24,8 +24,6 @@ module Screengem
24
24
 
25
25
  class TaskError < ::Screengem::Task
26
26
  include FactoryCreationError
27
-
28
- skip_dampening
29
27
  end
30
28
 
31
29
  private
@@ -6,13 +6,10 @@ module Screengem
6
6
  include RSpec::Matchers
7
7
 
8
8
  include Screengem::Configurable
9
- include Screengem::Dampenable
10
9
  include Screengem::Executable
11
10
 
12
- dampen_scope :questions
13
-
14
11
  def answer
15
- execute.tap { sleep(seconds_to_dampen) }
12
+ execute
16
13
  end
17
14
  end
18
15
  end
@@ -6,15 +6,12 @@ module Screengem
6
6
  include RSpec::Matchers
7
7
 
8
8
  include Screengem::Configurable
9
- include Screengem::Dampenable
10
9
  include Screengem::Executable
11
10
 
12
11
  include Screengem::DSL
13
12
 
14
- dampen_scope :tasks
15
-
16
13
  def perform
17
- execute.tap { sleep(seconds_to_dampen) }
14
+ execute
18
15
  end
19
16
  end
20
17
  end
@@ -1,3 +1,3 @@
1
1
  module Screengem
2
- VERSION = "0.16.0"
2
+ VERSION = "0.17.0"
3
3
  end
data/lib/screengem.rb CHANGED
@@ -13,12 +13,8 @@ require "screengem/screen_element"
13
13
  require "screengem/screengem_error"
14
14
 
15
15
  require "screengem/configuration"
16
- require "screengem/primitive_key"
17
- require "screengem/dampen_configuration"
18
- require "screengem/dampen_configuration_generator"
19
16
 
20
17
  require "screengem/concerns/configurable"
21
- require "screengem/concerns/dampenable"
22
18
  require "screengem/concerns/executable"
23
19
 
24
20
  require "screengem/dsl"
@@ -36,8 +32,6 @@ require "screengem/factories/task_factory"
36
32
 
37
33
  require "screengem/screen_elements"
38
34
 
39
- require "screengem/cli"
40
-
41
35
  require "screengem/version"
42
36
 
43
37
  module Screengem
data/screengem.gemspec CHANGED
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "capybara", ">= 3.0", "< 4.0"
34
34
  spec.add_runtime_dependency "require_all", ">= 3.0", "< 4.0"
35
35
  spec.add_runtime_dependency "rspec-expectations", "~> 3.11"
36
- spec.add_runtime_dependency "thor", "~> 1.2"
37
36
 
38
37
  spec.add_development_dependency "rake", "~> 13.0"
39
38
  spec.add_development_dependency "rspec", "~> 3.11"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screengem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alistair McKinnell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-03 00:00:00.000000000 Z
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,20 +84,6 @@ dependencies:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
86
  version: '3.11'
87
- - !ruby/object:Gem::Dependency
88
- name: thor
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - "~>"
92
- - !ruby/object:Gem::Version
93
- version: '1.2'
94
- type: :runtime
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - "~>"
99
- - !ruby/object:Gem::Version
100
- version: '1.2'
101
87
  - !ruby/object:Gem::Dependency
102
88
  name: rake
103
89
  requirement: !ruby/object:Gem::Requirement
@@ -199,8 +185,7 @@ dependencies:
199
185
  description:
200
186
  email:
201
187
  - alistairm@nulogy.com
202
- executables:
203
- - screengem
188
+ executables: []
204
189
  extensions: []
205
190
  extra_rdoc_files: []
206
191
  files:
@@ -217,24 +202,18 @@ files:
217
202
  - Rakefile
218
203
  - bin/console
219
204
  - bin/setup
220
- - exe/screengem
221
205
  - images/ScreengemCore.png
222
206
  - lib/screengem.rb
223
207
  - lib/screengem/actor.rb
224
208
  - lib/screengem/actor_memory.rb
225
209
  - lib/screengem/automatic_visit.rb
226
- - lib/screengem/cli.rb
227
210
  - lib/screengem/concerns/configurable.rb
228
- - lib/screengem/concerns/dampenable.rb
229
211
  - lib/screengem/concerns/executable.rb
230
212
  - lib/screengem/configuration.rb
231
- - lib/screengem/dampen_configuration.rb
232
- - lib/screengem/dampen_configuration_generator.rb
233
213
  - lib/screengem/dsl.rb
234
214
  - lib/screengem/factories/factory_creation_error.rb
235
215
  - lib/screengem/factories/question_factory.rb
236
216
  - lib/screengem/factories/task_factory.rb
237
- - lib/screengem/primitive_key.rb
238
217
  - lib/screengem/question.rb
239
218
  - lib/screengem/rails_routes.rb
240
219
  - lib/screengem/screen_element.rb
@@ -266,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
245
  - !ruby/object:Gem::Version
267
246
  version: '0'
268
247
  requirements: []
269
- rubygems_version: 3.3.18
248
+ rubygems_version: 3.3.22
270
249
  signing_key:
271
250
  specification_version: 4
272
251
  summary: Ruby implementation of the Screengem Pattern.
data/exe/screengem DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Add the screengem/lib directory to the load path
4
- $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
5
-
6
- require "screengem"
7
-
8
- Screengem::CLI.start(ARGV)
data/lib/screengem/cli.rb DELETED
@@ -1,32 +0,0 @@
1
- require "require_all"
2
- require "thor"
3
-
4
- module Screengem
5
- class CLI < Thor
6
- option :root, desc: "The directory to start scanning for Tasks and Questions"
7
- option :config, default: "dampen_configuration.yml", desc: "The name of the dampen configuration file"
8
- option :quiet, default: false, desc: "Suppress command output"
9
- desc "generate", "Create the sample dampening configuration"
10
- def generate
11
- # Require Rails to be loaded so that we can successfully require questions and tasks.
12
- require "./config/environment"
13
-
14
- root = options[:root]
15
-
16
- # Require all questions and tasks for inclusion in the sample configuration.
17
- require_all root
18
-
19
- Screengem.configure do |config|
20
- config.dampen_configuration_filename = File.join(root, options[:config])
21
- end
22
-
23
- sample_filename = Screengem.configuration.dampen_configuration_sample_filename
24
-
25
- puts "Regenerating #{sample_filename} ..." unless options[:quiet]
26
-
27
- sample_configuration = Screengem::DampenConfigurationGenerator.new.generate
28
-
29
- File.write(sample_filename, sample_configuration.to_yaml)
30
- end
31
- end
32
- end
@@ -1,54 +0,0 @@
1
- module Screengem
2
- #
3
- # Concern for adding dampening to primitives.
4
- #
5
- module Dampenable
6
- extend ActiveSupport::Concern
7
-
8
- class_methods do
9
- #
10
- # Since most primitives may be dampened.
11
- #
12
- def supports_dampening?
13
- true
14
- end
15
-
16
- #
17
- # Specify a primitive subclass with no dampening.
18
- #
19
- def skip_dampening
20
- define_singleton_method(:supports_dampening?) do
21
- false
22
- end
23
- end
24
-
25
- #
26
- # Specify the dampening configuration scope.
27
- #
28
- def dampen_scope(scope)
29
- define_method(:dampening_scope) do
30
- scope
31
- end
32
- end
33
-
34
- #
35
- # Specify dampening to apply to a primitive.
36
- #
37
- def dampen_for(seconds)
38
- define_singleton_method(:seconds_to_dampen) do
39
- seconds
40
- end
41
- end
42
- end
43
-
44
- def seconds_to_dampen
45
- dampen_configuration.seconds_to_dampen(dampening_scope, self.class.name)
46
- end
47
-
48
- private
49
-
50
- def dampen_configuration
51
- Screengem::DampenConfiguration.instance.configuration
52
- end
53
- end
54
- end
@@ -1,85 +0,0 @@
1
- module Screengem
2
- #
3
- # Exposes the question and task sleep intervals as defined in the dampening configuration.
4
- #
5
- class DampenConfiguration
6
- include ::Singleton
7
-
8
- attr_reader :configuration
9
-
10
- def initialize
11
- @configuration = DampenConfigurationFactory.new.build_configuration
12
- end
13
-
14
- def dampen_configuration_key(primitive_class_name)
15
- primitive_class_name.demodulize.underscore.gsub(/_(question|task)$/, "")
16
- end
17
-
18
- #
19
- # Knows how to build a dampen configuration.
20
- #
21
- class DampenConfigurationFactory
22
- def build_configuration
23
- if dampening_configured?
24
- DampenConfiguration::Standard.new(load_configuration)
25
- else
26
- DampenConfiguration::None.new
27
- end
28
- end
29
-
30
- private
31
-
32
- def dampening_configured?
33
- apply_dampening? && configuration_file_exists?
34
- end
35
-
36
- def apply_dampening?
37
- Screengem.configuration.apply_dampening?
38
- end
39
-
40
- def configuration_file_exists?
41
- File.exist?(configuration_yaml)
42
- end
43
-
44
- def load_configuration
45
- YAML.load_file(configuration_yaml)
46
- end
47
-
48
- def configuration_yaml
49
- Screengem.configuration.dampen_configuration_filename
50
- end
51
- end
52
-
53
- #
54
- # Respond by looking up seconds to dampen in the specified settings.
55
- #
56
- class Standard
57
- include Screengem::PrimitiveKey
58
-
59
- attr_reader :settings
60
-
61
- def initialize(settings)
62
- @settings = ActiveSupport::HashWithIndifferentAccess.new(settings).fetch(dampen_configuration_root, {})
63
- end
64
-
65
- def seconds_to_dampen(primitive_scope, primitive_class_name)
66
- settings.dig(primitive_scope, primitive_key(primitive_class_name)).to_i
67
- end
68
-
69
- private
70
-
71
- def dampen_configuration_root
72
- Screengem.configuration.dampen_configuration_root
73
- end
74
- end
75
-
76
- #
77
- # Always respond with no dampening.
78
- #
79
- class None
80
- def seconds_to_dampen(_primitive_scope, _primitive_class_name)
81
- 0
82
- end
83
- end
84
- end
85
- end
@@ -1,57 +0,0 @@
1
- module Screengem
2
- #
3
- # Knows how to generate the sample dampen configuration.
4
- #
5
- class DampenConfigurationGenerator
6
- include Screengem::PrimitiveKey
7
-
8
- # Seconds to sleep after executing a question or task.
9
- DEFAULT_SLEEP = 2
10
-
11
- def generate
12
- configuration = empty_configuration
13
-
14
- default_configuration = configuration["default"]
15
-
16
- default_configuration["questions"] = all_questions
17
- default_configuration["tasks"] = all_tasks
18
-
19
- configuration
20
- end
21
-
22
- private
23
-
24
- def empty_configuration
25
- {
26
- "default" => {
27
- "questions" => {},
28
- "tasks" => {}
29
- }
30
- }
31
- end
32
-
33
- def all_questions
34
- all_primitives(Screengem::Question)
35
- end
36
-
37
- def all_tasks
38
- all_primitives(Screengem::Task)
39
- end
40
-
41
- def all_primitives(primitive_root)
42
- sorted_descendents(primitive_root).each_with_object({}) do |primitive_class, memo|
43
- next unless apply_dampening?(primitive_class)
44
-
45
- memo[primitive_key(primitive_class.name)] = DEFAULT_SLEEP
46
- end
47
- end
48
-
49
- def sorted_descendents(primitive_root)
50
- primitive_root.descendants.sort_by { |primitive_class| primitive_key(primitive_class.name) }
51
- end
52
-
53
- def apply_dampening?(primitive_class)
54
- primitive_class.supports_dampening? && primitive_class.descendants.empty?
55
- end
56
- end
57
- end
@@ -1,10 +0,0 @@
1
- module Screengem
2
- #
3
- # Mixin that knows how to generate the primitive key for a dampening configuration.
4
- #
5
- module PrimitiveKey
6
- def primitive_key(primitive_class_name)
7
- Screengem::DampenConfiguration.instance.dampen_configuration_key(primitive_class_name)
8
- end
9
- end
10
- end