sugar-high 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -0
- data/VERSION +1 -1
- data/lib/sugar-high/alias.rb +6 -2
- data/lib/sugar-high/hash.rb +7 -0
- data/lib/sugar-high/includes.rb +9 -0
- data/spec/sugar-high/alias_spec.rb +31 -8
- data/spec/sugar-high/includes_spec.rb +33 -0
- data/sugar-high.gemspec +6 -2
- metadata +7 -3
data/README.markdown
CHANGED
@@ -30,6 +30,10 @@ See specs for example use
|
|
30
30
|
* args (Used in generator CLI testing)
|
31
31
|
* last_option *args : Returns last argument if hash or empty hash otherwise
|
32
32
|
|
33
|
+
### Hash
|
34
|
+
|
35
|
+
* hash_revert : Reverse keys and values
|
36
|
+
|
33
37
|
### File
|
34
38
|
|
35
39
|
* self.blank? and blank? : Is file empty?
|
@@ -41,6 +45,10 @@ PathString:
|
|
41
45
|
* up lv : Go up some directory levels, prefixing with a number of '../'
|
42
46
|
* down lv : Go down some directory levels, stripping off a number of prefixed '../'
|
43
47
|
|
48
|
+
### Includes
|
49
|
+
|
50
|
+
* includes : Includes modules listed as symbols
|
51
|
+
|
44
52
|
### Kind of
|
45
53
|
|
46
54
|
* any_kind_of? *const_list
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/sugar-high/alias.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sugar-high/methods'
|
2
|
+
require 'sugar-high/hash'
|
2
3
|
|
3
4
|
class Module
|
4
5
|
|
@@ -30,6 +31,9 @@ class Module
|
|
30
31
|
|
31
32
|
options.delete(:_after_)
|
32
33
|
options.delete(:_before_)
|
34
|
+
direction = options.delete(:_direction_)
|
35
|
+
|
36
|
+
options = options.hash_revert if direction == :reverse
|
33
37
|
|
34
38
|
options.each_pair do |original, aliases|
|
35
39
|
alias_methods name.to_sym, original, [aliases].flatten, config_options
|
@@ -40,10 +44,10 @@ class Module
|
|
40
44
|
aliases.each do |alias_name|
|
41
45
|
new_alias = make_name(name, alias_name.to_s, config_options)
|
42
46
|
original_name = make_name(name, original.to_s, config_options)
|
43
|
-
begin
|
47
|
+
begin
|
44
48
|
alias_method new_alias, original_name
|
45
49
|
rescue
|
46
|
-
raise ArgumentError, "Error
|
50
|
+
raise ArgumentError, "Error creating alias for ##{original_name} with ##{new_alias}"
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -28,23 +28,46 @@ class Ged
|
|
28
28
|
'hejsa'
|
29
29
|
end
|
30
30
|
|
31
|
-
multi_alias :_before_ => :kristian, :hello => :
|
31
|
+
multi_alias :_before_ => :kristian, :hejsa => :hello, :_direction_ => :reverse
|
32
32
|
end
|
33
33
|
|
34
|
+
class Wow
|
35
|
+
REGISTRATION_LINKS = {
|
36
|
+
:new_registration => :sign_up,
|
37
|
+
:edit_registration => :edit_profile
|
38
|
+
}
|
39
|
+
|
40
|
+
# new_registration_link, edit_registration_link
|
41
|
+
REGISTRATION_LINKS.keys.each do |name|
|
42
|
+
puts "name: #{name}"
|
43
|
+
class_eval %{
|
44
|
+
def #{name}_link
|
45
|
+
end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
multi_alias REGISTRATION_LINKS.merge(:_after_ => :link)
|
49
|
+
end
|
50
|
+
|
34
51
|
describe "SugarHigh" do
|
35
52
|
describe "Arguments" do
|
36
|
-
context '
|
53
|
+
context 'should alias :hello_kristian with :howdy_kristian ' do
|
37
54
|
it "should find alias" do
|
38
55
|
Abc.new.respond_to?(:howdy_kristian).should be_true
|
39
56
|
end
|
57
|
+
end
|
40
58
|
|
41
|
-
|
42
|
-
|
43
|
-
|
59
|
+
it "should find -alloha alias method for kristian" do
|
60
|
+
Xyz.new.respond_to?(:alloha_kristian).should be_true
|
61
|
+
end
|
44
62
|
|
45
|
-
|
46
|
-
|
47
|
-
|
63
|
+
it "should find -hejsa alias method for kristian" do
|
64
|
+
Ged.new.respond_to?(:kristian_hejsa).should be_true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should find alias methods!" do
|
68
|
+
w = Wow.new
|
69
|
+
w.respond_to?(:new_registration_link).should be_true
|
70
|
+
w.respond_to?(:sign_up_link).should be_true
|
48
71
|
end
|
49
72
|
end
|
50
73
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sugar-high/includes'
|
3
|
+
|
4
|
+
module Simple
|
5
|
+
module X
|
6
|
+
def x
|
7
|
+
'x'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Y
|
12
|
+
def y
|
13
|
+
'y'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
includes :x, :y
|
18
|
+
end
|
19
|
+
|
20
|
+
class Xman
|
21
|
+
include Simple
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "SugarHigh" do
|
25
|
+
describe "Includes ext" do
|
26
|
+
describe '#includes' do
|
27
|
+
it "should include namespaces X and Y" do
|
28
|
+
Xman.new.respond_to?(:x).should be_true
|
29
|
+
Xman.new.respond_to?(:y).should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/sugar-high.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sugar-high}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-25}
|
13
13
|
s.description = %q{More Ruby sugar - inspired by the 'zuker' project}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/sugar-high/alias.rb",
|
29
29
|
"lib/sugar-high/arguments.rb",
|
30
30
|
"lib/sugar-high/file.rb",
|
31
|
+
"lib/sugar-high/hash.rb",
|
32
|
+
"lib/sugar-high/includes.rb",
|
31
33
|
"lib/sugar-high/kind_of.rb",
|
32
34
|
"lib/sugar-high/matchers/have_aliases.rb",
|
33
35
|
"lib/sugar-high/metaclass.rb",
|
@@ -41,6 +43,7 @@ Gem::Specification.new do |s|
|
|
41
43
|
"spec/sugar-high/alias_spec.rb",
|
42
44
|
"spec/sugar-high/arguments_spec.rb",
|
43
45
|
"spec/sugar-high/file_spec.rb",
|
46
|
+
"spec/sugar-high/includes_spec.rb",
|
44
47
|
"spec/sugar-high/kind_of_spec.rb",
|
45
48
|
"spec/sugar-high/methods_spec.rb",
|
46
49
|
"spec/sugar-high/module_spec.rb",
|
@@ -56,6 +59,7 @@ Gem::Specification.new do |s|
|
|
56
59
|
"spec/sugar-high/alias_spec.rb",
|
57
60
|
"spec/sugar-high/arguments_spec.rb",
|
58
61
|
"spec/sugar-high/file_spec.rb",
|
62
|
+
"spec/sugar-high/includes_spec.rb",
|
59
63
|
"spec/sugar-high/kind_of_spec.rb",
|
60
64
|
"spec/sugar-high/methods_spec.rb",
|
61
65
|
"spec/sugar-high/module_spec.rb"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-25 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,8 @@ files:
|
|
55
55
|
- lib/sugar-high/alias.rb
|
56
56
|
- lib/sugar-high/arguments.rb
|
57
57
|
- lib/sugar-high/file.rb
|
58
|
+
- lib/sugar-high/hash.rb
|
59
|
+
- lib/sugar-high/includes.rb
|
58
60
|
- lib/sugar-high/kind_of.rb
|
59
61
|
- lib/sugar-high/matchers/have_aliases.rb
|
60
62
|
- lib/sugar-high/metaclass.rb
|
@@ -68,6 +70,7 @@ files:
|
|
68
70
|
- spec/sugar-high/alias_spec.rb
|
69
71
|
- spec/sugar-high/arguments_spec.rb
|
70
72
|
- spec/sugar-high/file_spec.rb
|
73
|
+
- spec/sugar-high/includes_spec.rb
|
71
74
|
- spec/sugar-high/kind_of_spec.rb
|
72
75
|
- spec/sugar-high/methods_spec.rb
|
73
76
|
- spec/sugar-high/module_spec.rb
|
@@ -109,6 +112,7 @@ test_files:
|
|
109
112
|
- spec/sugar-high/alias_spec.rb
|
110
113
|
- spec/sugar-high/arguments_spec.rb
|
111
114
|
- spec/sugar-high/file_spec.rb
|
115
|
+
- spec/sugar-high/includes_spec.rb
|
112
116
|
- spec/sugar-high/kind_of_spec.rb
|
113
117
|
- spec/sugar-high/methods_spec.rb
|
114
118
|
- spec/sugar-high/module_spec.rb
|