keyword_arguments 0.0.2 → 0.1.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/ChangeLog ADDED
@@ -0,0 +1,25 @@
1
+ 2009-10-31 Dominik Honnef <dominikho@gmx.net>
2
+
3
+ * test/*: replaced test/unit with baretest
4
+
5
+ * README.markdown: updated README to reflect recent changes
6
+
7
+ * lib/keyword_arguments.rb (Module#define_our_temporary_method_added): default arguments are now evaluated blocks
8
+ (Module#default_arguments): same
9
+
10
+ * Rakefile: fixed gem description
11
+ replaced Echoe with own gemspec
12
+ bumped version to 0.1.0
13
+
14
+ * CHANGELOG: replaced by ChangeLog
15
+
16
+ 2009-07-27 Dominik Honnef <dominikho@gmx.net>
17
+
18
+ * lib/keyword_arguments: hiding keyword_arguments from the backtrace
19
+ avoid warnings
20
+
21
+ * CHANGELOG: bumped version to 0.0.2
22
+
23
+ 2009-07-24 Dominik Honnef <dominikho@gmx.net>
24
+
25
+ * *: initial release of version 0.0.1
data/README.markdown CHANGED
@@ -7,7 +7,6 @@ Module, which make working with argument hashes in Ruby a bit easier.
7
7
 
8
8
  - This only works with Ruby 1.9. This, however, is as far as I know no
9
9
  big problem because there is also a gem for Ruby 1.8...
10
- - The tests require mocha to run
11
10
 
12
11
  ## Installation
13
12
 
@@ -19,7 +18,7 @@ Module, which make working with argument hashes in Ruby a bit easier.
19
18
  require 'keyword_arguments'
20
19
 
21
20
  class Test
22
- default_arguments a: 1, b: 2, c: 3
21
+ default_arguments {{a: 1, b: 2, c: 3}}
23
22
  def laissez_faire(args = {})
24
23
  args
25
24
  end
@@ -54,7 +53,12 @@ modules and included modules.
54
53
 
55
54
  ## Special notes
56
55
 
57
- You shouldn't redefine any of the *_arguments methods
58
- (as in `class Test; def self.default_arguments; nil; end; end`)
59
- because then you won't be able to use the ones from our package
60
- unless you use `::Module.default_arguments`
56
+ * You shouldn't redefine any of the \*\_arguments methods
57
+ (as in
58
+
59
+ class Test; def self.default_arguments; nil; end; end
60
+
61
+ because then you won't be able to use the ones from our package
62
+ unless you use `::Module.default_arguments`
63
+
64
+ * default arguments are to be passed as blocks returning hashes.
data/Rakefile CHANGED
@@ -1,17 +1,52 @@
1
- require 'echoe'
2
- Echoe.new('keyword_arguments') do |p|
3
- p.author = "Dominik Honnef"
4
- p.email = "dominikho@gmx.net"
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
5
3
 
6
- p.description = %q{named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull}
7
- p.summary = %q{named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull}
4
+ VERSION = "0.1.0"
8
5
 
9
- p.url = "http://keywordargs.rubyforge.org/"
10
- p.docs_host = "rubyforge.org:/var/www/gforge-projects/"
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = "keyword_arguments"
8
+ s.summary = 'keyword_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull'
9
+ s.description = s.summary
10
+ s.version = VERSION
11
+ s.author = "Dominik Honnef"
12
+ s.email = "dominikho@gmx.net"
13
+ s.date = Time.now.strftime "%Y-%m-%d"
14
+ s.require_path = "lib"
15
+ s.homepage = "http://keywordargs.rubyforge.org/"
16
+ s.rubyforge_project = "keywordargs"
11
17
 
12
- p.ruby_version = '>= 1.9.0'
18
+ s.has_rdoc = 'yard'
13
19
 
14
- p.require_signed = true
20
+ s.required_ruby_version = '>= 1.9.1'
15
21
 
16
- p.project = 'keywordargs'
22
+ s.add_development_dependency "baretest"
23
+
24
+ s.files = FileList["bin/*", "lib/**/*.rb", "[A-Z]*", "examples/**/*"].to_a
25
+ s.executables = [""]
26
+ end
27
+
28
+ Rake::GemPackageTask.new(spec)do |pkg|
29
+ end
30
+
31
+ begin
32
+ require 'yard'
33
+ YARD::Rake::YardocTask.new do |t|
34
+ end
35
+ rescue LoadError
36
+ end
37
+
38
+ task :test do
39
+ begin
40
+ require "baretest"
41
+ rescue LoadError => e
42
+ puts "Could not run tests: #{e}"
43
+ end
44
+
45
+ BareTest.load_standard_test_files(
46
+ :verbose => false,
47
+ :setup_file => 'test/setup.rb',
48
+ :chdir => File.absolute_path("#{__FILE__}/../")
49
+ )
50
+
51
+ BareTest.run(:format => "cli", :interactive => false)
17
52
  end
@@ -8,8 +8,8 @@ class Module
8
8
  end
9
9
 
10
10
  # Sets default arguments for the next method defined
11
- def default_arguments(args = { })
12
- @current_default_arguments = args
11
+ def default_arguments(&block)
12
+ @current_default_arguments = block
13
13
  define_our_temporary_method_added
14
14
  end
15
15
 
@@ -40,7 +40,7 @@ class Module
40
40
 
41
41
  # store the instance variables in local ones so we can use them in the following blocks
42
42
  current_required_arguments = @current_required_arguments || []
43
- current_default_arguments = @current_default_arguments || Hash.new
43
+ current_default_arguments = @current_default_arguments || lambda {{}}
44
44
  current_allowed_arguments = @current_allowed_arguments || []
45
45
 
46
46
  # methods and singleton methods have other means of being get/defined
@@ -65,7 +65,7 @@ class Module
65
65
  end
66
66
 
67
67
  # check for missing keys
68
- args = current_default_arguments.merge args
68
+ args = current_default_arguments.call.merge args
69
69
  missing = current_required_arguments - args.keys
70
70
  unless missing.empty?
71
71
  raise ArgumentError, "Missing arguments: #{missing.join(', ')}", caller
metadata CHANGED
@@ -1,89 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keyword_arguments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Honnef
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MRIwEAYDVQQDDAlkb21p
14
- bmlraG8xEzARBgoJkiaJk/IsZAEZFgNnbXgxEzARBgoJkiaJk/IsZAEZFgNuZXQw
15
- HhcNMDkwNzI0MjE1NDQ3WhcNMTAwNzI0MjE1NDQ3WjA+MRIwEAYDVQQDDAlkb21p
16
- bmlraG8xEzARBgoJkiaJk/IsZAEZFgNnbXgxEzARBgoJkiaJk/IsZAEZFgNuZXQw
17
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCgfogFNoAcdrR5mK0t5NiN
18
- MbWCH2QVLqOvpuaHN6uiaE30R9fT+1CcF97PSboMHMKaQFgiyAcBj8c2uGw5Sk7+
19
- Kv9TE2TIIG8l8oslnf9PVqrHSz823IjzbXo4WET4khI2v02pE2wx/souJ4PRgnEr
20
- gxQaOF7fqJRT2eYiZAMQye1y9tNSShRoKP3JIlp51KBXUMzGdzq4Mopp32zhEcio
21
- yEzcp1PYqu6D1Pr00fS/Alurnp/My5o3oIk0vBfJ6Q8j/6OSk+ck5xev2Z2Y9AUK
22
- iwipCxKrAsfOjpPc/Y66okMeTmKxx5N/8h/xNp/HiUApHQwjbYgFOAwmht5UzoPp
23
- AgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFLlluBMEZ3rFvxFcB+ULjUNd
24
- V+7WMAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAoDJGicQwBqMnhMkC
25
- JY7bgsrIwxoTMQT6B1keUtt9VQ3deywQu0ogawNmee5wy5oFqnMZFcSCXcJE/zIE
26
- iuSYU5t87iF09BIsSHWg2OlHAB4+GTUL0PkVsCVBDFukqEiXpNcqMUjTr8U+fe7V
27
- oD/qvzyMG1ooAFuTDfPknIQxTcavdnmUmO9Sfw10yXkomX8jjwaGduF/JHDIufub
28
- /f4b22rpLBhrOD6dqHCl7WuAfAhpobLqc7sa6Ro8caSUnpq9blOrT/PRtiTXwN6h
29
- p3eI3JV0LC6/tMHoeLAbHqauVbWUqDB+AfFw24sgZBqFA+MtMkDpqZ+BKiwiHl+S
30
- YEfDWg==
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- date: 2009-07-28 00:00:00 +02:00
12
+ date: 2009-11-01 00:00:00 +01:00
34
13
  default_executable:
35
- dependencies: []
36
-
37
- description: named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: baretest
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: keyword_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull
38
26
  email: dominikho@gmx.net
39
27
  executables: []
40
28
 
41
29
  extensions: []
42
30
 
43
- extra_rdoc_files:
44
- - README.markdown
45
- - CHANGELOG
46
- - LICENSE
47
- - lib/keyword_arguments.rb
31
+ extra_rdoc_files: []
32
+
48
33
  files:
34
+ - lib/keyword_arguments.rb
49
35
  - Rakefile
36
+ - ChangeLog
50
37
  - README.markdown
51
- - CHANGELOG
52
38
  - LICENSE
53
- - test/test_module.rb
54
- - Manifest
55
- - lib/keyword_arguments.rb
56
- - keyword_arguments.gemspec
57
- has_rdoc: true
39
+ has_rdoc: yard
58
40
  homepage: http://keywordargs.rubyforge.org/
41
+ licenses: []
42
+
59
43
  post_install_message:
60
- rdoc_options:
61
- - --line-numbers
62
- - --inline-source
63
- - --title
64
- - Keyword_arguments
65
- - --main
66
- - README.markdown
44
+ rdoc_options: []
45
+
67
46
  require_paths:
68
47
  - lib
69
48
  required_ruby_version: !ruby/object:Gem::Requirement
70
49
  requirements:
71
50
  - - ">="
72
51
  - !ruby/object:Gem::Version
73
- version: 1.9.0
52
+ version: 1.9.1
74
53
  version:
75
54
  required_rubygems_version: !ruby/object:Gem::Requirement
76
55
  requirements:
77
56
  - - ">="
78
57
  - !ruby/object:Gem::Version
79
- version: "1.2"
58
+ version: "0"
80
59
  version:
81
60
  requirements: []
82
61
 
83
62
  rubyforge_project: keywordargs
84
- rubygems_version: 1.3.1
63
+ rubygems_version: 1.3.5
85
64
  signing_key:
86
- specification_version: 2
87
- summary: named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull
88
- test_files:
89
- - test/test_module.rb
65
+ specification_version: 3
66
+ summary: keyword_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull
67
+ test_files: []
68
+
data.tar.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- &4�_��>�My>��r'�|!k��r���\X��������ҮiFa�/��� ��E+�m���Z>X�� ����2��_�/�tq, ƅ߉
2
- r�>ն�'�7�w�P�Ľ,& �+a3ć2����>-ʩv���%�r�}�W����]������A��H��Aq۲Wey�m�L5;�
3
- 0)q�x$����W�<��}ĵ�{O�A���4��|JB�6U��>�ᕙj�b&��ś���8�* �%e��[�;�YB���
data/CHANGELOG DELETED
@@ -1,5 +0,0 @@
1
- v0.0.2.
2
- - hiding keyword_arguments from the backtrace
3
- - no more warnings
4
-
5
- v0.0.1. first version. enjoy!
data/Manifest DELETED
@@ -1,7 +0,0 @@
1
- Rakefile
2
- README.markdown
3
- CHANGELOG
4
- LICENSE
5
- test/test_module.rb
6
- Manifest
7
- lib/keyword_arguments.rb
@@ -1,35 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{keyword_arguments}
5
- s.version = "0.0.2"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Dominik Honnef"]
9
- s.cert_chain = ["/home/dominikh/.rubyforge/gem-public_cert.pem"]
10
- s.date = %q{2009-07-28}
11
- s.description = %q{named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull}
12
- s.email = %q{dominikho@gmx.net}
13
- s.extra_rdoc_files = ["README.markdown", "CHANGELOG", "LICENSE", "lib/keyword_arguments.rb"]
14
- s.files = ["Rakefile", "README.markdown", "CHANGELOG", "LICENSE", "test/test_module.rb", "Manifest", "lib/keyword_arguments.rb", "keyword_arguments.gemspec"]
15
- s.has_rdoc = true
16
- s.homepage = %q{http://keywordargs.rubyforge.org/}
17
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Keyword_arguments", "--main", "README.markdown"]
18
- s.require_paths = ["lib"]
19
- s.required_ruby_version = Gem::Requirement.new(">= 1.9.0")
20
- s.rubyforge_project = %q{keywordargs}
21
- s.rubygems_version = %q{1.3.1}
22
- s.signing_key = %q{/home/dominikh/.rubyforge/gem-private_key.pem}
23
- s.summary = %q{named_arguments comes with a bunch of convenient methods for making "named arguments" (hashes as method arguments) in Ruby less painfull}
24
- s.test_files = ["test/test_module.rb"]
25
-
26
- if s.respond_to? :specification_version then
27
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
28
- s.specification_version = 2
29
-
30
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
31
- else
32
- end
33
- else
34
- end
35
- end
data/test/test_module.rb DELETED
@@ -1,97 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'test/unit/testcase'
4
- require 'test/unit' if $0 == __FILE__
5
- require 'mocha'
6
-
7
- require 'keyword_arguments.rb'
8
-
9
- class MixedMethodsTest
10
- required_arguments :test, :test2
11
- default_arguments test: 1
12
- def foo(args = { })
13
- args
14
- end
15
-
16
- def bar(var)
17
- var
18
- end
19
-
20
- def fisk(args = { })
21
- args
22
- end
23
-
24
- default_arguments key: 'value'
25
- def meow(args = { })
26
- args
27
- end
28
-
29
- default_arguments whatever: 'hi'
30
- def self.blubb(args = { })
31
- args
32
- end
33
-
34
- allowed_arguments :key1, :key2
35
- def limited(args = { })
36
- args
37
- end
38
- end
39
-
40
- class TestModule < Test::Unit::TestCase
41
- def setup
42
- @m = MixedMethodsTest.new
43
- end
44
-
45
- def test_default_arguments
46
- h = Hash.new
47
- h[:test] = 1
48
- h[:test2] = 2
49
- assert_equal h, @m.foo(:test2 => 2)
50
-
51
- h = Hash.new
52
- h[:test] = 3
53
- h[:test2] = 2
54
- assert_equal h, @m.foo(:test => 3, :test2 => 2)
55
- end
56
-
57
- def test_required_arguments
58
- assert_raises(ArgumentError) { @m.foo }
59
- end
60
-
61
- def test_normal_methods
62
- h = Hash.new
63
- h[:nothing] = nil
64
- assert_equal 1, @m.bar(1)
65
- assert_equal h, @m.fisk(:nothing => nil)
66
- end
67
-
68
- def test_chained_default_arguments
69
- h = Hash.new
70
- h[:test] = 1
71
- h[:test2] = 2
72
- assert_equal h, @m.foo(:test2 => 2)
73
-
74
- h = Hash.new
75
- h[:key] = 'value'
76
- assert_equal h, @m.meow
77
- end
78
-
79
- def test_singleton_method
80
- h = Hash.new
81
- h[:whatever] = 'hi'
82
- assert_equal h, MixedMethodsTest.blubb
83
- end
84
-
85
- def test_allowed_arguments
86
- h = Hash.new
87
- h[:key1] = 1
88
- assert_equal h, @m.limited(:key1 => 1)
89
-
90
- h = Hash.new
91
- h[:key1] = 1
92
- h[:key2] = 2
93
- assert_equal h, @m.limited(:key1 => 1, :key2 => 2)
94
-
95
- assert_raises(ArgumentError) { @m.limited(:key1 => 1, :key2 => 2, :key3 => 3) }
96
- end
97
- end
metadata.gz.sig DELETED
Binary file