assume 0.1.0 → 0.1.1

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: 8d8e6d1cef180511bada22d9611eddd535a1f929ca4a38aae70800d66653411e
4
- data.tar.gz: ab8ece061eea9f1b900f991ab2197a2ae09e6d832e1e552240bf36651768a6ee
3
+ metadata.gz: a7a6101652f07a693d31f7070d5e18dd06927742375ec9e0e4ee57a1b77b2ca3
4
+ data.tar.gz: 72dc5f2f56bdd8ec523e16e445c9146e6f64243bafb6cdd17bb7c7581d6299c2
5
5
  SHA512:
6
- metadata.gz: 3586e10e23cb079f8379235a829dd107106f2aaf444903c8f4a8536522e583e38ed102c1a509673fd660f8e7be5791e0db57839078044ca427b1deeb5a5543d1
7
- data.tar.gz: 94fba0ee942779ea52e89342b28ddf358f7c0a0f3ac09440c65a883a21ef4b541c2fd4e3818396e8464a2854f0a11283ba33cb0bae30b41edf777b9370132178
6
+ metadata.gz: 4721d719e7d90269d9c4d79b557c7ce04c739b277b9fa495db3757a65fcc428ceb6439e03f3a107253b583247facf4f8894a0a962dbc98825160e9e440b0a696
7
+ data.tar.gz: d2671defd34553365cbf23708a46ea9aabd0d715c9e3145c5a08fca63664707bf327b84cbbb2ff6176dc6eeb1800010cb88f7168dba9b58a608054f1feddf4d8
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.5
data/CHANGES.md CHANGED
@@ -1,2 +1,5 @@
1
+ ### 0.1.1
2
+ - prevent misconfiguration of handler with an exception
3
+
1
4
  ### 0.1.0
2
5
  - initial release
data/Gemfile.lock CHANGED
@@ -1,25 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assume (0.1.0)
4
+ assume (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
10
9
  diff-lcs (1.4.4)
11
10
  io-console (0.5.6)
12
11
  irb (1.2.7)
13
12
  reline (>= 0.1.5)
14
- parallel (1.20.1)
15
- parser (2.7.2.0)
16
- ast (~> 2.4.1)
17
- rainbow (3.0.0)
18
13
  rake (10.5.0)
19
- regexp_parser (2.0.0)
20
14
  reline (0.1.9)
21
15
  io-console (~> 0.5)
22
- rexml (3.2.4)
23
16
  rspec (3.10.0)
24
17
  rspec-core (~> 3.10.0)
25
18
  rspec-expectations (~> 3.10.0)
@@ -33,19 +26,6 @@ GEM
33
26
  diff-lcs (>= 1.2.0, < 2.0)
34
27
  rspec-support (~> 3.10.0)
35
28
  rspec-support (3.10.0)
36
- rubocop (1.6.1)
37
- parallel (~> 1.10)
38
- parser (>= 2.7.1.5)
39
- rainbow (>= 2.2.2, < 4.0)
40
- regexp_parser (>= 1.8, < 3.0)
41
- rexml
42
- rubocop-ast (>= 1.2.0, < 2.0)
43
- ruby-progressbar (~> 1.7)
44
- unicode-display_width (>= 1.4.0, < 2.0)
45
- rubocop-ast (1.3.0)
46
- parser (>= 2.7.1.5)
47
- ruby-progressbar (1.10.1)
48
- unicode-display_width (1.7.0)
49
29
 
50
30
  PLATFORMS
51
31
  ruby
@@ -56,7 +36,6 @@ DEPENDENCIES
56
36
  irb
57
37
  rake (~> 10.0)
58
38
  rspec (~> 3.0)
59
- rubocop
60
39
 
61
40
  BUNDLED WITH
62
- 2.1.4
41
+ 2.2.22
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Assume is a tool that helps you record your assumptions about code directly in the code you're writing. It is similiar in functionality to and directly inspired by [solid_assert](https://rubygems.org/gems/solid_assert).
4
4
 
5
+ As opposed to solid_assert, this gem has you write your assumptions in ruby code blocks.
6
+ The idea behind this is that the assumption does not need to be evaluated in your production/release environment, reserving expensive checks for development/test environments which only
7
+ affect developers.
8
+
5
9
  ## What?
6
10
 
7
11
  We make lots of assumptions when we write code. [Programming with assertions](https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html) is a technique that helps you catch problems with your assumptions earlier in the development process.
@@ -9,7 +13,7 @@ We make lots of assumptions when we write code. [Programming with assertions](ht
9
13
  Assertions live in a subtle space between testing your code explicitly and
10
14
  raising exceptions to enforce your api behaviour or handle edge cases. It is not a replacement for either.
11
15
 
12
- This gem is an attempt to make the concept less computer-sciency and more english, encouraging you to think about and record your assumptions as you go, maybe even leave them in the codebase for your colleagues to find, so they may understand your thinking, and thus your code, better.
16
+ This gem is an attempt to make the concept less computer-sciency and more english, encouraging you to think about and record your assumptions as you go and leave them in the codebase for your colleagues to find, so they may understand your thinking, and thus your code, better.
13
17
 
14
18
  ## Why tho?
15
19
 
@@ -30,7 +34,7 @@ end
30
34
 
31
35
  We know we don't need to perform another check on i, as we've exhausted all other options, but what happens when 'Dave' comes along next month and extends the enum to allow a 4?
32
36
 
33
- By recording our assumption in code, 'Dave' will (hopefully) test his new enum and quickly discover that he broke our previous assumptions.
37
+ By recording our assumption in code, 'Dave' will (hopefully) test his new enum value and quickly discover that he broke our previous assumption.
34
38
 
35
39
  If he happens to read our code, it will say *right there in the code* that he's broken it, and he'll know to fix it.
36
40
 
@@ -72,17 +76,32 @@ You're doing some control flow you know will never happen
72
76
  def something(arg)
73
77
  case arg
74
78
  when 1
79
+ :option1
75
80
  when 2
81
+ :option2
76
82
  when 3
83
+ :option3
77
84
  else
78
85
  # instead of raise "this should never happen"
79
- assume { false } # maybe real users don't need to notice, since this is not actually dangerous
86
+ # maybe real users don't need to notice, since this is not actually dangerous
87
+ assume { false }
88
+
89
+ :option1 # .. as long as we return the default option
80
90
  end
81
91
  end
82
92
  ```
83
93
 
84
94
  ## Installation
85
95
 
96
+ Open `assume/lib/assume.rb` and copy/paste it into your project.
97
+
98
+ The code is trivial, and you may want to customize it to behave
99
+ differently or have a different interface.
100
+
101
+ Since making this gem I have done this myself, and recommend it.
102
+
103
+ ### Using rubygems
104
+
86
105
  Add this line to your application's Gemfile:
87
106
 
88
107
  ```ruby
@@ -114,7 +133,7 @@ require "assume/core_ext" # monkey-patches Object to provide the methods everywh
114
133
  ```
115
134
 
116
135
  ```ruby
117
- require "assume/refine" # Loads Assumptions
136
+ require "assume/refine" # Loads Assumptions, a module containing a refinement
118
137
 
119
138
  class Whatever
120
139
  using Assumptions # assume's methods are now available in this class
@@ -181,7 +200,7 @@ Don't use assume and rescue BadAssumption as an error handling mechanism.
181
200
  Make your own error class and `raise`/`rescue` it.
182
201
  Don't use assume to enforce the public api of a class/method. `raise ArgumentError` instead.
183
202
 
184
- You should probably not use assume directly in a test case (you've already got expect/assert/whatever) but if the code under test uses assume and assume is enabled in your test suite, bonus! Your test suite is now more robust!
203
+ You should probably not use assume directly in a test case (you've already got expect/assert/whatever) but if the code under test uses assume and assume is enabled in your test suite, bonus!
185
204
 
186
205
  ## Advanced
187
206
 
@@ -210,7 +229,7 @@ the block's #source_location method points it at. E.g. it will not print any sou
210
229
 
211
230
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
212
231
 
213
- Warning: Do not use `rspec` to run all the tests, they will fail as they are testing require statements. Use `rake`.
232
+ Use `rake test` to run the tests. `rake` and `rake spec` also works.
214
233
 
215
234
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
216
235
 
data/Rakefile CHANGED
@@ -3,12 +3,13 @@
3
3
  require "bundler/gem_tasks"
4
4
 
5
5
  task :spec do
6
- sh "rspec spec/assume_spec.rb"
7
- sh "rspec spec/core_ext_spec.rb"
8
- sh "rspec spec/refine_spec.rb"
6
+ sh "bundle exec rspec spec/assume_spec.rb"
7
+ sh "bundle exec rspec spec/core_ext_spec.rb"
8
+ sh "bundle exec rspec spec/refine_spec.rb"
9
9
  end
10
10
  task default: :spec
11
+ task test: :spec
11
12
 
12
13
  task :console do
13
- exec 'bin/console'
14
+ exec 'bundle exec bin/console'
14
15
  end
data/assume.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Odin H B"]
11
11
  spec.email = ["odinh2908@gmail.com"]
12
12
 
13
- spec.summary = "Write your assumptions down - in code"
14
- spec.description = "Assume encourages you to communicate with your team members and build confidence in your code"
13
+ spec.summary = "Be honest about your (code's) assumptions"
14
+ spec.description = "Assume is an assert library with a better name"
15
15
  spec.homepage = "https://github.com/odinhb/assume"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -1,3 +1,3 @@
1
1
  module Assume
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/assume.rb CHANGED
@@ -35,6 +35,10 @@ module Assume
35
35
 
36
36
  class << self
37
37
  def handler=(handler)
38
+ unless handler.respond_to?(:call)
39
+ raise ArgumentError, "Assume::handler must respond to #call"
40
+ end
41
+
38
42
  @assumption_handler = handler
39
43
  end
40
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assume
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Odin H B
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2022-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,8 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Assume encourages you to communicate with your team members and build
70
- confidence in your code
69
+ description: Assume is an assert library with a better name
71
70
  email:
72
71
  - odinh2908@gmail.com
73
72
  executables: []
@@ -76,6 +75,7 @@ extra_rdoc_files: []
76
75
  files:
77
76
  - ".gitignore"
78
77
  - ".rspec"
78
+ - ".tool-versions"
79
79
  - CHANGES.md
80
80
  - Gemfile
81
81
  - Gemfile.lock
@@ -96,7 +96,7 @@ metadata:
96
96
  homepage_uri: https://github.com/odinhb/assume
97
97
  source_code_uri: https://github.com/odinhb/assume
98
98
  changelog_uri: https://github.com/odinhb/assume/CHANGES.md
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -111,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.1.4
115
- signing_key:
114
+ rubygems_version: 3.0.3
115
+ signing_key:
116
116
  specification_version: 4
117
- summary: Write your assumptions down - in code
117
+ summary: Be honest about your (code's) assumptions
118
118
  test_files: []