ennui 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTZlOWY3YjlkM2E0M2Y5Y2JiZGYzZjU5NTkwY2MxYmVjMzQ5NDNmNg==
4
+ ZTJiYjRiZGYwMjkxMzNhNjZkMGE5NjMxNjQzMTdhNWQxNzkxM2QxYg==
5
5
  data.tar.gz: !binary |-
6
- MGFkODcwY2E2MmFkODM3MWEyZDA4NTRkODdkNzhkMWU3NTEwODU0Yw==
6
+ Yzc0NDUyNWVmNGQwNTVhZTQ3YTNkYjViNzAzN2JmYjU5ZGNkODkwMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MzQ0MGVjYmIzODdjOThhNGM0YTI0MTU3MWJkZGFmZGE2NGU3ZTMwZDhmNjNi
10
- NTQ1ODcxYzhiZTUwZWY2NjljOThmOWJlM2NkMDE4YzJmY2Y0OTFhMjYzODc0
11
- OTY3MDY4MTEwZTE3ODIxMzkyMzhjMWUyZGRiZTEyOTM1MTIyMjg=
9
+ ZDY3MmJmNDRiZGE1NTY2YmFmMDI5NjdmNWQ5YTRkNWY3YTcyNmY4ZTNmNTcz
10
+ Zjg1ODQ3MDZlNWU5MGI3NzRhYWMyM2E2ZmEwOGM3NzQxMDA3NzdmMTFjM2Fh
11
+ YTBiMDEzYzFiMDhjNjFhNWRiYzc5MmQ2ZTEyYjE0OTE2NzY0ZDE=
12
12
  data.tar.gz: !binary |-
13
- MThlNzRjYzFlZGI0YTRkZmM4OWI0MzE0ZWNhYzc4OTQwMzY2ZGIzY2YyZTM3
14
- NDQ3NjE1YjNhNWE2ZDMwZGM0YmI4OTYyNDI4YmJkYWE4NzVmMWNmMThmNTUz
15
- NGU4NzEyMGU4NWZlZmUwODViZTZhMWZlMDFhYjE3ZGY1ZDIxZDI=
13
+ NDliYThmYzczNmUzN2VlNGU3OWE2Njc3NGU0MmE1OWE1OTIxNTgwNGExMmM4
14
+ NmRiYWYzY2FiMDg0NDJhOGJiZGYzNDg4YjBkNjhkYjYwNjJlOTBiZjZkMjg4
15
+ ZGRhN2FkNzk1NDE3ZGQ1Yjc4Y2Y2OWUxMGNmMTFjZmI5MTA2MGU=
data/.gitignore CHANGED
@@ -12,4 +12,4 @@
12
12
  /log/*.log
13
13
  /tmp
14
14
 
15
- ennui-0.0.1.gem
15
+ *.gem
data/Gemfile CHANGED
@@ -15,3 +15,5 @@ group :test do
15
15
  gem 'guard-rspec'
16
16
  gem 'simplecov'
17
17
  end
18
+
19
+ gemspec
@@ -1,3 +1,8 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ennui (0.0.2)
5
+
1
6
  GEM
2
7
  remote: https://rubygems.org/
3
8
  specs:
@@ -59,6 +64,7 @@ PLATFORMS
59
64
  DEPENDENCIES
60
65
  awesome_print
61
66
  cucumber
67
+ ennui!
62
68
  fivemat
63
69
  guard-rspec
64
70
  pry
data/Rakefile CHANGED
@@ -26,11 +26,9 @@ end
26
26
  desc "Build gem locally"
27
27
  task :build => :gemspec do
28
28
  system "gem build #{gemspec.name}.gemspec"
29
- FileUtils.mkdir_p "pkg"
30
- FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
31
29
  end
32
30
 
33
31
  desc "Install gem locally"
34
32
  task :install => :build do
35
- system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
33
+ system "gem install #{gemspec.name}-#{gemspec.version}.gem"
36
34
  end
@@ -1,6 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
1
5
  Gem::Specification.new do |s|
2
6
  s.name = "ennui"
3
- s.version = "0.0.1"
7
+ s.version = "0.0.2"
4
8
  s.platform = Gem::Platform::RUBY
5
9
  s.authors = ["Todd Mohney"]
6
10
  s.email = ["toddmohney@gmail.com"]
@@ -1,7 +1,32 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'ennui'
3
+ require "ennui"
4
4
 
5
- 10.times do
6
- puts "meh" if Ennui.sometimes?
5
+ class Example
6
+ include Ennui
7
+
8
+ def do_sometimes_predicate_example
9
+ puts
10
+ puts "do sometimes predicate example"
11
+ puts "------------------------------"
12
+ 10.times do
13
+ puts "meh" if sometimes?
14
+ end
15
+ end
16
+
17
+
18
+ def do_sometimes_block_example
19
+ puts
20
+ puts "do sometimes block example"
21
+ puts "--------------------------"
22
+ 10.times do
23
+ sometimes do
24
+ puts "pfft"
25
+ end
26
+ end
27
+ end
7
28
  end
29
+
30
+ example_runner = Example.new
31
+ example_runner.do_sometimes_predicate_example
32
+ example_runner.do_sometimes_block_example
@@ -1,16 +1,28 @@
1
1
  module Ennui
2
2
 
3
- def Ennui.sometimes?
3
+ def sometimes?
4
4
  random_number % 2 == 0
5
5
  end
6
6
 
7
- def Ennui.who_cares?
7
+ def sometimes
8
+ yield if sometimes? && block_given?
9
+ end
10
+
11
+ def whatever
12
+ sometimes
13
+ end
14
+
15
+ def maybe
16
+ sometimes
17
+ end
18
+
19
+ def who_cares?
8
20
  random_number % 4 == 0
9
21
  end
10
22
 
11
- private
23
+ private
12
24
 
13
- def Ennui.random_number
25
+ def random_number
14
26
  Random.new.rand(0..1000)
15
27
  end
16
28
 
@@ -1,41 +1,69 @@
1
1
  require 'spec_helper'
2
2
  require 'pry'
3
+ require 'ennui'
4
+
5
+ include Ennui
6
+
7
+ class EnnuiTest
8
+ include Ennui
9
+ end
3
10
 
4
11
  describe Ennui do
12
+ let(:ennui_test) { EnnuiTest.new }
5
13
 
6
14
  describe "#sometimes?" do
7
- before do
8
- @truthiness_score = 0
15
+ it "is true about %50 of the time" do
16
+ score = truthiness_score(1000, Proc.new { sometimes? })
17
+ score.should be_within(0.10).of(0.50)
18
+ end
19
+ end
20
+
21
+ describe "#sometimes" do
22
+ it "calls sometimes?" do
23
+ Ennui.should_receive(:sometimes?)
24
+ Ennui.sometimes
25
+ end
9
26
 
10
- 100.times do
11
- @truthiness_score += 1 if Ennui.sometimes?
27
+ context "when sometimes? is true" do
28
+ before do
29
+ Ennui.stub(:sometimes?) { true }
12
30
  end
13
31
 
14
- puts "Truthiness score: #{@truthiness_score}"
32
+ it "yields to the block" do
33
+ expect { |block| Ennui.sometimes(&block) }.to yield_control
34
+ end
15
35
  end
16
36
 
17
- it "is true about %50 of the time" do
18
- score = truthiness_score(1000, Proc.new { Ennui.sometimes? })
19
- score.should be_within(0.10).of(0.50)
37
+ context "when sometimes? is false" do
38
+ before do
39
+ Ennui.stub(:sometimes?) { false }
40
+ end
41
+
42
+ it "does not yield to the block" do
43
+ expect { |block| Ennui.sometimes(&block) }.not_to yield_control
44
+ end
20
45
  end
21
46
  end
22
47
 
23
48
  describe "#who_cares?" do
24
49
  it "is true about %25 of the time" do
25
- score = truthiness_score(1000, Proc.new { Ennui.who_cares? })
50
+ score = truthiness_score(1000, Proc.new { who_cares? })
26
51
  score.should be_within(0.10).of(0.25)
27
52
  end
28
53
  end
29
54
 
30
- def truthiness_score(iterations, proc)
31
- truthiness = 0
32
- iterations.times do
33
- truthiness += 1 if proc.call
55
+ describe "#whatever" do
56
+ it "is an alias for sometimes" do
57
+ Ennui.should_receive(:sometimes)
58
+ Ennui.whatever
34
59
  end
60
+ end
35
61
 
36
- score = truthiness.to_f / iterations.to_f
37
- puts "Truthiness score: #{score}"
38
- score
62
+ describe "#maybe" do
63
+ it "is an alias for sometimes" do
64
+ Ennui.should_receive(:sometimes)
65
+ Ennui.maybe
66
+ end
39
67
  end
40
68
 
41
69
  end
@@ -2,3 +2,15 @@ require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
4
  require 'ennui'
5
+
6
+ def truthiness_score(iterations, proc)
7
+ truthiness = 0
8
+ iterations.times do
9
+ truthiness += 1 if proc.call
10
+ end
11
+
12
+ score = truthiness.to_f / iterations.to_f
13
+ puts "Truthiness score: #{score}"
14
+ score
15
+ end
16
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ennui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Mohney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-18 00:00:00.000000000 Z
11
+ date: 2013-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ennui provides a library of predicates which return true at various frequencies.
14
14
  email: