yard-dm-predefined 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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 dm-predefined Documentation' --protected --files ChangeLog.md,LICENSE.txt
data/ChangeLog.md ADDED
@@ -0,0 +1,5 @@
1
+ ### 0.1.0 / 2010-02-20
2
+
3
+ * Initial release:
4
+ * Parses `predefine :name, ...` class-method calls.
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-dm-predefined
2
+
3
+ * [github.com/postmodern/yard-dm-predefined](http://github.com/postmodern/yard-dm-predefined)
4
+ * [github.com/postmodern/yard-dm-predefined/issues](http://github.com/postmodern/yard-dm-predefined/issues)
5
+
6
+ ## Description
7
+
8
+ yard-dm-predefined is a plugin for YARD for parsing
9
+ [dm-predefined](http://dm-predefined.rubyforge.org) methods.
10
+
11
+ ## Features
12
+
13
+ * Parses `predefine :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-dm-predefined
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-dm-predefined"
8
+ gem.summary = %Q{A plugin for YARD for parsing dm-predefined methods.}
9
+ gem.description = %Q{yard-dm-predefined is a plugin for YARD for parsing dm-predefined methods.}
10
+ gem.email = "postmodern.mod3@gmail.com"
11
+ gem.homepage = "http://github.com/postmodern/yard-dm-predefined"
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,2 @@
1
+ require 'yard-dm-predefined/predefine_handler'
2
+ require 'yard-dm-predefined/legacy'
@@ -0,0 +1 @@
1
+ require 'yard-dm-predefined/legacy/predefine_handler'
@@ -0,0 +1,24 @@
1
+ module YARD
2
+ module DM
3
+ module Predefined
4
+ module Legacy
5
+ class PredefineHandler < YARD::Handlers::Ruby::Legacy::Base
6
+
7
+ handles /\Apredefine\s+:/
8
+
9
+ def process
10
+ nobj = namespace
11
+ name = statement.tokens[2,1].to_s[1..-1]
12
+
13
+ register MethodObject.new(nobj, name, :class) do |o|
14
+ o.visibility = :public
15
+ o.source = statement.source
16
+ o.signature = "def #{nobj}.#{name}"
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module YARD
2
+ module DM
3
+ module Predefined
4
+ class PredefineHandler < YARD::Handlers::Ruby::Base
5
+
6
+ handles method_call(:predefine)
7
+
8
+ def process
9
+ nobj = namespace
10
+ name = if statement.type == :predefine
11
+ statement.jump(:ident, :op, :kw, :const).source
12
+ elsif statement.call?
13
+ obj = statement.parameters(false).first
14
+
15
+ case obj.type
16
+ when :symbol_literal
17
+ obj.jump(:ident, :op, :kw, :const).source
18
+ when :string_literal
19
+ obj.jump(:string_content).source
20
+ end
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}"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ 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,11 @@
1
+ class BadModel
2
+
3
+ include DataMapper::Resource
4
+
5
+ property :id, Serial
6
+
7
+ property :name, String
8
+
9
+ predefine = predefine.to_s.to_sym
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ class SimpleModel
2
+
3
+ include DataMapper::Resource
4
+
5
+ property :id, Serial
6
+
7
+ property :name, String
8
+
9
+ predefine :x, :name => 'X'
10
+
11
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'helpers/examples'
3
+
4
+ require 'yard-dm-predefined/predefine_handler'
5
+ require 'yard-dm-predefined/legacy/predefine_handler'
6
+
7
+ describe "PredefineHandler" do
8
+ include Helpers::Examples
9
+
10
+ describe "valid" do
11
+ before(:all) do
12
+ parse_file :simple_model
13
+ end
14
+
15
+ it "should register a class reader method for a predefine" do
16
+ yard('SimpleModel.x').should be_instance_of(CodeObjects::MethodObject)
17
+ end
18
+ end
19
+
20
+ describe "invalid" do
21
+ before(:all) do
22
+ parse_file :bad_model
23
+ end
24
+
25
+ it "should not register class reader methods for variables" do
26
+ yard('BadModel.x').should be_nil
27
+ end
28
+ end
29
+ 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,68 @@
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-dm-predefined}
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-20}
13
+ s.description = %q{yard-dm-predefined is a plugin for YARD for parsing dm-predefined methods.}
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
+ ".gitignore",
22
+ ".specopts",
23
+ ".yardopts",
24
+ "ChangeLog.md",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/yard-dm-predefined.rb",
30
+ "lib/yard-dm-predefined/legacy.rb",
31
+ "lib/yard-dm-predefined/legacy/predefine_handler.rb",
32
+ "lib/yard-dm-predefined/predefine_handler.rb",
33
+ "spec/helpers/examples.rb",
34
+ "spec/helpers/examples/bad_model.rb.txt",
35
+ "spec/helpers/examples/simple_model.rb.txt",
36
+ "spec/predefine_handler_spec.rb",
37
+ "spec/spec_helper.rb",
38
+ "yard-dm-predefined.gemspec"
39
+ ]
40
+ s.has_rdoc = %q{yard}
41
+ s.homepage = %q{http://github.com/postmodern/yard-dm-predefined}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.5}
45
+ s.summary = %q{A plugin for YARD for parsing dm-predefined methods.}
46
+ s.test_files = [
47
+ "spec/spec_helper.rb",
48
+ "spec/helpers/examples.rb",
49
+ "spec/predefine_handler_spec.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<yard>, [">= 0.4.0"])
58
+ s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
59
+ else
60
+ s.add_dependency(%q<yard>, [">= 0.4.0"])
61
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<yard>, [">= 0.4.0"])
65
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
66
+ end
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-dm-predefined
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-20 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-dm-predefined is a plugin for YARD for parsing dm-predefined methods.
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
+ - .gitignore
47
+ - .specopts
48
+ - .yardopts
49
+ - ChangeLog.md
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - VERSION
54
+ - lib/yard-dm-predefined.rb
55
+ - lib/yard-dm-predefined/legacy.rb
56
+ - lib/yard-dm-predefined/legacy/predefine_handler.rb
57
+ - lib/yard-dm-predefined/predefine_handler.rb
58
+ - spec/helpers/examples.rb
59
+ - spec/helpers/examples/bad_model.rb.txt
60
+ - spec/helpers/examples/simple_model.rb.txt
61
+ - spec/predefine_handler_spec.rb
62
+ - spec/spec_helper.rb
63
+ - yard-dm-predefined.gemspec
64
+ has_rdoc: yard
65
+ homepage: http://github.com/postmodern/yard-dm-predefined
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --charset=UTF-8
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.5
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: A plugin for YARD for parsing dm-predefined methods.
92
+ test_files:
93
+ - spec/spec_helper.rb
94
+ - spec/helpers/examples.rb
95
+ - spec/predefine_handler_spec.rb