named_parameter 0.0.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +38 -20
- data/Rakefile +1 -1
- data/named_parameter.gemspec +1 -2
- metadata +5 -6
- data/lib/.named_parameter.rb.swo +0 -0
data/README.md
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
-
# Named Parameter `v0.0.
|
1
|
+
# Named Parameter `v0.0.5`
|
2
2
|
|
3
3
|
## Description
|
4
4
|
That you ever dream with named parameter in Ruby? Well, you doesn't have to pray to
|
5
5
|
Ruby's 2.0 have this, just install this gem and have fun!
|
6
6
|
|
7
|
-
## How
|
7
|
+
## How Install
|
8
|
+
Install the gem:
|
9
|
+
|
10
|
+
gem install named_parameter
|
11
|
+
|
12
|
+
## How use it
|
8
13
|
Just extend the module NamedParameter in your class/module and use the method 'named'
|
9
14
|
before define your method, when you call it, use a hash with parameters name as keys.
|
10
|
-
|
15
|
+
|
16
|
+
### It's just simple and clean:
|
11
17
|
|
12
18
|
require 'rubygems'
|
13
19
|
require 'named_parameter'
|
@@ -22,7 +28,23 @@ See this example:
|
|
22
28
|
|
23
29
|
People.new.say phrase: "Awesome!"
|
24
30
|
|
25
|
-
|
31
|
+
### We can also call named above method definition
|
32
|
+
|
33
|
+
require 'rubygems'
|
34
|
+
require 'named_parameter'
|
35
|
+
|
36
|
+
class People
|
37
|
+
extend NamedParameter
|
38
|
+
|
39
|
+
named
|
40
|
+
def say(phrase)
|
41
|
+
puts "People says: #{phrase}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
People.new.say phrase: "Awesome!"
|
46
|
+
|
47
|
+
### Maybe you want to use optional arguments, no problem!
|
26
48
|
|
27
49
|
require 'rubygems'
|
28
50
|
require 'named_parameter'
|
@@ -37,7 +59,7 @@ Or maybe you want to define an optional parameter, no problem!
|
|
37
59
|
|
38
60
|
People.new.say
|
39
61
|
|
40
|
-
Multiple arguments? Of course!
|
62
|
+
### Multiple arguments? Of course!
|
41
63
|
|
42
64
|
require 'rubygems'
|
43
65
|
require 'named_parameter'
|
@@ -53,7 +75,7 @@ Multiple arguments? Of course!
|
|
53
75
|
Point.new.move_to(y: 30,x: 50)
|
54
76
|
|
55
77
|
|
56
|
-
If you like
|
78
|
+
### If you like singleton classes you will love that:
|
57
79
|
|
58
80
|
require 'rubygems'
|
59
81
|
require 'named_parameter'
|
@@ -69,7 +91,7 @@ If you like sigleton classes you will love that:
|
|
69
91
|
Point.move_to(y: 30,x: 50)
|
70
92
|
|
71
93
|
|
72
|
-
And that feature too:
|
94
|
+
### And that feature too:
|
73
95
|
|
74
96
|
require 'rubygems'
|
75
97
|
require 'named_parameter'
|
@@ -77,23 +99,19 @@ And that feature too:
|
|
77
99
|
class Point
|
78
100
|
extend NamedParameter
|
79
101
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
102
|
+
class << self
|
103
|
+
named def move_to(x,y,z=0)
|
104
|
+
puts "Moving to [#{x},#{y},#{z}]"
|
105
|
+
end
|
106
|
+
end
|
85
107
|
end
|
86
108
|
|
87
109
|
Point.move_to(y: 30,x: 50)
|
88
110
|
|
89
111
|
|
90
|
-
##
|
91
|
-
|
92
|
-
|
112
|
+
## Can I use in production?
|
113
|
+
The answer is: **YES**
|
114
|
+
But you have to know that gem
|
93
115
|
use the [method_added callback](http://ruby-doc.org/core/classes/Module.html#M000460), so if you want to use named parameter
|
94
116
|
and this callback in the same class, you have to use [around alias spell](https://gist.github.com/534772#file_around_alias.rb).
|
95
|
-
|
96
|
-
## How Install
|
97
|
-
Install the gem:
|
98
|
-
|
99
|
-
gem install named_parameter
|
117
|
+
So you can use in production, but be careful using it in classes manipulated by other libraries.
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ require 'rake'
|
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.version = "0.0
|
17
|
+
gem.version = "1.0.0"
|
18
18
|
gem.name = "named_parameter"
|
19
19
|
gem.homepage = "http://github.com/hugolnx/named_parameter"
|
20
20
|
gem.license = "MIT"
|
data/named_parameter.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "named_parameter"
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hugo Roque (a.k.a HugoLnx)"]
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
"Gemfile",
|
20
20
|
"README.md",
|
21
21
|
"Rakefile",
|
22
|
-
"lib/.named_parameter.rb.swo",
|
23
22
|
"lib/named_parameter.rb",
|
24
23
|
"lib/named_parameter/error.rb",
|
25
24
|
"lib/named_parameter/errors.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: named_parameter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-08-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &77836440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77836440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &77835570 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77835570
|
36
36
|
description: Allows named parameter in ruby
|
37
37
|
email: hugolnx@gmail.com
|
38
38
|
executables: []
|
@@ -43,7 +43,6 @@ files:
|
|
43
43
|
- Gemfile
|
44
44
|
- README.md
|
45
45
|
- Rakefile
|
46
|
-
- lib/.named_parameter.rb.swo
|
47
46
|
- lib/named_parameter.rb
|
48
47
|
- lib/named_parameter/error.rb
|
49
48
|
- lib/named_parameter/errors.rb
|
data/lib/.named_parameter.rb.swo
DELETED
Binary file
|