onboardable 0.1.0 → 1.0.1

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: 2f8dab433ffdae729d520f952885f1023821f8174bfcf761d7e8b81ed4970e2f
4
- data.tar.gz: a2abc67ae9936358c9742bd5e3c39a98f4a97e134d12ca7ece4773a235296763
3
+ metadata.gz: 9cc331c83492d5c21563a91644b3f2441b38d561ebde4d0690ba68813fadeb60
4
+ data.tar.gz: 1e55f9c4913a17385c6e2ebe4c7d1dd58921a35b72d786171aa8a28efae09306
5
5
  SHA512:
6
- metadata.gz: 8f1ec81d701796ba14700f104ba424d73d27dc6dca04b172dad575d3b9b4fb925997caf6491f95400aedb7d7b8d0d8e00ed5b4c24206c88ff72808e22462f625
7
- data.tar.gz: 7518e5c2d5713bc2ce3db3c5f50d136c92c328b9eeccc045e9c59c60dbfab4b0d240cbc107e1ddbc0779ca6e36aa64108e7b0eaff17afb975d2f5877fbc03dcd
6
+ metadata.gz: '0456826a6d0b6bea084f95191240ea28776be3b4d8106a2f8055b259d24524055248143e01050be87e6c512084e9ddf7c576c594327ae9b617eb1db5e7068973'
7
+ data.tar.gz: 2e35337681b26a2c09fa7ba1e7e8b5c505747a5c0144f3116214241c06aca3b04d76b72ce439d14ca717090caa01e95f7f219543784dcdbc07b354b66984686f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
- ## [0.1.0] - 2024-03-2
5
+ - Added `first_step` and `last_step` methods to easily access
6
+ the boundaries of step lists.
7
+ - Added `progress` method for calculating onboarding completion percentage.
8
+
9
+ ## [1.0.0] - 2024-05-08
10
+
11
+ - Enhanced `first_step?` and `last_step?` methods to accept an optional argument,
12
+ improving flexibility by allowing checks against any specified step.
13
+
14
+ ## [0.1.0] - 2024-05-07
6
15
 
7
16
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- onboardable (0.1.0)
4
+ onboardable (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -29,7 +29,7 @@ GEM
29
29
  rspec-expectations (3.13.0)
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
31
  rspec-support (~> 3.13.0)
32
- rspec-mocks (3.13.0)
32
+ rspec-mocks (3.13.1)
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
34
  rspec-support (~> 3.13.0)
35
35
  rspec-support (3.13.1)
data/README.md CHANGED
@@ -78,14 +78,15 @@ that allow step navigation and state verification:
78
78
  This sets up the initial step based on the defined onboarding flow.
79
79
 
80
80
  ```ruby
81
- User.new.onboarding
81
+ onboarding = User.new.onboarding
82
82
  # Initializes the onboarding process for a new user instance
83
83
  ```
84
84
 
85
85
  1. **Navigating Through Steps**
86
86
 
87
87
  Navigate through the onboarding steps using the navigation methods provided.
88
- These methods help in moving forward and backward through the onboarding process
88
+ These methods help in moving forward and backward through the onboarding process.
89
+
89
90
  - **Next Step**
90
91
 
91
92
  Access the next step without changing the current step to preview
@@ -125,6 +126,16 @@ that allow step navigation and state verification:
125
126
  # Returns true if the current step is the last
126
127
  ```
127
128
 
129
+ 1. **Monitor Progress**
130
+
131
+ Calculate the progress or completion percentage of the onboarding process
132
+ to provide users with an indication of how far they have progressed.
133
+
134
+ ```ruby
135
+ onboarding.progress
136
+ # Returns the percentage of onboarding completion
137
+ ```
138
+
128
139
  1. **Access Current Step Details**
129
140
 
130
141
  Retrieve details about the current step, which can include the name,
@@ -152,8 +163,35 @@ that allow step navigation and state verification:
152
163
  indicate completion or triggering other application logic.
153
164
 
154
165
  ```ruby
166
+ # Direct Check Approach
155
167
  if onboarding.last_step?
156
- # Trigger finalization processes like database updates or notifications
168
+ # Implement finalization processes like updating user attributes
169
+ end
170
+
171
+ # Exception Handling Approach
172
+ begin
173
+ onboarding.next_step!
174
+ rescue LastStepError
175
+ # Implement finalization processes like updating user attributes
176
+ end
177
+ ```
178
+
179
+ 1. **Exit the Onboarding Process Early**
180
+
181
+ Handle cases where a user decides to discontinue the onboarding
182
+ by attempting to navigate back from the initial step.
183
+
184
+ ```ruby
185
+ # Direct Check Approach
186
+ if onboarding.first_step?
187
+ # Implement cleanup or final actions for an orderly exit
188
+ end
189
+
190
+ # Exception Handling Approach
191
+ begin
192
+ onboarding.prev_step!
193
+ rescue FirstStepError
194
+ # Implement cleanup or final actions for an orderly exit
157
195
  end
158
196
  ```
159
197
 
@@ -11,6 +11,10 @@ module Onboardable
11
11
  self.current_step = current_step
12
12
  end
13
13
 
14
+ def progress
15
+ (step_index!(current_step).to_f / steps.size) * 100
16
+ end
17
+
14
18
  private
15
19
 
16
20
  def steps=(raw_steps)
@@ -23,12 +23,20 @@ module Onboardable
23
23
  self.current_step = prev_step || raise(FirstStepError.new(current_step, steps))
24
24
  end
25
25
 
26
- def first_step?
27
- current_step == steps.fetch(0)
26
+ def first_step?(step = current_step)
27
+ step == first_step
28
28
  end
29
29
 
30
- def last_step?
31
- current_step == steps.fetch(-1)
30
+ def last_step?(step = current_step)
31
+ step == last_step
32
+ end
33
+
34
+ def first_step
35
+ steps.fetch(0)
36
+ end
37
+
38
+ def last_step
39
+ steps.fetch(-1)
32
40
  end
33
41
  end
34
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onboardable
4
- VERSION = '0.1.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -5,6 +5,8 @@ module Onboardable
5
5
 
6
6
  def initialize: (Array[Step], Step) -> instance
7
7
 
8
+ def progress: -> Float
9
+
8
10
  private
9
11
 
10
12
  attr_writer steps: Array[Step]
@@ -5,8 +5,10 @@ module Onboardable
5
5
  def next_step!: () -> Step
6
6
  def prev_step: () -> Step?
7
7
  def prev_step!: () -> Step
8
- def first_step?: () -> bool
9
- def last_step?: () -> bool
8
+ def first_step?: (?Step) -> bool
9
+ def first_step: -> Step
10
+ def last_step?: (?Step) -> bool
11
+ def last_step: -> Step
10
12
  end
11
13
  end
12
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onboardable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Skrynnyk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-07 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -158,6 +158,7 @@ homepage: https://github.com/dmrAnderson/onboardable
158
158
  licenses:
159
159
  - MIT
160
160
  metadata:
161
+ homepage_uri: https://github.com/dmrAnderson/onboardable
161
162
  changelog_uri: https://github.com/dmrAnderson/onboardable/blob/main/CHANGELOG.md
162
163
  bug_tracker_uri: https://github.com/dmrAnderson/onboardable/issues
163
164
  documentation_uri: https://github.com/dmrAnderson/onboardable/blob/main/README.md