yard-parameters 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ doc
2
+ pkg
3
+ tmp/*
4
+ .DS_Store
5
+ .yardoc
6
+ *.db
7
+ *.log
8
+ *.swp
9
+ *~
data/.specopts ADDED
@@ -0,0 +1 @@
1
+ --colour --format specdoc
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title 'YARD Parameters Documentation' --protected --files ChangeLog.md,LICENSE.txt
data/ChangeLog.md ADDED
@@ -0,0 +1,5 @@
1
+ ### 0.1.0 / 2010-02-18
2
+
3
+ * Initial release:
4
+ * Parses `parameter :name` methods.
5
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+
2
+ Copyright (c) 2010 Hal Brodigan
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # yard-parameters
2
+
3
+ * [github.com/postmodern/yard-parameters](http://github.com/postmodern/yard-parameters)
4
+ * [github.com/postmodern/yard-parameters/issues](http://github.com/postmodern/yard-parameters/issues)
5
+
6
+ ## Description
7
+
8
+ yard-parameters is a plugin for YARD for parsing
9
+ [parameters](http://parameters.rubyforge.org).
10
+
11
+ ## Features
12
+
13
+ * Parses `parameter :name` class method-calls.
14
+
15
+ ## Requirements
16
+
17
+ * [yard](http://yardoc.org/) >= 0.4.0
18
+
19
+ ## Install
20
+
21
+ $ sudo gem install yard-parameters
22
+
23
+ ## Note on Patches/Pull Requests
24
+
25
+ * Fork the project.
26
+ * Make your feature addition or bug fix.
27
+ * Add tests for it. This is important so I don't break it in a
28
+ future version unintentionally.
29
+ * Commit, do not mess with rakefile, version, or history.
30
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
31
+ * Send me a pull request. Bonus points for topic branches.
32
+
33
+ ## Copyright
34
+
35
+ See {file:LICENSE.txt} for license information.
36
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "yard-parameters"
8
+ gem.summary = %Q{A plugin for YARD for parsing parameters.}
9
+ gem.description = %Q{yard-parameters is a plugin for YARD for parsing parameters.}
10
+ gem.email = "postmodern.mod3@gmail.com"
11
+ gem.homepage = "http://github.com/postmodern/yard-parameters"
12
+ gem.authors = ["postmodern"]
13
+ gem.add_dependency "yard", ">= 0.4.0"
14
+ gem.add_development_dependency "rspec", ">= 1.3.0"
15
+ gem.has_rdoc = 'yard'
16
+ end
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs += ['lib', 'spec']
24
+ spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ spec.spec_opts = ['--options', '.specopts']
26
+ end
27
+
28
+ task :spec => :check_dependencies
29
+ task :default => :spec
30
+
31
+ begin
32
+ require 'yard'
33
+ YARD::Rake::YardocTask.new
34
+ rescue LoadError
35
+ task :yard do
36
+ abort "YARD is not available. In order to run yard, you must: gem install yard"
37
+ end
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,45 @@
1
+ require 'yard'
2
+
3
+ module YARD
4
+ module Parameters
5
+ module Legacy
6
+ class ParameterHandler < YARD::Handlers::Ruby::Legacy::Base
7
+
8
+ handles /\Aparameter\s+:/
9
+
10
+ def process
11
+ nobj = namespace
12
+ mscope = scope
13
+ name = statement.tokens[2,1].to_s[1..-1]
14
+
15
+ register MethodObject.new(nobj, name, :class) do |o|
16
+ o.visibility = :public
17
+ o.source = statement.source
18
+ o.signature = "def #{nobj}.#{name}"
19
+ end
20
+
21
+ register MethodObject.new(nobj, "#{name}=", :class) do |o|
22
+ o.visibility = :public
23
+ o.source = statement.source
24
+ o.signature = "def #{nobj}.#{name}=(value)"
25
+ o.parameters = [['value', nil]]
26
+ end
27
+
28
+ register MethodObject.new(nobj, name, mscope) do |o|
29
+ o.visibility = :public
30
+ o.source = statement.source
31
+ o.signature = "def #{name}"
32
+ end
33
+
34
+ register MethodObject.new(nobj, "#{name}=", mscope) do |o|
35
+ o.visibility = :public
36
+ o.source = statement.source
37
+ o.signature = "def #{name}=(value)"
38
+ o.parameters = [['value', nil]]
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1 @@
1
+ require 'yard-parameters/legacy/parameter_handler'
@@ -0,0 +1,47 @@
1
+ require 'yard'
2
+
3
+ module YARD
4
+ module Parameters
5
+ class ParameterHandler < YARD::Handlers::Ruby::Base
6
+
7
+ handles method_call(:parameter)
8
+
9
+ def process
10
+ nobj = namespace
11
+ mscope = scope
12
+ name = statement.parameters[0].first
13
+
14
+ if name.type == :symbol
15
+ name = name.source[1..-1]
16
+
17
+ register MethodObject.new(nobj, name, :class) do |o|
18
+ o.visibility = :public
19
+ o.source = statement.source
20
+ o.signature = "def #{nobj}.#{name}"
21
+ end
22
+
23
+ register MethodObject.new(nobj, "#{name}=", :class) do |o|
24
+ o.visibility = :public
25
+ o.source = statement.source
26
+ o.signature = "def #{nobj}.#{name}=(value)"
27
+ o.parameters = [['value', nil]]
28
+ end
29
+
30
+ register MethodObject.new(nobj, name, mscope) do |o|
31
+ o.visibility = :public
32
+ o.source = statement.source
33
+ o.signature = "def #{name}"
34
+ end
35
+
36
+ register MethodObject.new(nobj, "#{name}=", mscope) do |o|
37
+ o.visibility = :public
38
+ o.source = statement.source
39
+ o.signature = "def #{name}=(value)"
40
+ o.parameters = [['value', nil]]
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,2 @@
1
+ require 'yard-parameters/parameter_handler'
2
+ require 'yard-parameters/legacy'
@@ -0,0 +1,5 @@
1
+ class BadParameter
2
+
3
+ parameter = parameter.to_s.to_sym
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class SimpleParameter
2
+
3
+ include Parameters
4
+
5
+ parameter :x
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'yard'
2
+
3
+ module Helpers
4
+ module Examples
5
+ EXAMPLES_DIR = File.expand_path(File.join(File.dirname(__FILE__),'examples'))
6
+
7
+ def parse_file(file, thisfile = __FILE__)
8
+ YARD::Registry.clear
9
+
10
+ path = File.join(Helpers::Examples::EXAMPLES_DIR, "#{file}.rb.txt")
11
+ YARD::Parser::SourceParser.parse(path)
12
+ end
13
+
14
+ def yard(name)
15
+ YARD::Registry.at(name)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'helpers/examples'
3
+
4
+ require 'yard-parameters/parameter_handler'
5
+ require 'yard-parameters/legacy/parameter_handler'
6
+
7
+ describe "ParameterHandler" do
8
+ include Helpers::Examples
9
+
10
+ describe "valid" do
11
+ before(:all) do
12
+ parse_file :simple_parameter
13
+ end
14
+
15
+ it "should register a class reader method for the parameter" do
16
+ yard('SimpleParameter.x').should be_instance_of(CodeObjects::MethodObject)
17
+ end
18
+
19
+ it "should register a class writer method for the parameter" do
20
+ yard('SimpleParameter.x=').should be_instance_of(CodeObjects::MethodObject)
21
+ end
22
+
23
+ it "should register a instance reader method for the parameter" do
24
+ yard('SimpleParameter#x').should be_instance_of(CodeObjects::MethodObject)
25
+ end
26
+
27
+ it "should register a instance writer method for the parameter" do
28
+ yard('SimpleParameter#x=').should be_instance_of(CodeObjects::MethodObject)
29
+ end
30
+ end
31
+
32
+ describe "invalid" do
33
+ before(:all) do
34
+ parse_file :bad_parameter
35
+ end
36
+
37
+ it "should not register class reader methods for variables" do
38
+ yard('BadParameter.x').should be_nil
39
+ end
40
+
41
+ it "should not register class writer methods for variables" do
42
+ yard('BadParameter.x=').should be_nil
43
+ end
44
+
45
+ it "should not register instance reader methods for variables" do
46
+ yard('BadParameter#x').should be_nil
47
+ end
48
+
49
+ it "should not register instance writer methods for variables" do
50
+ yard('BadParameter#x=').should be_nil
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ gem 'rspec', '>=1.3.0'
3
+ require 'spec'
4
+
5
+ gem 'yard', '>=0.4.0'
6
+ require 'yard'
7
+
8
+ include YARD
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{yard-parameters}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["postmodern"]
12
+ s.date = %q{2010-02-18}
13
+ s.description = %q{yard-parameters is a plugin for YARD for parsing parameters.}
14
+ s.email = %q{postmodern.mod3@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "ChangeLog.md",
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ ".specopts",
24
+ ".yardopts",
25
+ "ChangeLog.md",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/yard-parameters.rb",
31
+ "lib/yard-parameters/legacy.rb",
32
+ "lib/yard-parameters/legacy/parameter_handler.rb",
33
+ "lib/yard-parameters/parameter_handler.rb",
34
+ "spec/helpers/examples.rb",
35
+ "spec/helpers/examples/bad_parameter.rb.txt",
36
+ "spec/helpers/examples/simple_parameter.rb.txt",
37
+ "spec/parameter_handler_spec.rb",
38
+ "spec/spec_helper.rb",
39
+ "yard-parameters.gemspec"
40
+ ]
41
+ s.has_rdoc = %q{yard}
42
+ s.homepage = %q{http://github.com/postmodern/yard-parameters}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.5}
46
+ s.summary = %q{A plugin for YARD for parsing parameters.}
47
+ s.test_files = [
48
+ "spec/spec_helper.rb",
49
+ "spec/helpers/examples.rb",
50
+ "spec/parameter_handler_spec.rb"
51
+ ]
52
+
53
+ if s.respond_to? :specification_version then
54
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ s.add_runtime_dependency(%q<yard>, [">= 0.4.0"])
59
+ s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
60
+ else
61
+ s.add_dependency(%q<yard>, [">= 0.4.0"])
62
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<yard>, [">= 0.4.0"])
66
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
67
+ end
68
+ end
69
+
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-parameters
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - postmodern
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-18 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: yard
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ version:
35
+ description: yard-parameters is a plugin for YARD for parsing parameters.
36
+ email: postmodern.mod3@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - ChangeLog.md
43
+ - LICENSE.txt
44
+ - README.md
45
+ files:
46
+ - .document
47
+ - .gitignore
48
+ - .specopts
49
+ - .yardopts
50
+ - ChangeLog.md
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - VERSION
55
+ - lib/yard-parameters.rb
56
+ - lib/yard-parameters/legacy.rb
57
+ - lib/yard-parameters/legacy/parameter_handler.rb
58
+ - lib/yard-parameters/parameter_handler.rb
59
+ - spec/helpers/examples.rb
60
+ - spec/helpers/examples/bad_parameter.rb.txt
61
+ - spec/helpers/examples/simple_parameter.rb.txt
62
+ - spec/parameter_handler_spec.rb
63
+ - spec/spec_helper.rb
64
+ - yard-parameters.gemspec
65
+ has_rdoc: yard
66
+ homepage: http://github.com/postmodern/yard-parameters
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --charset=UTF-8
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: A plugin for YARD for parsing parameters.
93
+ test_files:
94
+ - spec/spec_helper.rb
95
+ - spec/helpers/examples.rb
96
+ - spec/parameter_handler_spec.rb