mobiusloop 0.1.2 → 0.1.3

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: 1f8aeb0ff8c00b5bc92a1746d916eefbff900728
4
- data.tar.gz: 7f93d1d2a066f66a5ca4b2db2086c17d53956a2c
3
+ metadata.gz: 0e6bd4113018108ce0d474e02243c13e5e8701f9
4
+ data.tar.gz: ccda4bfa5a8026be4c646f884cf5aaaf8b8275d0
5
5
  SHA512:
6
- metadata.gz: 5b9a4dffb7ecdba4d028869f7f9fc5586037bc543c52b57eda4c5b70ed318824c88226ea46f27743f12a80f8a8907c3917b4471c72105cec78a9dd5e3d8ae036
7
- data.tar.gz: b124626976da7218379aef1c4f04f8deb5828aa2410245a9802920008cb16da06ddac145f1166277cbcc23b78a18352d0cafa814ec712e11f882e58734cc01cf
6
+ metadata.gz: 8fc115d1b44f03d233997ee9dde71744b75ae8377bbf6e6b5d9d1ab1abf22d3f275fc0f76cd523783b1c8a51d0fa1212c37d23ccc3ce71e78322d1dc6896eaf7
7
+ data.tar.gz: 8b20b671d419e975385d6e7ea87bf98fad1475c16648be055cd3f0f85d00778240617f5fc105fe6731114fb48e6830992d5a342d821bcfbbbb3de3af61e1f2d9
data/README.md CHANGED
@@ -130,23 +130,17 @@ end
130
130
  ## getting started
131
131
 
132
132
  Adding `mobiusloop` to your product is easy, but requires some command-line chops.
133
- If this section looks like Greek, then as nicely as possible ask a developer on your team to help.
133
+ If this section looks like Greek, then as nicely as possible ask a developer on your team for help.
134
134
 
135
- **Note:** Currently only Linux and OSX are supported platforms. Windows will be added in the future.
136
-
137
- **TODO:** Simplify the installation steps to `gem install mobiusloop`. For now download the source and build a .gem locally.
138
-
139
- Download the [source code](https://github.com/ryanshriver/mobiusloop-ruby) into a working directory (e.g. /workspace/mobiusloop-ruby)
135
+ **Note:** Currently only Ruby on Linux and OSX are tested platforms. Windows will be added in the future.
140
136
 
141
137
  If [Ruby](https://www.ruby-lang.org/en/), [gem](https://rubygems.org) and [bundle](http://bundler.io) are not installed, install them first.
142
- Then from the working directory, run these commands:
143
138
 
144
- $ gem build mobiusloop.gemspec
145
- $ gem install mobiusloop-0.1.1.gem
139
+ Then install `mobiusloop` with this command:
146
140
 
147
- Replace `mobiusloop-0.1.1.gem` with whatever version was built.
141
+ $ gem install mobiusloop
148
142
 
149
- Finally, create a symbolic link for the `mobiusloop` command. First locate your ruby executable path:
143
+ Once installed, create a symbolic link for the `mobiusloop` command. First locate your ruby executable path:
150
144
 
151
145
  $ gem env
152
146
 
@@ -155,11 +149,10 @@ Then create a symbolic link:
155
149
 
156
150
  $ ln -s </path/to/executable/directory/mobiusloop /usr/local/bin/mobiusloop
157
151
 
158
- **TODO:** Find a way to create symbolic link as part of gem install
152
+ **TODO:** Find a way to create symbolic link as part of gem install to remove this manual step
159
153
 
160
154
 
161
-
162
- ## Adding `mobiusloop` to your app
155
+ ## adding mobiusloop to your app
163
156
 
164
157
  To create and run your own goals, let's start with a working example and modify it.
165
158
 
@@ -168,102 +161,68 @@ Change to the root directory of your app and run `mobiusloop`:
168
161
  $ cd product_home
169
162
  $ mobiusloop
170
163
 
171
- You will see that `mobiousloop` is not initialized. So let's do that:
164
+ You get feedback that `mobiousloop` is not initialized. So let's do that:
172
165
 
173
166
  $ mobiusloop --init
174
167
 
175
- You will see that `mobiusloop` created a `goals/` directory and put some files in there. Let's run our example:
168
+ `mobiusloop` just created a `goals/` directory and put some files in there. Let's run our example:
176
169
 
177
170
  $ mobiusloop
178
171
 
179
- If all goes well, you will see something like this:
180
-
181
- ```Ruby
182
- Objective: Get a million paying customers by Q3 2016
183
-
184
- Outcome: Increase Journal Readership to 1,000,000
185
- Given a baseline of 500000 "readers" on "Oct 1, 2015"
186
- And a target of 1000000 "readers" by "Oct 1, 2016"
187
- When we measure progress with "Total Readers Scale"
188
- Success! found 820,000 readers in 0.0 seconds!
189
- Then report progress towards targets
190
- Hooray! You are on track!
191
- 64% progress to target using 63% of the time (231 days)
192
- 36% remaining to target in 134 days
193
-
194
- Outcome: Increase Published Articles by 25%
195
- Given a baseline of 40000 "articles" on "Jan 1, 2016"
196
- And a target of 50000 "articles" by "Oct 1, 2016"
197
- When we measure progress with "Total Articles Scale"
198
- Success! found 420,00 articles in 0.0 seconds!
199
- Then report progress towards targets
200
- Sorry, you are not on track
201
- 20% progress to target using 51% of the time (139 days)
202
- 80% remaining to target in 134 days
203
-
204
- 2 scenarios (2 passed)
205
- 8 steps (8 passed)
206
- 0m0.025s
207
- ```
208
- Congrats `mobiusloop` is running for your product! Now let's customize it for your needs.
172
+ If all goes well, you get feedback that `mobiusloop` is running for your product! Now let's customize it for your needs.
209
173
 
210
174
 
211
- ## Create your first `.goal`
175
+ ## create your first .goal
212
176
 
213
- First, open `goals/increase_readers.goal` in a text editor, change the baseline or target value, save and run the example again.
214
- Did you notice changes in the progress and status? Change the baseline and target dates and try again. Get the hang of it?
177
+ First, open `goals/increase_readers.goal` in a text editor, change the baseline or target value, save and run again.
178
+ Did you notice changes in the progress and status? Change the baseline and target dates and try again. Getting the hang of it?
215
179
 
216
- Let's pretend you have a product outcome to improve response time from 4.5 seconds to 1.5 seconds for your app.
217
- We know your product would never be this slow, but let's just pretend. Start by copying our working example:
180
+ Now let's pretend you have a product outcome to **improve response time** for your product from 4.5 seconds to 1 second.
181
+ Start by copying our working example:
218
182
 
219
183
  $ cp goals/increase_readers.goal goals/improve_response_time.goal
220
184
 
221
185
 
222
- #### Create Objectives and Outcomes
186
+ #### create objectives and outcomes
223
187
 
224
188
  Open the new `improve_response_time.goal` in your text editor and make some changes:
225
189
 
226
- - Update `Objective:` to reflect our new goal. Something like <i>improve our digital customer experience</i>.
227
- - Let's only start with one `Outcome`, so delete from `Outcome: Increase Published Articles` to the end of the file
190
+ - Update `Objective:` to reflect our new goal. How about <i>Improve our digital customer experience this year</i>.
191
+ - Let's only start with one `Outcome`, so delete from `Outcome: Increase Published Articles by 25%` to the end of the file
228
192
  - Now update your `Outcome:` keeping it short and sweet. Something like <i>Improve Response Time</i>
229
193
 
230
194
  Now save the file and run again:
231
195
 
232
196
  $ mobiusloop
233
197
 
234
- Cool, now we have multiple running goals! As you add more `.goal` files to `goals/` folder, `mobiusloop` runs them.
198
+ This runs all the `.goal` files to `goals/` folder. We can just run our new one with this command:
235
199
 
236
- If you only wanted to run one `.goal`, you could do that easily:
237
-
238
- $ mobiusloop goals/increase_readers.goal
200
+ $ mobiusloop goals/improve_response_time.goal
239
201
 
240
202
  We don't need the example anymore, so let's remove it:
241
203
 
242
204
  $ rm goals/increase_readers.goal
243
205
 
244
- #### Define baselines and targets
245
-
246
- Open `improve_response_time.goal` again and let's update the baselines and targets.
247
- Let's pretend as of last October your app's home page takes 4.5 seconds to load. That's your baseline. Make a change:
248
206
 
249
- - In the row starting with `Given`, change 50000 to 4.5
207
+ #### define baselines and targets
250
208
 
251
- Your product owner has said <i>sub-second</i> is how fast it should load. That's your target. Make another change:
209
+ Open `improve_response_time.goal` again and let's update the baselines and targets.
210
+ Let's pretend as of October 1, 2015 your app's home page takes 5 seconds to load. That's your baseline. Make a change:
252
211
 
253
- - In the row starting with `And`, change 1000000 to 1
212
+ - In the row starting with `Given`, change 50000 to 5 and "readers" to "seconds"
254
213
 
255
- Finally, your unit of measure is not "readers", so let's fix that:
214
+ Your product owner has said <i>sub-second</i> is their goal. That's your target. Make another change:
256
215
 
257
- - Change "readers" to "seconds" for both target and baseline rows
216
+ - In the row starting with `And`, change 1000000 to 1 and "readers" to "second"
258
217
 
259
218
  Now save the file and run again:
260
219
 
261
220
  $ mobiusloop
262
221
 
263
- This works, but the scale says we have 820,000 seconds! That's not right, so let's fix it.
222
+ This works, but we have 820,000 seconds! That's not right, so let's fix it.
264
223
 
265
224
 
266
- #### Define scales
225
+ #### define scales
267
226
 
268
227
  Open `improve_response_time.goal` again and let's change the scale to record response times, not total readers.
269
228
 
@@ -275,15 +234,15 @@ Now save the file and run again.
275
234
 
276
235
  Wow, much better! The "Page Response Scale" requested google.com and compared the response time to your target.
277
236
 
278
- How did you do? Depending on your internet speed, hopefully you hit the target.
237
+ How did you do? Did you hit the target?
279
238
 
280
239
 
281
- ## Developing with `mobiusloop`
240
+ ## developing with mobiusloop
282
241
 
283
- Hopefully by now you're getting the hang of it. When developing with `mobiusloop` there are three basic steps:
242
+ Hopefully by now you're getting the hang of `mobiusloop`. During development there are three basic steps:
284
243
 
285
244
 
286
- #### Step 1: Create a new `.goal` file in the `goals/` directory
245
+ #### step 1: create a new .goal file in the goals/ directory
287
246
 
288
247
  You can copy an example or start from scratch. When done, do a dry run to ensure your syntax is valid:
289
248
 
@@ -292,7 +251,7 @@ You can copy an example or start from scratch. When done, do a dry run to ensure
292
251
  Replacing `your_objective.goal` with your filename. If there's any syntax problems, fix them and run again until you get a clean run.
293
252
 
294
253
 
295
- #### Step 2: Optionally create a step definition
254
+ #### step 2: optionally create a step definition
296
255
 
297
256
  `mobiusloop` ships with one step definition `goals/step_definitions/mobius_steps.rb`. If you write your objectives,
298
257
  problems, outcomes and key results in the format above there's no need to create one. However if you want to create your own
@@ -305,7 +264,7 @@ Copy and paste this into a new file `your_name_steps.rb` and save it to the `goa
305
264
  info on step definitions, see [Cucumber's reference](https://cucumber.io/docs/reference#step-definitions).
306
265
 
307
266
 
308
- #### Step 3: Create a new `Scale`
267
+ #### step 3: create a new Scale
309
268
 
310
269
  Create a new Ruby class to perform the measurement. For example, if your .`goal` file contains "My Custom Scale", the Ruby class would be:
311
270
 
@@ -322,22 +281,22 @@ class MyCustomScale < Scale
322
281
 
323
282
  end
324
283
  ```
325
- Replace the line `total = fetch_your_total` with your custom logic. The last line should be `Measure.new(total)` to return a new measure.
284
+ This code lives in `my_custom.scale.rb`.
285
+ Replace the line `total = fetch_your_total` with your custom logic.
286
+ The last line `Measure.new(total)` returns a new measure.
326
287
 
327
288
  We recommend writing unit tests around any custom scales you create to ensure they work as expected before integrating with `mobiusloop`
328
289
 
329
- When done, run:
290
+ To run a single `.goal`, try this:
330
291
 
331
292
  $ mobiusloop goals/your_objective.goal
332
293
 
333
- To run a single `.goal`, or:
294
+ Where `your_objective.goal` is the name of your custom goal. You can run all the `.goal` files in `/goals` folder with this:
334
295
 
335
296
  $ mobiusloop
336
297
 
337
- To run all the `.goal` files in `/goals` folder.
338
-
339
298
 
340
- ## Advanced Features
299
+ ## advanced features
341
300
 
342
301
  Because `mobiusloop` is an extension of [Cucumber](http://cucumber.io), there are many features in Cucumber that also
343
302
  exist in `mobiusloop`. A few examples:
@@ -353,7 +312,6 @@ Will only run those Objectives, Problems, Outcomes or Key Results associated wit
353
312
  JSON or other formats. See [Cucumber reports](https://cucumber.io/docs/reference#reports) for more details.
354
313
 
355
314
 
356
-
357
315
  ## Testing
358
316
 
359
317
  `mobiusloop` is built using a test-first approach. We're proud of our tests, but we're always looking to add more.
@@ -11,6 +11,7 @@ module Cucumber
11
11
 
12
12
  # extra mobiusloop initiialization
13
13
  copy_step_defs('mobius_steps.rb', 'goals/step_definitions') # install mobius_steps.rb step definition
14
+ copy_step_defs('scales/page_response_scale.rb', 'goals/step_definitions') # example scale to measure response time
14
15
  copy_gherkin_languages('gherkin-languages.json') # copy modified gherkin-languages.json file to gherkin gem(s)
15
16
  copy_example_file('total_articles_scale.rb', 'goals/step_definitions')
16
17
  copy_example_file('total_readers_scale.rb', 'goals/step_definitions')
@@ -24,7 +24,7 @@ class Outcome
24
24
  start_time = Time.now
25
25
  @scale.record_measurement
26
26
  elapsed_time = (Time.now - start_time)
27
- return "Success! found " + format_number(@scale.measurements.last) + " " + @name + " in #{elapsed_time.round(1)} seconds!"
27
+ return "Success! Measure is " + format_number(@scale.measurements.last) + " " + @name + " in #{elapsed_time.round(1)} seconds!"
28
28
  rescue Exception => e
29
29
  return "Error! Measurement failed with message: " + e.message
30
30
  end
@@ -33,12 +33,22 @@ class Outcome
33
33
  # used to report progress towards goals
34
34
  def report
35
35
  report = ""
36
- report << status
36
+ # report << status
37
37
  report << report_progress
38
38
  report << report_remaining
39
39
  report
40
40
  end
41
41
 
42
+ # format number for display (1000000 => 1,000,000)
43
+ # unless number starts with 0 or .
44
+ def format_number(measure)
45
+ if measure != nil || measure.value != nil
46
+ whole, decimal = measure.value.to_s.split(".")
47
+ whole_with_commas = whole.chars.to_a.reverse.each_slice(3).map(&:join).join(",").reverse
48
+ [whole_with_commas, decimal].compact.join(".")
49
+ end
50
+ end
51
+
42
52
  private
43
53
 
44
54
  # report the status. Very simplistic now, need to validate if there is need
@@ -61,7 +71,11 @@ class Outcome
61
71
 
62
72
  # report remaining progress towards the target
63
73
  def report_remaining
64
- "#{percent_remaining.round(0)}% remaining to target in #{remaining_days} days\n"
74
+ if percent_remaining.round(0) <= 0
75
+ "Target achieved!"
76
+ else
77
+ "#{percent_remaining.round(0)}% remaining to target in #{remaining_days} days\n"
78
+ end
65
79
  end
66
80
 
67
81
  # percentage progress towards target as of now
@@ -91,9 +105,4 @@ class Outcome
91
105
  (DateTime.parse(target_date) - DateTime.now).to_i
92
106
  end
93
107
 
94
- # format number for display (1000000 => 1,000,000)
95
- def format_number(measure)
96
- measure.value.to_s.gsub(/(\d{3})(?=\d)/, '\\1,') unless measure == nil
97
- end
98
-
99
108
  end
@@ -0,0 +1,20 @@
1
+ require 'benchmark'
2
+ require 'mobiusloop/scale'
3
+
4
+ require "net/http"
5
+ require "uri"
6
+
7
+ # Records the response time of a web page
8
+ class PageResponseScale < Scale
9
+
10
+ attr_accessor :location
11
+
12
+ # returns a new Measure with response time of the :location
13
+ def measure
14
+ @location = "http://google.com" if @location == nil
15
+ time = Benchmark.measure do
16
+ response = Net::HTTP.get_response(URI.parse(@location))
17
+ end
18
+ Measure.new(time.real)
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobiusloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Shriver
@@ -791,6 +791,7 @@ files:
791
791
  - lib/mobiusloop/objective.rb
792
792
  - lib/mobiusloop/outcome.rb
793
793
  - lib/mobiusloop/scale.rb
794
+ - lib/mobiusloop/scales/page_response_scale.rb
794
795
  - lib/simplecov_setup.rb
795
796
  - major_changes_to_cucumber.md
796
797
  - mobiusloop.gemspec
@@ -870,7 +871,7 @@ rubyforge_project:
870
871
  rubygems_version: 2.4.5.1
871
872
  signing_key:
872
873
  specification_version: 4
873
- summary: mobiusloop-0.1.2
874
+ summary: mobiusloop-0.1.3
874
875
  test_files:
875
876
  - features/docs/api/list_step_defs_as_json.feature
876
877
  - features/docs/api/listen_for_events.feature