nkpart-prohax 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/prohax.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $: << File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  module Prohax
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
6
6
 
7
7
  require 'prohax/strucked'
data/lib/prohax/let_in.rb CHANGED
@@ -1,32 +1,31 @@
1
1
  require 'prohax/strucked'
2
2
 
3
- class Container
3
+ class LetInContainer
4
+ def metaclass
5
+ class <<self
6
+ self
7
+ end
8
+ end
9
+
4
10
  def initialize defines
5
11
  defines.each do |key, value|
6
12
  if value.respond_to? :call then
7
- self.class.class_eval {
13
+ self.metaclass.class_eval {
8
14
  define_method(key) { |*args| value.call *args }
9
15
  }
10
16
  else
11
- self.class.class_eval {
17
+ self.metaclass.class_eval {
12
18
  define_method(key) { value }
13
19
  }
14
20
  end
15
21
  end
16
22
  end
17
- end
18
23
 
19
- class LetProxy < Strucked.build(:defines)
20
- # def initialize defines
21
- # @defines = defines
22
- # end
23
- def in &blk
24
- Container.new(@defines).instance_eval &blk
25
- end
24
+ alias :in :instance_eval
26
25
  end
27
26
 
28
27
  module Kernel
29
28
  def let defines
30
- LetProxy.new(defines)
29
+ LetInContainer.new(defines)
31
30
  end
32
31
  end
@@ -15,6 +15,12 @@ class Strucked
15
15
  self.instance_variable_set("@\#\{fld\}", value)
16
16
  end
17
17
  end
18
+
19
+ def == other
20
+ self.class.fields.inject(true) do |memo, f|
21
+ memo && (self.instance_variable_get("@\#\{f\}") == other.instance_variable_get("@\#\{f\}"))
22
+ end
23
+ end
18
24
  EOS
19
25
  cls
20
26
  end
data/prohax.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{prohax}
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nick Partridge"]
9
- s.date = %q{2008-11-18}
9
+ s.date = %q{2008-11-27}
10
10
  s.description = %q{}
11
11
  s.email = ["nkpart@gmail.com"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.txt"]
@@ -2,7 +2,11 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "The let().in {} syntax" do
4
4
  it "should be let-like and in-ish" do
5
- let(:foo => 5 ).in { foo }.should == 5
5
+ let(
6
+ :foo => 5
7
+ ).in {
8
+ foo
9
+ }.should == 5
6
10
  end
7
11
 
8
12
  it "should be mad" do
@@ -16,4 +20,11 @@ describe "The let().in {} syntax" do
16
20
  plus(x, times(five, plus(1, fast_five)))
17
21
  }.should == 35
18
22
  end
23
+
24
+ it "should have separate scopes" do
25
+ let(:three => 3).in { three }.should == 3
26
+ proc {
27
+ let(:five => 5).in { three }
28
+ }.should raise_error
29
+ end
19
30
  end
@@ -29,6 +29,14 @@ describe Strucked do
29
29
  it "does not create accessors" do
30
30
  proc { Strucked.new(:foo).new(5).foo }.should raise_error
31
31
  end
32
+
33
+ it "should provide equality" do
34
+ f = Strucked.build :a
35
+
36
+ p = f.new 5
37
+ q = f.new 5
38
+ p.should == q
39
+ end
32
40
 
33
41
  end
34
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nkpart-prohax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Partridge
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 -08:00
12
+ date: 2008-11-27 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency