yard-dm-is-predefined 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ doc
2
+ pkg
3
+ tmp/*
4
+ .DS_Store
5
+ .yardoc
6
+ *.db
7
+ *.log
8
+ *.swp
9
+ *~
@@ -0,0 +1 @@
1
+ --colour --format specdoc
@@ -0,0 +1 @@
1
+ --markup markdown --title 'YARD dm-predefined Documentation' --protected --files ChangeLog.md,LICENSE.txt
@@ -0,0 +1,9 @@
1
+ ### 0.2.0 / 2010-06-10
2
+
3
+ * Renamed to yard-dm-is-predefined.
4
+
5
+ ### 0.1.0 / 2010-02-20
6
+
7
+ * Initial release:
8
+ * Parses `predefine :name, ...` class-method calls.
9
+
@@ -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.
@@ -0,0 +1,26 @@
1
+ # yard-dm-is-predefined
2
+
3
+ * [github.com/postmodern/yard-dm-is-predefined](http://github.com/postmodern/yard-dm-is-predefined)
4
+ * [github.com/postmodern/yard-dm-is-predefined/issues](http://github.com/postmodern/yard-dm-is-predefined/issues)
5
+
6
+ ## Description
7
+
8
+ yard-dm-is-predefined is a plugin for YARD for parsing
9
+ [dm-is-predefined](http://github.com/postmodern/dm-is-predefined) 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-is-predefined
22
+
23
+ ## Copyright
24
+
25
+ See {file:LICENSE.txt} for license information.
26
+
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "yard-dm-is-predefined"
8
+ gem.license = 'MIT'
9
+ gem.summary = %Q{A plugin for YARD for parsing dm-predefined methods.}
10
+ gem.description = %Q{yard-dm-predefined is a plugin for YARD for parsing dm-predefined methods.}
11
+ gem.email = "postmodern.mod3@gmail.com"
12
+ gem.homepage = "http://github.com/postmodern/yard-dm-is-predefined"
13
+ gem.authors = ["postmodern"]
14
+ gem.add_dependency "yard", ">= 0.4.0"
15
+ gem.add_development_dependency "rspec", "~> 1.3.0"
16
+ gem.has_rdoc = 'yard'
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs += ['lib', 'spec']
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ spec.spec_opts = ['--options', '.specopts']
28
+ end
29
+
30
+ task :spec => :check_dependencies
31
+ task :default => :spec
32
+
33
+ begin
34
+ require 'yard'
35
+ YARD::Rake::YardocTask.new
36
+ rescue LoadError
37
+ task :yard do
38
+ abort "YARD is not available. In order to run yard, you must: gem install yard"
39
+ end
40
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,2 @@
1
+ require 'yard-dm-is-predefined/predefine_handler'
2
+ require 'yard-dm-is-predefined/legacy'
@@ -0,0 +1 @@
1
+ require 'yard-dm-is-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-is-predefined/predefine_handler'
5
+ require 'yard-dm-is-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,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-dm-is-predefined}
8
+ s.version = "0.2.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-06-10}
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-is-predefined.rb",
30
+ "lib/yard-dm-is-predefined/legacy.rb",
31
+ "lib/yard-dm-is-predefined/legacy/predefine_handler.rb",
32
+ "lib/yard-dm-is-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-is-predefined.gemspec"
39
+ ]
40
+ s.has_rdoc = %q{yard}
41
+ s.homepage = %q{http://github.com/postmodern/yard-dm-is-predefined}
42
+ s.licenses = ["MIT"]
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{A plugin for YARD for parsing dm-predefined methods.}
47
+ s.test_files = [
48
+ "spec/spec_helper.rb",
49
+ "spec/helpers/examples.rb",
50
+ "spec/predefine_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::VERSION) >= 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,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-dm-is-predefined
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - postmodern
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-10 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: yard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 4
31
+ - 0
32
+ version: 0.4.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 3
46
+ - 0
47
+ version: 1.3.0
48
+ type: :development
49
+ version_requirements: *id002
50
+ description: yard-dm-predefined is a plugin for YARD for parsing dm-predefined methods.
51
+ email: postmodern.mod3@gmail.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - ChangeLog.md
58
+ - LICENSE.txt
59
+ - README.md
60
+ files:
61
+ - .gitignore
62
+ - .specopts
63
+ - .yardopts
64
+ - ChangeLog.md
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - VERSION
69
+ - lib/yard-dm-is-predefined.rb
70
+ - lib/yard-dm-is-predefined/legacy.rb
71
+ - lib/yard-dm-is-predefined/legacy/predefine_handler.rb
72
+ - lib/yard-dm-is-predefined/predefine_handler.rb
73
+ - spec/helpers/examples.rb
74
+ - spec/helpers/examples/bad_model.rb.txt
75
+ - spec/helpers/examples/simple_model.rb.txt
76
+ - spec/predefine_handler_spec.rb
77
+ - spec/spec_helper.rb
78
+ - yard-dm-is-predefined.gemspec
79
+ has_rdoc: yard
80
+ homepage: http://github.com/postmodern/yard-dm-is-predefined
81
+ licenses:
82
+ - MIT
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ requirements: []
105
+
106
+ rubyforge_project:
107
+ rubygems_version: 1.3.7
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: A plugin for YARD for parsing dm-predefined methods.
111
+ test_files:
112
+ - spec/spec_helper.rb
113
+ - spec/helpers/examples.rb
114
+ - spec/predefine_handler_spec.rb