nO_op 1.O.O → 1.O.O.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/History.txt +5 -0
  2. data/README.md +34 -0
  3. data/lib/nO_op.rb +4 -0
  4. data/spec/nO_op_spec.rb +19 -0
  5. metadata +4 -2
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.0.1 2011-09-23
2
+
3
+ * 1 miniscule enhancement:
4
+ * Added o_O
5
+
1
6
  == 1.0.0 2011-09-23
2
7
 
3
8
  * 1 major enhancement:
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # What?
2
+
3
+ I think this question can be best answered by a few contrived examples of what real-world use might look like.
4
+
5
+ ```
6
+ # This convoluted code makes sure that the @kind is "credit_card" or
7
+ # "purchase_order", and if it's not "credit_card", then the customer
8
+ # must not have a payment_method of "credit_card".
9
+ if [ 'credit_card', 'purchase_order' ].include?(@kind) && (@kind == 'credit_card' || current_user.customer.payment_method == 'purchase_order')
10
+ @order = ((@kind == 'credit_card') ? CreditCardOrder : PurchaseOrder).new(params[:order])
11
+
12
+ O_o
13
+ end
14
+ ```
15
+
16
+ or
17
+
18
+ ```
19
+ current_user.prelude_web_user.shipping_addresses.reject { |a| a.to_s.blank? }.sort_by(&:to_s).O_o.collect {|a| [ a.to_s, a.id ] }
20
+ ```
21
+
22
+ I like to think of that second usage as a judgemental `tap`.
23
+
24
+ Also available:
25
+
26
+ * o_O
27
+
28
+ ## Contributions
29
+
30
+ You want to contribute to this? Really? Y'know, you should check out my 'truthy' project, too.
31
+
32
+ ## License
33
+
34
+ nO_op uses the MIT license. Read License.txt if you care.
data/lib/nO_op.rb CHANGED
@@ -5,4 +5,8 @@ module Kernel
5
5
  def O_o
6
6
  self
7
7
  end
8
+
9
+ def o_O
10
+ self
11
+ end
8
12
  end
data/spec/nO_op_spec.rb CHANGED
@@ -23,4 +23,23 @@ describe 'methods' do
23
23
  obj.O_o.should == obj
24
24
  end
25
25
  end
26
+
27
+ it "should add an 'o_O' method" do
28
+ Object.new.should.respond_to(:o_O)
29
+ end
30
+
31
+ describe "'o_O' method" do
32
+ it 'should not require arguments' do
33
+ lambda { Object.new.o_O }.should.not.raise(ArgumentError)
34
+ end
35
+
36
+ it 'should return the calling object' do
37
+ obj = Object.new
38
+ obj.o_O.should == obj
39
+ end
40
+
41
+ it 'should be callable on its own' do
42
+ lambda { o_O }.should.not.raise
43
+ end
44
+ end
26
45
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nO_op
3
3
  version: !ruby/object:Gem::Version
4
- hash: 231
4
+ hash: 445
5
5
  prerelease: 2
6
6
  segments:
7
7
  - 1
8
8
  - O
9
9
  - O
10
- version: 1.O.O
10
+ - 1
11
+ version: 1.O.O.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Yossef Mendelssohn
@@ -45,6 +46,7 @@ extra_rdoc_files: []
45
46
  files:
46
47
  - License.txt
47
48
  - History.txt
49
+ - README.md
48
50
  - lib/nO_op.rb
49
51
  - spec/helper.rb
50
52
  - spec/nO_op_spec.rb