named_parameters 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -94,6 +94,8 @@ Kudos to Juris Galang and his gem named-parameters. (http://www.rubygems.org/gem
94
94
  Defenitely have a look at this gem also, if you want to use named parameters.
95
95
 
96
96
  == Changelog
97
- [0.1.2] Changed headings in documentation
98
- [0.1.1] Added documentation for blocks
99
- [0.1.0] First release
97
+ [0.1.3] * Made LICENSE visible to documentation (Sorry for that)
98
+ * Made actual name space and NamedParameters#named_parameters macro visible to documentation
99
+ [0.1.2] * Changed headings in documentation
100
+ [0.1.1] * Added documentation for blocks
101
+ [0.1.0] * First release
@@ -12,9 +12,9 @@ end
12
12
  #
13
13
  module NamedParameters
14
14
 
15
- # :nodoc:
15
+
16
16
  # Makes all methods of this module to class or module methods of include
17
- def self.included base
17
+ def self.included base #:nodoc:
18
18
  base.extend(self)
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ module NamedParameters
27
27
 
28
28
  # @param defaults [Hash] Containing defaults values for optional parameters.
29
29
  # Parameters that are not listet here are mandatory.
30
- def named_parameters defaults = { }
30
+ def named_parameters (defaults = { })
31
31
  defaults.empty? ? all_required : some_defaults(defaults)
32
32
  end
33
33
 
@@ -40,7 +40,7 @@ module NamedParameters
40
40
  @@next_method_modifier = :all_required
41
41
  end
42
42
 
43
- def some_defaults defaults
43
+ def some_defaults (defaults)
44
44
  @@next_method_modifier = :defaults
45
45
  @@defaults = defaults
46
46
  end
@@ -62,13 +62,13 @@ module NamedParameters
62
62
 
63
63
  # @param method_name [Symbol]
64
64
  # @return [Object] Not important
65
- def redefine_all_required_method(method_name,&block)
65
+ def redefine_all_required_method(method_name, &block)
66
66
  method = instance_method method_name
67
67
  parameter_definition = method.parameters.collect { |_, b| b }
68
68
  old_name = (method_name.to_s+"_before_named_parameters").to_sym
69
69
  alias_method old_name, method_name
70
70
  module_eval do
71
- define_method method_name do |options,&block|
71
+ define_method method_name do |options, &block|
72
72
  missing = parameter_definition-(options.keys)
73
73
  unless missing.empty?
74
74
  raise RuntimeError.new("Missing arguments: #{missing}")
@@ -102,7 +102,7 @@ but it is not a parameter of #{method_name}") unless parameter_definition.includ
102
102
  old_name = (method_name.to_s+"_before_named_parameters").to_sym
103
103
  alias_method old_name, method_name
104
104
  module_eval do
105
- define_method method_name do |options = { },&block|
105
+ define_method method_name do |options = { }, &block|
106
106
  unexpected = options.keys - parameter_definition
107
107
  unless unexpected.empty?
108
108
  raise RuntimeError.new("Unexpected arguments: #{unexpected}")
@@ -7,7 +7,7 @@ class Book
7
7
 
8
8
  named_parameters
9
9
 
10
- def initialize (author, title, year)
10
+ def initialize(author, title, year)
11
11
  @author = author
12
12
  @title = title
13
13
  @year = year
@@ -26,8 +26,6 @@ class Book
26
26
  end
27
27
 
28
28
  named_parameters(optional: "optional")
29
-
30
- #noinspection RubyInstanceMethodNamingConvention
31
29
  def method_with_defaults_and_mandatory (optional, mandatory)
32
30
  [optional, mandatory]
33
31
  end
@@ -82,7 +80,6 @@ describe Book do
82
80
  code = -> do
83
81
  class Book
84
82
  some_defaults(a: "a", b: "b")
85
-
86
83
  def a_method (a, c)
87
84
  #... do something
88
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: named_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &25091196 !ruby/object:Gem::Requirement
16
+ requirement: &25875492 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: 3.0.0
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *25091196
27
+ version_requirements: *25875492
28
28
  description: ! 'By including the NamedParameters module into your class/module the
29
29
  ''named_parameters'' macro is
30
30
 
@@ -39,7 +39,7 @@ extra_rdoc_files:
39
39
  - README
40
40
  - LICENSE
41
41
  files:
42
- - src/named_parameters.rb
42
+ - lib/named_parameters.rb
43
43
  - README
44
44
  - LICENSE
45
45
  - spec/named_parameters_spec.rb