onboardable 1.4.0 → 1.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b6bddf9e6bd140af8b288a658222c3742ce07f6b9f2585716ba28e9c24a1097
4
- data.tar.gz: '09a2c6fe377f80a33e1fbff274c9e05cfa6c907ae3661def938b961bf1afe181'
3
+ metadata.gz: 8f24682a34d8f84cf2eba4bdf9e69734bfa4788c7937d1b8b90b05456985b27b
4
+ data.tar.gz: c18c2ec8f27809b239c7ca8059522923bc511b3aebafaf732cc611244549d463
5
5
  SHA512:
6
- metadata.gz: '0379a520c2bb0699772c500866924497fb6ab89ffacbb93d3e7b34b0fac3f614ae899d8ab5bff49a9189d6c46f3d37fe1c7e557c95c9929d2205c03530edc63c'
7
- data.tar.gz: ce3d1feaca082deedc5dbf4d20fb56663ec403d3614e35e35c1ebb21b237864bde9599da46e8ff0e16a7d03164253fea878c9f736afc0631bba982a706b25200
6
+ metadata.gz: e443300f42828683e075ec62377ff4d3d43663c8c4e8609f9f17baf89b06b71c84fdda673939fa4fd86f487f192b7c6d65028b389cd790f3c196f6d8ad62e0a8
7
+ data.tar.gz: b8f14acd58e53891ef6de0f0c0b65181a354904ff27fd77940072641c680980ba99539012b12add6ae4395f42087416ed9f174b04168c12df6a0483414fd4f22
data/CHANGELOG.md CHANGED
@@ -1,65 +1,72 @@
1
1
  # CHANGELOG
2
2
 
3
- ## [Unreleased]
3
+ ## 1.6.0
4
4
 
5
- ## [1.4.0] - 2025-04-01
5
+ - Add support for Ruby 4.0.
6
+
7
+ ## 1.5.0
8
+
9
+ - Drop support for Ruby 3.1.
10
+ - Update development dependencies to their latest versions.
11
+
12
+ ## 1.4.0
6
13
 
7
14
  - Add support for Ruby 3.4.
8
15
  - Drop support for Ruby 3.0.
9
16
 
10
- ## [1.3.3] - 2024-08-16
17
+ ## 1.3.3
11
18
 
12
19
  - Updated rbs files to improve type-checking.
13
20
  - Added github-actions package ecosystem to the development workflow.
14
21
 
15
- ## [1.3.2] - 2024-07-10
22
+ ## 1.3.2
16
23
 
17
24
  - Added adjustments to rbs files to improve type-checking.
18
25
 
19
- ## [1.3.1] - 2024-06-10
26
+ ## 1.3.1
20
27
 
21
28
  - Fixed the issue with the custom formula calculation.
22
29
 
23
- ## [1.3.0] - 2024-06-10
30
+ ## 1.3.0
24
31
 
25
- - Added option to calculate onboarding progress using a custom formula.
32
+ - Added an option to calculate onboarding progress using a custom formula.
26
33
 
27
- ## [1.2.2] - 2024-06-03
34
+ ## 1.2.2
28
35
 
29
36
  - Fixed the issue with the default `#current_step` method.
30
37
 
31
- ## [1.2.1] - 2024-06-01
38
+ ## 1.2.1
32
39
 
33
40
  - Added trusted publisher
34
41
 
35
- ## [1.2.0] - 2024-05-25
42
+ ## 1.2.0
36
43
 
37
44
  - Added `#second_step?` method to check if the target step is the second step.
38
45
  - Added `#prev_step?` method to check if the target step is the previous step.
39
46
  - Added `#current_step?` method to check if the target step is the current step.
40
47
 
41
- ## [1.1.1] - 2024-05-21
48
+ ## 1.1.1
42
49
 
43
50
  - Added `onboarding` class method to define the onboarding steps.
44
51
  - Added [documentation link](https://rubydoc.info/gems/onboardable) to gemspec.
45
52
 
46
- ## [1.1.0] - 2024-05-21
53
+ ## 1.1.0
47
54
 
48
55
  - Introduced `step_from` method for adding steps from external sources.
49
56
  - Added warn_about_override method to alert on step overrides.
50
57
  - Added YARD documentation to the project for improved code documentation.
51
58
 
52
- ## [1.0.1] - 2024-05-09
59
+ ## 1.0.1
53
60
 
54
61
  - Added `first_step` and `last_step` methods to easily access
55
62
  the boundaries of step lists.
56
63
  - Added `progress` method for calculating onboarding completion percentage.
57
64
 
58
- ## [1.0.0] - 2024-05-08
65
+ ## 1.0.0
59
66
 
60
67
  - Enhanced `first_step?` and `last_step?` methods to accept an optional argument,
61
68
  improving flexibility by allowing checks against any specified step.
62
69
 
63
- ## [0.1.0] - 2024-05-07
70
+ ## 0.1.0
64
71
 
65
72
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,40 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- onboardable (1.4.0)
4
+ onboardable (1.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.3)
10
- diff-lcs (1.6.1)
10
+ diff-lcs (1.6.2)
11
11
  docile (1.4.1)
12
- json (2.10.2)
13
- language_server-protocol (3.17.0.4)
12
+ json (2.18.0)
13
+ language_server-protocol (3.17.0.5)
14
14
  lint_roller (1.1.0)
15
- parallel (1.26.3)
16
- parser (3.3.7.4)
15
+ parallel (1.27.0)
16
+ parser (3.3.10.0)
17
17
  ast (~> 2.4.1)
18
18
  racc
19
- prism (1.4.0)
19
+ prism (1.7.0)
20
20
  racc (1.8.1)
21
21
  rainbow (3.1.1)
22
- rake (13.2.1)
23
- regexp_parser (2.10.0)
24
- rspec (3.13.0)
22
+ rake (13.3.1)
23
+ regexp_parser (2.11.3)
24
+ rspec (3.13.2)
25
25
  rspec-core (~> 3.13.0)
26
26
  rspec-expectations (~> 3.13.0)
27
27
  rspec-mocks (~> 3.13.0)
28
- rspec-core (3.13.3)
28
+ rspec-core (3.13.6)
29
29
  rspec-support (~> 3.13.0)
30
- rspec-expectations (3.13.3)
30
+ rspec-expectations (3.13.5)
31
31
  diff-lcs (>= 1.2.0, < 2.0)
32
32
  rspec-support (~> 3.13.0)
33
- rspec-mocks (3.13.2)
33
+ rspec-mocks (3.13.6)
34
34
  diff-lcs (>= 1.2.0, < 2.0)
35
35
  rspec-support (~> 3.13.0)
36
- rspec-support (3.13.2)
37
- rubocop (1.75.1)
36
+ rspec-support (3.13.6)
37
+ rubocop (1.82.1)
38
38
  json (~> 2.3)
39
39
  language_server-protocol (~> 3.17.0.2)
40
40
  lint_roller (~> 1.1.0)
@@ -42,22 +42,22 @@ GEM
42
42
  parser (>= 3.3.0.2)
43
43
  rainbow (>= 2.2.2, < 4.0)
44
44
  regexp_parser (>= 2.9.3, < 3.0)
45
- rubocop-ast (>= 1.43.0, < 2.0)
45
+ rubocop-ast (>= 1.48.0, < 2.0)
46
46
  ruby-progressbar (~> 1.7)
47
47
  unicode-display_width (>= 2.4.0, < 4.0)
48
- rubocop-ast (1.43.0)
48
+ rubocop-ast (1.48.0)
49
49
  parser (>= 3.3.7.2)
50
50
  prism (~> 1.4)
51
- rubocop-performance (1.25.0)
51
+ rubocop-performance (1.26.1)
52
52
  lint_roller (~> 1.1)
53
53
  rubocop (>= 1.75.0, < 2.0)
54
- rubocop-ast (>= 1.38.0, < 2.0)
54
+ rubocop-ast (>= 1.47.1, < 2.0)
55
55
  rubocop-rake (0.7.1)
56
56
  lint_roller (~> 1.1)
57
57
  rubocop (>= 1.72.1)
58
- rubocop-rspec (3.5.0)
58
+ rubocop-rspec (3.8.0)
59
59
  lint_roller (~> 1.1)
60
- rubocop (~> 1.72, >= 1.72.1)
60
+ rubocop (~> 1.81)
61
61
  ruby-progressbar (1.13.0)
62
62
  simplecov (0.22.0)
63
63
  docile (~> 1.1)
@@ -65,12 +65,17 @@ GEM
65
65
  simplecov_json_formatter (~> 0.1)
66
66
  simplecov-html (0.13.1)
67
67
  simplecov_json_formatter (0.1.4)
68
- unicode-display_width (3.1.4)
69
- unicode-emoji (~> 4.0, >= 4.0.4)
70
- unicode-emoji (4.0.4)
68
+ unicode-display_width (3.2.0)
69
+ unicode-emoji (~> 4.1)
70
+ unicode-emoji (4.2.0)
71
+ yard (0.9.38)
72
+ yard-lint (1.3.0)
73
+ yard (~> 0.9)
74
+ zeitwerk (~> 2.6)
75
+ zeitwerk (2.7.4)
71
76
 
72
77
  PLATFORMS
73
- x86_64-darwin-23
78
+ x86_64-darwin-25
74
79
  x86_64-linux
75
80
 
76
81
  DEPENDENCIES
@@ -82,6 +87,7 @@ DEPENDENCIES
82
87
  rubocop-rake (~> 0.7.1)
83
88
  rubocop-rspec (~> 3.0, >= 3.0.4)
84
89
  simplecov (~> 0.22.0)
90
+ yard-lint (~> 1.2, >= 1.2.3)
85
91
 
86
92
  BUNDLED WITH
87
- 2.6.6
93
+ 4.0.3
data/README.md CHANGED
@@ -65,7 +65,7 @@ could be included in the documentation. This guide covers initialization,
65
65
  navigation, step verification, and completion of the onboarding process.
66
66
 
67
67
  After defining and accessing the onboarding steps as described
68
- earlier, managed the onboarding process through various controls
68
+ earlier, manage the onboarding process through various controls
69
69
  that allow step navigation and state verification:
70
70
 
71
71
  1. **Initialize Onboarding Process**
@@ -91,16 +91,16 @@ that allow step navigation and state verification:
91
91
  onboarding = builder.build
92
92
  ```
93
93
 
94
- 1. **Check the order of steps**
94
+ 2. **Check the order of steps**
95
95
 
96
96
  Determine the order of steps in the onboarding process to ensure
97
97
  that the sequence is correct and that the steps are defined as expected.
98
98
 
99
99
  ```ruby
100
- onboarding.steps # Returns the list of steps
100
+ onboarding.steps
101
101
  ```
102
102
 
103
- 1. **Navigating Through Steps**
103
+ 3. **Navigating Through Steps**
104
104
 
105
105
  Navigate through the onboarding steps using the navigation methods provided.
106
106
  These methods help in moving forward and backward through the onboarding process.
@@ -111,8 +111,8 @@ that allow step navigation and state verification:
111
111
  what's next or advance to it, updating the current step status.
112
112
 
113
113
  ```ruby
114
- onboarding.next_step # Preview the next step
115
- onboarding.next_step! # Advance to the next step
114
+ onboarding.next_step
115
+ onboarding.next_step!
116
116
  ```
117
117
 
118
118
  - **Previous Step**
@@ -121,32 +121,32 @@ that allow step navigation and state verification:
121
121
  making changes or updates to revert to the previous step.
122
122
 
123
123
  ```ruby
124
- onboarding.prev_step # Preview the previous step
125
- onboarding.prev_step! # Move back to the previous step
124
+ onboarding.prev_step
125
+ onboarding.prev_step!
126
126
  ```
127
127
 
128
- 1. **Check Step Position**
128
+ 4. **Check Step Position**
129
129
 
130
130
  Determine whether the current step is the first or the last in the sequence
131
131
  to manage UI elements like 'Next' or 'Back' buttons appropriately.
132
132
 
133
133
  ```ruby
134
- step = onboarding.steps.sample # Random step from the list
134
+ step = onboarding.steps.sample
135
135
 
136
- onboarding.first_step?(step) # Is the first step?
137
- onboarding.last_step?(step) # Is the last step?
138
- onboarding.current_step?(step) # Is the current step?
139
- onboarding.second_step?(step) # Is the second step?
140
- onboarding.prev_step?(step) # Is the previous step?
136
+ onboarding.first_step?(step)
137
+ onboarding.last_step?(step)
138
+ onboarding.current_step?(step)
139
+ onboarding.second_step?(step)
140
+ onboarding.prev_step?(step)
141
141
  ```
142
142
 
143
- 1. **Monitor Progress**
143
+ 5. **Monitor Progress**
144
144
 
145
145
  - Calculate the progress or completion percentage of the onboarding process
146
146
  to provide users with an indication of how far they have progressed.
147
147
 
148
148
  ```ruby
149
- onboarding.progress # Returns the completion percentage
149
+ onboarding.progress
150
150
  ```
151
151
 
152
152
  - To customize the progress calculation formula, define a lambda function
@@ -172,20 +172,20 @@ that allow step navigation and state verification:
172
172
  end
173
173
  ```
174
174
 
175
- 1. **Access Current Step Details**
175
+ 6. **Access Current Step Details**
176
176
 
177
177
  Retrieve details about the current step, which can include the name,
178
178
  custom data, and status, to display appropriate information or help
179
- the user completes tasks associated with the step.
179
+ the user understand their current position in the onboarding process.
180
180
 
181
181
  ```ruby
182
- onboarding.current_step # Current step details
183
- onboarding.current_step.name # Step name
184
- onboarding.current_step.data # Step custom data
185
- onboarding.current_step.status # Step status
182
+ onboarding.current_step
183
+ onboarding.current_step.name
184
+ onboarding.current_step.data
185
+ onboarding.current_step.status
186
186
  ```
187
187
 
188
- 1. **Complete the Onboarding Process**
188
+ 7. **Complete the Onboarding Process**
189
189
 
190
190
  Once the user reaches the last step and completes it, finalize the
191
191
  onboarding process, which might involve setting a user attribute to
@@ -200,12 +200,12 @@ that allow step navigation and state verification:
200
200
  # Exception Handling Approach
201
201
  begin
202
202
  onboarding.next_step!
203
- rescue LastStepError
203
+ rescue Onboardable::LastStepError
204
204
  # Implement finalization processes like updating user attributes
205
205
  end
206
206
  ```
207
207
 
208
- 1. **Exit the Onboarding Process Early**
208
+ 8. **Exit the Onboarding Process Early**
209
209
 
210
210
  Handle cases where a user decides to discontinue the onboarding
211
211
  by attempting to navigate back from the initial step.
@@ -219,7 +219,7 @@ that allow step navigation and state verification:
219
219
  # Exception Handling Approach
220
220
  begin
221
221
  onboarding.prev_step!
222
- rescue FirstStepError
222
+ rescue Onboardable::FirstStepError
223
223
  # Implement cleanup or final actions for an orderly exit
224
224
  end
225
225
  ```
@@ -230,13 +230,13 @@ user-friendly onboarding process using the Onboardable gem.
230
230
  ## 🛠 Development
231
231
 
232
232
  1. After checking out the repo, run `bin/setup` to install dependencies.
233
- 1. Then, run `rake spec` to run the tests.
234
- 1. Also run `bin/console` for an interactive prompt that will allow you to experiment.
235
- 1. To install this gem onto your local machine, run `bundle exec rake install`.
236
- 1. To release a new version, update the version number in `version.rb`.
237
- 1. After, run `bundle exec rake release`, which will create a git tag for the version.
238
- 1. Push git commits and the created tag.
239
- 1. Then push the `.gem` file to [rubygems.org](https://rubygems.org).
233
+ 2. Then, run `rake spec` to run the tests.
234
+ 3. Also run `bin/console` for an interactive prompt that will allow you to experiment.
235
+ 4. To install this gem onto your local machine, run `bundle exec rake install`.
236
+ 5. To release a new version, update the version number in `version.rb`.
237
+ 6. After, run `bundle exec rake release`, which will create a git tag for the version.
238
+ 7. Push git commits and the created tag.
239
+ 8. Then push the `.gem` file to [rubygems.org](https://rubygems.org).
240
240
 
241
241
  ## 🤝 Contributing
242
242
 
@@ -250,5 +250,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
250
250
 
251
251
  ## 📜 Code of Conduct
252
252
 
253
- Everyone interacting in the Onboardable project's codebases, issue trackers,
254
- chat rooms and mailing lists are expected to follow the [code of conduct](https://github.com/dmrAnderson/onboardable/blob/main/CODE_OF_CONDUCT.md).
253
+ Everyone interacting with the Onboardable project's codebases, issue trackers,
254
+ chat rooms, and mailing lists are expected to follow the [code of conduct](https://github.com/dmrAnderson/onboardable/blob/main/CODE_OF_CONDUCT.md).
@@ -20,7 +20,7 @@ module Onboardable
20
20
  # Initializes a new instance of StepConversionError.
21
21
  #
22
22
  # @param klass [Class] The class that failed to convert.
23
- # @param step [unknown] The object that was attempted to be converted to a Step.
23
+ # @param step [Object] The object that was attempted to be converted to a Step.
24
24
  def initialize(klass, step)
25
25
  super("Can't convert #{klass} to Step (#{klass}#to_onboarding_step gives #{step.class}).")
26
26
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onboardable
4
+ # The List module encapsulates functionality for managing a sequence of onboarding steps.
4
5
  module List
5
6
  # The List class manages a sequence of steps in an onboarding process, tracking progress and current state.
6
7
  class Base
7
8
  include Navigation
8
9
 
10
+ # Default calculation for onboarding progress as a percentage.
9
11
  PROGRESS_CALCULATION = ->(step_index, steps_size) { (step_index.to_f / steps_size) * 100 }
10
12
 
11
13
  # @return [Array<Step>] The steps in the list.
@@ -14,11 +16,13 @@ module Onboardable
14
16
  # @return [Step] The current step in the list.
15
17
  attr_reader :current_step
16
18
 
17
- # Initializes a new instance of List with steps and a current step.
19
+ # Initializes a new instance of the List with steps and a current step.
18
20
  #
19
21
  # @param steps [Array<Step>] An array of steps comprising the onboarding process.
20
22
  # @param current_step [Step] The step currently active in the process.
21
- # @param options [Hash] An options hash for the list.
23
+ # @param options [Hash] Optional parameters for configuring the list.
24
+ # @option options [Proc] :progress_calculation A custom calculation for progress percentage.
25
+ # Receives step_index and steps_size as arguments and returns a Float.
22
26
  def initialize(steps, current_step, options = {})
23
27
  self.steps = steps
24
28
  self.current_step = current_step
@@ -39,7 +43,7 @@ module Onboardable
39
43
  # @return [Hash] The options hash for the list.
40
44
  attr_reader :options
41
45
 
42
- # Sets and validates the steps array, ensuring it is an Array of Step objects.
46
+ # Sets and validates an array of steps.
43
47
  #
44
48
  # @param steps [Array<Step>] The steps to be assigned to the list.
45
49
  # @return [Array<Step>] The assigned steps.
@@ -58,9 +62,11 @@ module Onboardable
58
62
  end
59
63
  end
60
64
 
61
- # Sets and validates the options hash, ensuring it is a Hash object.
65
+ # Sets and validates options for the list.
62
66
  #
63
67
  # @param options [Hash] The options to be assigned to the list.
68
+ # @option options [Proc] :progress_calculation A custom calculation for progress percentage.
69
+ # Receives step_index and steps_size as arguments and returns a Float.
64
70
  # @return [Hash] The assigned options.
65
71
  def options=(options)
66
72
  @options = Hash(options).transform_keys(&:to_sym).freeze
@@ -6,6 +6,7 @@ module Onboardable
6
6
  class Builder
7
7
  include Utils::Warnings
8
8
 
9
+ # Key used to store steps in the options hash.
9
10
  STEP_KEY = :steps
10
11
 
11
12
  # Stores the steps added to the builder.
@@ -19,6 +20,10 @@ module Onboardable
19
20
  attr_accessor :current_step
20
21
 
21
22
  # Initializes a new instance of ListBuilder.
23
+ #
24
+ # @param options [Hash] Options to be set for the builder.
25
+ # @option options [Proc] :progress_calculation A custom calculation for progress percentage.
26
+ # Receives step_index and steps_size as arguments and returns a Float.
22
27
  def initialize(options = {})
23
28
  self.options = options
24
29
  end
@@ -59,9 +64,11 @@ module Onboardable
59
64
  # @return [Hash] The options hash for the builder.
60
65
  attr_reader :options
61
66
 
62
- # Sets the options hash for the builder.
67
+ # Sets options hash for the builder.
63
68
  #
64
- # @param options [Hash] The options hash to be set.
69
+ # @param options [Hash] Options to be set for the builder.
70
+ # @option options [Proc] :progress_calculation A custom calculation for progress percentage.
71
+ # Receives step_index and steps_size as arguments and returns a Float.
65
72
  def options=(options)
66
73
  @options = Hash(options).except(STEP_KEY)
67
74
  end
@@ -91,7 +98,7 @@ module Onboardable
91
98
  #
92
99
  # @param name [String] The name of the step to be converted to a Step object.
93
100
  # @return [Step] The corresponding Step object.
94
- # @raise [StepError] Raises if the specified step name is not present in the steps hash.
101
+ # @raise [StepError] Raises if the specified step name is not present in steps hash.
95
102
  def convert_to_step!(name)
96
103
  steps[name] || raise(StepError.new(name, steps.keys))
97
104
  end
@@ -3,21 +3,27 @@
3
3
  module Onboardable
4
4
  # Represents a single step within an onboarding process, including its status and associated data.
5
5
  class Step
6
+ # Method name used for converting a class to a Step object.
6
7
  CONVERSION_METHOD = :to_onboarding_step
7
8
 
9
+ # The step is pending and has not yet been started.
8
10
  PENDING_STATUS = :pending
11
+ # The step is currently in progress.
9
12
  CURRENT_STATUS = :current
13
+ # The step has been completed.
10
14
  COMPLETED_STATUS = :completed
11
15
 
16
+ # The default status for a new step.
12
17
  DEFAULT_STATUS = PENDING_STATUS
13
18
 
19
+ # All valid statuses for a step.
14
20
  STATUSES = [PENDING_STATUS, CURRENT_STATUS, COMPLETED_STATUS].freeze
15
21
 
16
22
  class << self
17
23
  # Attempts to convert a class to a Step object using a specified conversion method.
18
24
  #
19
- # @param klass [Class] The class to convert to a Step
20
- # @return [Step, nil] The converted Step object, or nil if the class does not respond to the conversion method
25
+ # @param klass [Class] The class to convert to a Step.
26
+ # @return [Step, nil] The converted Step object, or nil if the class does not respond to the conversion method.
21
27
  def try_convert(klass)
22
28
  return unless klass.respond_to?(CONVERSION_METHOD)
23
29
 
@@ -30,26 +36,27 @@ module Onboardable
30
36
 
31
37
  # Raises an error for a failed conversion attempt.
32
38
  #
33
- # @param klass [Class] The class that failed to convert
34
- # @raise [StepConversionError] Raises an error for a failed conversion attempt
39
+ # @param klass [Class] The class that failed to convert.
40
+ # @param step [Object] The invalid object returned from the conversion method.
41
+ # @raise [StepConversionError] Raises an error for a failed conversion attempt.
35
42
  def conversion_error!(klass, step)
36
43
  raise StepConversionError.new(klass, step)
37
44
  end
38
45
  end
39
46
 
40
- # @return [String] The name of the step
47
+ # @return [String] The name of the step.
41
48
  attr_reader :name
42
49
 
43
- # @return [Hash] Custom data associated with the step
50
+ # @return [Hash] Custom data associated with the step.
44
51
  attr_reader :data
45
52
 
46
- # @return [Symbol] The current status of the step
53
+ # @return [Symbol] The current status of the step.
47
54
  attr_reader :status
48
55
 
49
56
  # Initializes a new Step with a name, optional custom data, and a default status.
50
57
  #
51
- # @param name [String] The name of the step
52
- # @param data [Hash] The custom data associated with the step, defaults to an empty hash
58
+ # @param name [String] The name of the step.
59
+ # @param data [Hash] The custom data associated with the step.
53
60
  def initialize(name, data = {})
54
61
  self.name = name
55
62
  self.data = data
@@ -79,43 +86,44 @@ module Onboardable
79
86
 
80
87
  # Compares this step to another to determine if they are equivalent, based on the step name.
81
88
  #
82
- # @param other [Step] The step to compare with
83
- # @return [Boolean] True if both steps have the same name, false otherwise
89
+ # @param other [Step] The step to compare with.
90
+ # @return [Boolean] True if both steps have the same name, false otherwise.
84
91
  def ==(other)
85
92
  to_str == other.to_str
86
93
  end
87
94
 
88
95
  # Provides a string representation of the step, using its name.
89
96
  #
90
- # @return [String] The name of the step
97
+ # @return [String] The name of the step.
91
98
  def to_str
92
99
  name
93
100
  end
94
101
 
95
102
  # Updates the status of the step based on a specified comparison result.
96
103
  #
97
- # @param comparison_result [Integer] The result of a comparison with the current step (-1, 0, or 1)
98
- # @return [Symbol] The new status of the step
104
+ # @param comparison_result [Integer] The result of a comparison operation.
105
+ # @return [Symbol] The new status of the step.
99
106
  def update_status!(comparison_result)
100
107
  self.status = case comparison_result
101
108
  when -1 then COMPLETED_STATUS
102
109
  when 0 then CURRENT_STATUS
103
110
  when 1 then PENDING_STATUS
104
- else comparison_result_error!(comparison_result); end
111
+ else comparison_result_error!(comparison_result)
112
+ end
105
113
  end
106
114
 
107
115
  private
108
116
 
109
117
  # Sets the name of the step, ensuring it is a valid String.
110
118
  #
111
- # @param name [String] The raw name of the step
119
+ # @param name [String] The raw name of the step.
112
120
  def name=(name)
113
121
  @name = String.new(name).freeze
114
122
  end
115
123
 
116
124
  # Sets the status of the step.
117
125
  #
118
- # @param status [Symbol] The new status of the step
126
+ # @param status [Symbol] The new status of the step.
119
127
  def status=(status)
120
128
  STATUSES.include?(status) || raise(StepStatusError.new(status, STATUSES))
121
129
 
@@ -124,15 +132,15 @@ module Onboardable
124
132
 
125
133
  # Sets the custom data for the step, ensuring it is a valid Hash.
126
134
  #
127
- # @param data [Hash] The raw custom data
135
+ # @param data [Hash] The raw custom data.
128
136
  def data=(data)
129
137
  @data = Hash(data).freeze
130
138
  end
131
139
 
132
140
  # Raises an error for an invalid comparison result.
133
141
  #
134
- # @param comparison_result [Integer] The invalid comparison result
135
- # @raise [ComparisonResultError] Raises an error for an invalid comparison result
142
+ # @param comparison_result [Integer] The invalid comparison result.
143
+ # @raise [ComparisonResultError] Raises an error for an invalid comparison result.
136
144
  def comparison_result_error!(comparison_result)
137
145
  raise ComparisonResultError.new(comparison_result, (-1..1).to_a)
138
146
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onboardable
4
+ # The Utils module contains utility classes and modules for the Onboardable namespace.
4
5
  module Utils
5
6
  # The Warnings module provides utility methods for issuing warnings.
6
7
  module Warnings
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onboardable
4
- VERSION = '1.4.0'
4
+ # The version of the Onboardable gem.
5
+ VERSION = '1.6.0'
5
6
  end
data/lib/onboardable.rb CHANGED
@@ -13,7 +13,7 @@ module Onboardable
13
13
  # Initializes the Onboardable module when included in a class, extending it with class and instance methods.
14
14
  #
15
15
  # @param klass [Module] The class including the Onboardable module
16
- # @return [untyped] The class including the Onboardable module.
16
+ # @return [void]
17
17
  def self.included(klass)
18
18
  klass.extend ClassMethods
19
19
  klass.include InstanceMethods
@@ -27,6 +27,8 @@ module Onboardable
27
27
  # Configures onboarding steps via a ListBuilder with a provided block.
28
28
  #
29
29
  # @param options [Hash] Optional configuration options for the ListBuilder.
30
+ # @option options [Proc] :progress_calculation A custom calculation for progress percentage.
31
+ # Receives step_index and steps_size as arguments and returns a Float.
30
32
  # @yield [List::Builder] Executes block in the context of List::Builder.
31
33
  # @return [Step] The current step in the building process.
32
34
  def onboarding=(options = {}, &)
data/onboardable.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Provides tools for easy setup of custom onboarding to boost engagement.'
13
13
  spec.homepage = 'https://github.com/dmrAnderson/onboardable'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 3.1.0'
15
+ spec.required_ruby_version = '>= 3.2.0'
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
18
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
27
  spec.files = Dir.chdir(__dir__) do
28
28
  `git ls-files -z`.split("\x0").reject do |f|
29
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|spec)/|\.(?:git|rspec|rubocop))})
29
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|spec)/|\.(?:git|rspec|rubocop|yard))})
30
30
  end
31
31
  end
32
32
 
@@ -46,6 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'rubocop-rake', '~> 0.7.1'
47
47
  spec.add_development_dependency 'rubocop-rspec', '~> 3.0', '>= 3.0.4'
48
48
  spec.add_development_dependency 'simplecov', '~> 0.22.0'
49
+ spec.add_development_dependency 'yard-lint', '~> 1.2', '>= 1.2.3'
49
50
 
50
51
  spec.metadata['rubygems_mfa_required'] = 'true'
51
52
  end
@@ -7,7 +7,7 @@ module Onboardable
7
7
  end
8
8
 
9
9
  class StepConversionError < Error
10
- def initialize: (Class klass, untyped step) -> untyped
10
+ def initialize: (Class klass, Object step) -> untyped
11
11
  end
12
12
 
13
13
  class EmptyStepsError < Error
data/sig/onboardable.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  module Onboardable
2
2
  VERSION: String
3
3
 
4
- def self.included: (Class klass) -> untyped
4
+ def self.included: (Module klass) -> void
5
5
 
6
6
  module ClassMethods
7
7
  attr_accessor list_builder: List::Builder
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onboardable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Skrynnyk
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -131,6 +131,26 @@ dependencies:
131
131
  - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: 0.22.0
134
+ - !ruby/object:Gem::Dependency
135
+ name: yard-lint
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '1.2'
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 1.2.3
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '1.2'
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: 1.2.3
134
154
  description: Provides tools for easy setup of custom onboarding to boost engagement.
135
155
  email:
136
156
  - skrynnyk.artem@coaxsoft.com
@@ -177,14 +197,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
197
  requirements:
178
198
  - - ">="
179
199
  - !ruby/object:Gem::Version
180
- version: 3.1.0
200
+ version: 3.2.0
181
201
  required_rubygems_version: !ruby/object:Gem::Requirement
182
202
  requirements:
183
203
  - - ">="
184
204
  - !ruby/object:Gem::Version
185
205
  version: '0'
186
206
  requirements: []
187
- rubygems_version: 3.6.2
207
+ rubygems_version: 4.0.3
188
208
  specification_version: 4
189
209
  summary: Streamlines onboarding process integration
190
210
  test_files: []