alias 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'context' #gem install jeremymcanally-context -s http://gems.github.com
4
- require 'mocha' #gem install mocha
5
- require 'matchy' #gem install jeremymcanally-matchy -s http://gems.github.com
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require 'bacon'
2
+ require 'mocha'
3
+ require 'mocha-on-bacon'
7
4
  require 'alias'
5
+ include Alias
8
6
 
9
- class Test::Unit::TestCase
7
+ class Bacon::Context
8
+ def before_all; yield; end
9
+ def xit(*args); end
10
10
  def capture_stdout(&block)
11
11
  original_stdout = $stdout
12
12
  $stdout = fake = StringIO.new
@@ -1,42 +1,40 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
2
 
3
- module Alias
4
- class UtilTest < Test::Unit::TestCase
5
- test "any_const_get fetches simple class" do
6
- Util.any_const_get("Array").should == Array
7
- end
8
-
9
- test "any_const_get fetches nested class" do
10
- eval "module ::Somemodule; class Someclass; end; end"
11
- Util.any_const_get("Somemodule::Someclass").should == Somemodule::Someclass
12
- end
13
-
14
- test "any_const_get returns nil for nonexistent class" do
15
- Util.any_const_get("NonexistentClass").should == nil
16
- end
17
-
18
- test "slice only returns valid keys given" do
19
- Util.slice({:a=>1,:b=>2}, :a, :c).should == {:a=>1}
20
- end
21
-
22
- test "slice_off! returns given keys but takes them off existing hash" do
23
- h = {:a=>1, :b=>2}
24
- Util.slice_off!(h, :a, :c).should == {:a=>1}
25
- h.should == {:b=>2}
26
- end
27
-
28
- test "camelize should uppercase non-underscored string" do
29
- Util.camelize('man').should == 'Man'
30
- end
31
-
32
- test "camelize should camelize underscored string" do
33
- Util.camelize('some_test').should == 'SomeTest'
34
- end
35
-
36
- test "make_shortest_aliases" do
37
- eval "::Y = 'some value'"
38
- expected_hash = {"Yo"=>"Y", "Man"=>"M", "Cool"=>"C", 'Yay'=>'Ya'}
39
- Util.make_shortest_aliases(['Yo','Yay','Cool','Man']).should == expected_hash
40
- end
3
+ describe "Util" do
4
+ it "any_const_get fetches simple class" do
5
+ Util.any_const_get("Array").should == Array
6
+ end
7
+
8
+ it "any_const_get fetches nested class" do
9
+ eval "module ::Somemodule; class Someclass; end; end"
10
+ Util.any_const_get("Somemodule::Someclass").should == Somemodule::Someclass
11
+ end
12
+
13
+ it "any_const_get returns nil for nonexistent class" do
14
+ Util.any_const_get("NonexistentClass").should == nil
15
+ end
16
+
17
+ it "slice only returns valid keys given" do
18
+ Util.slice({:a=>1,:b=>2}, :a, :c).should == {:a=>1}
19
+ end
20
+
21
+ it "slice_off! returns given keys but takes them off existing hash" do
22
+ h = {:a=>1, :b=>2}
23
+ Util.slice_off!(h, :a, :c).should == {:a=>1}
24
+ h.should == {:b=>2}
25
+ end
26
+
27
+ it "camelize should uppercase non-underscored string" do
28
+ Util.camelize('man').should == 'Man'
29
+ end
30
+
31
+ it "camelize should camelize underscored string" do
32
+ Util.camelize('some_test').should == 'SomeTest'
33
+ end
34
+
35
+ it "make_shortest_aliases" do
36
+ eval "::Y = 'some value'"
37
+ expected_hash = {"Yo"=>"Y", "Man"=>"M", "Cool"=>"C", 'Yay'=>'Ya'}
38
+ Util.make_shortest_aliases(['Yo','Yay','Cool','Man']).should == expected_hash
41
39
  end
42
40
  end
@@ -1,72 +1,70 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
2
 
3
- class Alias::ValidatorTest < Test::Unit::TestCase
4
- context "Validator" do
5
- before(:all) { eval "class ::TestCreator < Alias::Creator; end"}
6
- before(:each) { Alias::Validator.instance_eval "@validators = {}"}
3
+ describe "Validator" do
4
+ before_all { eval "class ::TestCreator < Alias::Creator; end"}
5
+ before { Validator.instance_eval "@validators = {}"}
7
6
 
8
- def validate(options={})
9
- creator = TestCreator.new
10
- options.each {|k,v| creator.send("#{k}=",v)}
11
- @validator.validate(creator, {}, :blah)
12
- end
7
+ def validate(options={})
8
+ creator = TestCreator.new
9
+ options.each {|k,v| creator.send("#{k}=",v)}
10
+ @validator.validate(creator, {}, :blah)
11
+ end
13
12
 
14
- def validator_message
15
- @validator.create_message(:blah)
16
- end
13
+ def validator_message
14
+ @validator.create_message(:blah)
15
+ end
17
16
 
18
- def create_validator(options)
19
- @validator = TestCreator.valid :num, options
20
- end
17
+ def create_validator(options)
18
+ @validator = TestCreator.valid :num, options
19
+ end
21
20
 
22
- def create_parent_validator(key)
23
- Alias::Validator.register_validators [{:key=>key, :if=>lambda {|e| 'yo'}, :message=>lambda {|e| 'cool'}}]
24
- @parent_validator = Alias::Validator.validators[key]
25
- end
21
+ def create_parent_validator(key)
22
+ Validator.register_validators [{:key=>key, :if=>lambda {|e| 'yo'}, :message=>lambda {|e| 'cool'}}]
23
+ @parent_validator = Validator.validators[key]
24
+ end
26
25
 
27
- test "copies a validator when using a previous one" do
28
- create_parent_validator :num
29
- create_validator :if=>:num
30
- @parent_validator.validate(TestCreator.new, {}, :blah).should == validate
31
- end
26
+ it "copies a validator when using a previous one" do
27
+ create_parent_validator :num
28
+ create_validator :if=>:num
29
+ @parent_validator.validate(TestCreator.new, {}, :blah).should == validate
30
+ end
32
31
 
33
- test "inherits a validator's message when using a previous one" do
34
- create_parent_validator :num
35
- create_validator :if=>:num
36
- validator_message.should == 'cool'
37
- end
32
+ it "inherits a validator's message when using a previous one" do
33
+ create_parent_validator :num
34
+ create_validator :if=>:num
35
+ validator_message.should == 'cool'
36
+ end
38
37
 
39
- test "overrides an inherited message with explicit message" do
40
- create_parent_validator :num
41
- create_validator :if=>:num, :message=>lambda {|e| 'cooler'}
42
- validator_message.should == 'cooler'
43
- end
38
+ it "overrides an inherited message with explicit message" do
39
+ create_parent_validator :num
40
+ create_validator :if=>:num, :message=>lambda {|e| 'cooler'}
41
+ validator_message.should == 'cooler'
42
+ end
44
43
 
45
- test "sets a default message if an invalid one is given" do
46
- create_validator :if=>lambda {|e| 'yo'}, :message=>:blah
47
- validator_message.should =~ /Validation failed/
48
- end
44
+ it "sets a default message if an invalid one is given" do
45
+ create_validator :if=>lambda {|e| 'yo'}, :message=>:blah
46
+ validator_message.should =~ /Validation failed/
47
+ end
49
48
 
50
- test "with :with option sets proc arg" do
51
- create_validator :if=>lambda {|e| 'yo'}, :with=>[:a, :b]
52
- @validator.validation_proc.expects(:call).with(['a','c'])
53
- @validator.validate(TestCreator.new, {:a=>'a', :b=>'c', :c=>'d'}, :c)
54
- end
49
+ it "with :with option sets proc arg" do
50
+ create_validator :if=>lambda {|e| 'yo'}, :with=>[:a, :b]
51
+ @validator.validation_proc.expects(:call).with(['a','c'])
52
+ @validator.validate(TestCreator.new, {:a=>'a', :b=>'c', :c=>'d'}, :c)
53
+ end
55
54
 
56
- test "with :unless option negates result and changes message" do
57
- create_validator :unless=>lambda {|e| true }, :message=>lambda {|e| "yo doesn't exist"}
58
- validate.should == false
59
- validator_message.should == 'yo already exists'
60
- end
55
+ it "with :unless option negates result and changes message" do
56
+ create_validator :unless=>lambda {|e| true }, :message=>lambda {|e| "yo doesn't exist"}
57
+ validate.should == false
58
+ validator_message.should == 'yo already exists'
59
+ end
61
60
 
62
- test "with :optional option can be forced" do
63
- create_validator :if=>lambda { false }, :optional=>true
64
- validate(:force=>true).should == true
65
- end
61
+ it "with :optional option can be forced" do
62
+ create_validator :if=>lambda { false }, :optional=>true
63
+ validate(:force=>true).should == true
64
+ end
66
65
 
67
- test "without :optional option cannot be forced" do
68
- create_validator :if=>lambda { false }
69
- validate(:force=>true).should == false
70
- end
66
+ it "without :optional option cannot be forced" do
67
+ create_validator :if=>lambda {|e| false }
68
+ validate(:force=>true).should == false
71
69
  end
72
70
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 2
9
+ version: 0.2.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Gabriel Horner
@@ -9,10 +14,48 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-07-07 00:00:00 -04:00
17
+ date: 2010-06-11 00:00:00 -04:00
13
18
  default_executable:
14
- dependencies: []
15
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bacon
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: mocha
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: mocha-on-bacon
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id003
16
59
  description: Creates aliases for class methods, instance methods, constants, delegated methods and more. Aliases can be easily searched or saved as YAML config files to load later. Custom alias types are easy to create with the DSL Alias provides. Although Alias was created with the irb user in mind, any Ruby console program can hook into Alias for creating configurable aliases.
17
60
  email: gabriel.horner@gmail.com
18
61
  executables: []
@@ -20,15 +63,9 @@ executables: []
20
63
  extensions: []
21
64
 
22
65
  extra_rdoc_files:
23
- - LICENSE.txt
24
66
  - README.rdoc
25
- files:
26
- - CHANGELOG.rdoc
27
67
  - LICENSE.txt
28
- - README.rdoc
29
- - Rakefile
30
- - VERSION.yml
31
- - lib/alias.rb
68
+ files:
32
69
  - lib/alias/console.rb
33
70
  - lib/alias/creator.rb
34
71
  - lib/alias/creators/any_to_instance_method_creator.rb
@@ -39,8 +76,9 @@ files:
39
76
  - lib/alias/manager.rb
40
77
  - lib/alias/util.rb
41
78
  - lib/alias/validator.rb
79
+ - lib/alias/version.rb
80
+ - lib/alias.rb
42
81
  - test/alias_test.rb
43
- - test/aliases.yml
44
82
  - test/any_to_instance_method_creator_test.rb
45
83
  - test/class_method_creator_test.rb
46
84
  - test/class_to_instance_method_creator_test.rb
@@ -52,44 +90,45 @@ files:
52
90
  - test/test_helper.rb
53
91
  - test/util_test.rb
54
92
  - test/validator_test.rb
93
+ - test/aliases.yml
94
+ - LICENSE.txt
95
+ - CHANGELOG.rdoc
96
+ - README.rdoc
97
+ - Rakefile
98
+ - gemspec
55
99
  has_rdoc: true
56
100
  homepage: http://tagaholic.me/alias/
57
101
  licenses: []
58
102
 
59
103
  post_install_message:
60
- rdoc_options:
61
- - --charset=UTF-8
104
+ rdoc_options: []
105
+
62
106
  require_paths:
63
107
  - lib
64
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
65
110
  requirements:
66
111
  - - ">="
67
112
  - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
68
115
  version: "0"
69
- version:
70
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
71
118
  requirements:
72
119
  - - ">="
73
120
  - !ruby/object:Gem::Version
74
- version: "0"
75
- version:
121
+ segments:
122
+ - 1
123
+ - 3
124
+ - 6
125
+ version: 1.3.6
76
126
  requirements: []
77
127
 
78
128
  rubyforge_project: tagaholic
79
- rubygems_version: 1.3.2
129
+ rubygems_version: 1.3.7
80
130
  signing_key:
81
131
  specification_version: 3
82
132
  summary: Creates, manages and saves aliases for class methods, instance methods, constants, delegated methods and more.
83
- test_files:
84
- - test/alias_test.rb
85
- - test/any_to_instance_method_creator_test.rb
86
- - test/class_method_creator_test.rb
87
- - test/class_to_instance_method_creator_test.rb
88
- - test/console_test.rb
89
- - test/constant_creator_test.rb
90
- - test/creator_test.rb
91
- - test/instance_method_creator_test.rb
92
- - test/manager_test.rb
93
- - test/test_helper.rb
94
- - test/util_test.rb
95
- - test/validator_test.rb
133
+ test_files: []
134
+
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 2
4
- :patch: 1