normally 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +2 -2
  2. data/lib/normally.rb +10 -10
  3. metadata +2 -2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Prioritizing the Happy Path
4
4
 
5
- Much of the time when talking about conditional expressions, the concepts of a _happy path_ and a _sad path_ are useful. The happy path is the branch of the conditional that executes during the normal operation of your program. The sad path is there only to deal with errors or invalid input. When test-driving code, I normally focus on the happy path first. When reading code, I like to see the happy path first because the happy path tells me what the code is supposed to do, while the sad path just tells me how the code avoids doing things it's not supposed to do.
5
+ Much of the time when talking about conditional expressions, the concepts of a _happy path_ and a _sad path_ are useful. The happy path is the branch of the conditional that executes during the normal operation of your program. The sad path is there only to deal with errors or invalid input. When reading code, I like to see the happy path first because the happy path tells me what the code is supposed to do, while the sad path just tells me how the code avoids doing things it's not supposed to do.
6
6
 
7
7
  Despite the importance of the happy path, the sad path is often the most visible in code with conditionals. Consider the following:
8
8
 
@@ -37,7 +37,7 @@ You know the drill. If you're using [bundler](https://rubygems.org/gems/bundler)
37
37
  gem 'normally'
38
38
  ```
39
39
 
40
- To install globally, do `gem install normally`
40
+ To install globally, run `gem install normally`.
41
41
 
42
42
  The `normally` method is part of the `Normally` module, which must be included either in the global namespace or in the class where you want to use the `normally` syntax. For example:
43
43
 
data/lib/normally.rb CHANGED
@@ -1,15 +1,15 @@
1
- class HappyPath
2
- def initialize(happy_proc)
3
- @happy_proc = happy_proc
4
- end
5
-
6
- def but_if(condition)
7
- condition ? yield : @happy_proc.call
8
- end
9
- end
10
-
11
1
  module Normally
12
2
  def normally(&block)
13
3
  HappyPath.new(block)
14
4
  end
5
+
6
+ class HappyPath
7
+ def initialize(happy_proc)
8
+ @happy_proc = happy_proc
9
+ end
10
+
11
+ def but_if(condition)
12
+ condition ? yield : @happy_proc.call
13
+ end
14
+ end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normally
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -46,5 +46,5 @@ rubyforge_project:
46
46
  rubygems_version: 1.8.23
47
47
  signing_key:
48
48
  specification_version: 3
49
- summary: normally-0.0.0
49
+ summary: normally-0.0.1
50
50
  test_files: []