yard-method-decorators 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yard-method-decorators.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeremy Friesen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Yard::MethodDecorators
2
+
3
+ A YARD plugin for the
4
+ [method decorators gem](http://rubygems.org/gems/method_decorators).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'yard-method-decorators'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install yard-method-decorators
19
+
20
+ ## Usage
21
+
22
+ $ yardoc -p templates_custom \
23
+ -e lib/yard-method-decorators.rb example/example_code.rb
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ # Run `yardoc -p templates_custom -e lib/yard-method-decorators.rb example/example_code.rb`
2
+ require 'method_decorators'
3
+
4
+ class HelloWorld
5
+ extend MethodDecorators
6
+ +Precondition.new {|p1, p2| p1.is_a?(Integer) && p2.is_a?(Integer)}
7
+ +Memoize
8
+ def adder(value1,value2)
9
+ value1 + value2
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module YARD::MethodDecorators
2
+ # Your code goes here...
3
+ end
4
+
5
+ YARD::Templates::Engine.register_template_path(
6
+ File.dirname(__FILE__) + '/../templates'
7
+ )
8
+
9
+ require File.join(File.dirname(__FILE__), 'yard-method-decorators', 'handler')
10
+ require File.join(File.dirname(__FILE__), 'yard-method-decorators', 'version')
11
+
@@ -0,0 +1,22 @@
1
+ class YARD::MethodDecorators::PlusHander < YARD::Handlers::Ruby::Base
2
+ handles :unary
3
+ namespace_only
4
+
5
+ process do
6
+ # method_decorators_tag = YARD::Tags::Tag.new(:method_decorators, "", [])
7
+
8
+ parent_statement = statement.parent
9
+ index_of_statement = parent_statement.children.find_index(statement)
10
+ decorated_method_statement = parent_statement.
11
+ children[index_of_statement..-1].detect {|child| child.type != :unary }
12
+ decorated_method_name = decorated_method_statement.jump(:ident).source
13
+ object = YARD::CodeObjects::MethodObject.new(namespace, decorated_method_name)
14
+ object[:method_decorators] ||= []
15
+ object[:method_decorators] << {
16
+ name: statement.jump(:const).source,
17
+ file: statement.file,
18
+ line: statement.line,
19
+ source: statement.last.last.source.chomp
20
+ }
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module MethodDecorators
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
@@ -0,0 +1,28 @@
1
+ <% if object[:method_decorators] %>
2
+ <div class="tags">
3
+ <h4>Method Decorators:</h4>
4
+ <ul class="decorators">
5
+ <% for decorator in object[:method_decorators] %>
6
+ <li><%= decorator[:name] %>
7
+ <div class="source_code">
8
+ <table>
9
+ <tr>
10
+ <td>
11
+ <pre class="lines">
12
+
13
+
14
+ <%= decorator[:source].split("\n").size.times.to_a.map {|i| decorator[:line] + i }.join("\n") %></pre>
15
+ </td>
16
+ <td>
17
+ <pre class="code"><span class="info file"># File '<%= h decorator[:file] %>', line <%= decorator[:line] %></span>
18
+
19
+ <%= html_syntax_highlight format_source(decorator[:source]) %></pre>
20
+ </td>
21
+ </tr>
22
+ </table>
23
+ </div>
24
+ </li>
25
+ <% end %>
26
+ </ul>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,4 @@
1
+ def init
2
+ super
3
+ sections.last.place(:method_decorators).after(:method_signature)
4
+ end
@@ -0,0 +1,9 @@
1
+ <% if object[:method_decorators] %>
2
+
3
+ Method Decorators:
4
+ ------------------
5
+
6
+ <% for decorator in object[:method_decorators] %>
7
+ <%= indent wrap("- " + spec[:decorator]) %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/yard-method-decorators/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = [
6
+ "Jeremy Friesen",
7
+ ]
8
+ gem.email = [
9
+ "jeremy.n.friesen@gmail.com",
10
+ ]
11
+ gem.description = %q{Captures MethodDecorators in YARD}
12
+ gem.summary = %q{Captures MethodDecorators in YARD}
13
+ gem.homepage = "http://github.com/jeremyf/yard-method-decorators"
14
+
15
+ gem.files = `git ls-files`.split($\)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.name = "yard-method-decorators"
19
+ gem.require_paths = ["lib"]
20
+ gem.version = YARD::MethodDecorators::VERSION
21
+ gem.add_dependency 'yard'
22
+ gem.add_dependency 'method_decorators'
23
+ gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'rspec-given'
25
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-method-decorators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeremy Friesen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: method_decorators
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-given
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Captures MethodDecorators in YARD
79
+ email:
80
+ - jeremy.n.friesen@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - Gemfile
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - example/example_code.rb
92
+ - lib/yard-method-decorators.rb
93
+ - lib/yard-method-decorators/handler.rb
94
+ - lib/yard-method-decorators/version.rb
95
+ - spec/spec_helper.rb
96
+ - templates/default/method_details/html/method_decorators.erb
97
+ - templates/default/method_details/setup.rb
98
+ - templates/default/method_details/text/method_decorators.erb
99
+ - yard-method-decorators.gemspec
100
+ homepage: http://github.com/jeremyf/yard-method-decorators
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Captures MethodDecorators in YARD
124
+ test_files:
125
+ - spec/spec_helper.rb
126
+ has_rdoc: