yard-activerecord2 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,33 +4,34 @@ require 'active_support/inflector'
4
4
  module YARD::Handlers::Ruby::ActiveRecord::Associations
5
5
  class Base < YARD::Handlers::Ruby::MethodHandler
6
6
  namespace_only
7
-
7
+
8
8
  def process
9
- object = YARD::CodeObjects::MethodObject.new(namespace, method_name)
10
- object.group = "Active Record Associations"
9
+ group_name = "Active Record Associations"
10
+ namespace.groups << group_name unless namespace.groups.include? group_name
11
+
12
+ object = YARD::CodeObjects::MethodObject.new(namespace, method_name)
13
+ object.group = group_name
11
14
  object.docstring = return_description
12
15
  object.docstring.add_tag get_tag(:return, '', class_name)
13
16
  object.docstring.add_tag get_tag(:see, 'http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html')
14
17
  object.dynamic = true
15
18
  register object
16
- group_name = "Active Record Associations"
17
- namespace.groups << group_name unless namespace.groups.include? group_name
18
19
  end
19
-
20
+
20
21
  private
21
22
  def method_name
22
23
  call_params[0]
23
24
  end
24
-
25
+
25
26
  def class_name(singularize = false)
26
27
  param_size = statement.parameters.size
27
28
  if param_size > 2
28
- i = 1
29
+ i = 1
29
30
  return_this = false
30
31
  while i < param_size - 1
31
32
  # May want to evaluate doing it this way
32
- hash = eval('{' + statement.parameters[i].jump(:hash).source + '}')
33
- return hash[:class_name] unless hash[:class_name].nil?
33
+ statement.parameters[i].jump(:hash).source =~ /(:class_name\s*=>|class_name:)\s*["']([^"']+)["']/
34
+ return $2 if $2
34
35
  i += 1
35
36
  end
36
37
  end
@@ -40,11 +41,11 @@ module YARD::Handlers::Ruby::ActiveRecord::Associations
40
41
  method_name.capitalize
41
42
  end
42
43
  end
43
-
44
+
44
45
  def return_description
45
46
  "An array of associated #{method_name}."
46
47
  end
47
-
48
+
48
49
  def get_tag(tag, text, return_classes = [])
49
50
  YARD::Tags::Tag.new(tag, text, [return_classes].flatten)
50
51
  end
@@ -8,7 +8,7 @@ module YARD::Handlers::Ruby::ActiveRecord::Delegations
8
8
  def process
9
9
  params = call_params
10
10
  class_name = params.pop
11
- class_name = class_name[:to] if class_name.is_a?(Hash) && class_name[:to]
11
+ class_name = class_name[:to] if class_name.is_a?(Hash)
12
12
  class_name.capitalize!
13
13
  params.each do |method_name|
14
14
  object = YARD::CodeObjects::MethodObject.new(namespace, method_name)
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module ActiveRecord
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
@@ -3,15 +3,18 @@ require 'yard'
3
3
  module YARD::Handlers::Ruby::ActiveRecord
4
4
  end
5
5
 
6
- require_relative 'yard-activerecord/fields/create_table_handler'
7
- require_relative 'yard-activerecord/fields/define_handler'
8
- require_relative 'yard-activerecord/fields/field_handler'
6
+ root = File.expand_path(File.dirname(__FILE__))
7
+ $LOAD_PATH << root unless $LOAD_PATH.include? root
9
8
 
10
- require_relative 'yard-activerecord/associations/belongs_to_handler'
11
- require_relative 'yard-activerecord/associations/has_one_handler'
12
- require_relative 'yard-activerecord/associations/has_one_handler'
13
- require_relative 'yard-activerecord/associations/has_and_belongs_to_many_handler'
9
+ require 'yard-activerecord/fields/create_table_handler'
10
+ require 'yard-activerecord/fields/define_handler'
11
+ require 'yard-activerecord/fields/field_handler'
14
12
 
15
- require_relative 'yard-activerecord/delegations/delegate_handler'
13
+ require 'yard-activerecord/associations/belongs_to_handler'
14
+ require 'yard-activerecord/associations/has_one_handler'
15
+ require 'yard-activerecord/associations/has_many_handler'
16
+ require 'yard-activerecord/associations/has_and_belongs_to_many_handler'
16
17
 
17
- require_relative 'yard-activerecord/scopes/scope_handler'
18
+ require 'yard-activerecord/delegations/delegate_handler'
19
+
20
+ require 'yard-activerecord/scopes/scope_handler'
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'YARD'
3
- require File.dirname(__FILE__) + '/lib/yard-activerecord'
4
- require File.dirname(__FILE__) + '/lib/yard-activerecord/version'
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "yard-activerecord/version"
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "yard-activerecord2"
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  attributes, associations, delegates and scopes. A must for any Rails app
17
17
  using YARD as documentation plugin. }
18
18
 
19
- s.add_development_dependency 'yard', '>= 0.7.0'
19
+ s.add_dependency 'yard', '>= 0.8.3'
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.require_path = "lib"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-activerecord2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,15 +18,15 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.0
22
- type: :development
21
+ version: 0.8.3
22
+ type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.7.0
29
+ version: 0.8.3
30
30
  description: ! "\n YARD-Activerecord is a YARD extension that handles and interprets
31
31
  methods\n used when developing applications with ActiveRecord. The extension
32
32
  handles\n attributes, associations, delegates and scopes. A must for any Rails
@@ -42,10 +42,7 @@ files:
42
42
  - Gemfile
43
43
  - README.md
44
44
  - Rakefile
45
- - lib/.DS_Store
46
45
  - lib/yard-activerecord.rb
47
- - lib/yard-activerecord/.DS_Store
48
- - lib/yard-activerecord/associations/.DS_Store
49
46
  - lib/yard-activerecord/associations/base.rb
50
47
  - lib/yard-activerecord/associations/belongs_to_handler.rb
51
48
  - lib/yard-activerecord/associations/has_and_belongs_to_many_handler.rb
@@ -53,13 +50,10 @@ files:
53
50
  - lib/yard-activerecord/associations/has_one_handler.rb
54
51
  - lib/yard-activerecord/associations/plural_handler.rb
55
52
  - lib/yard-activerecord/associations/singular_handler.rb
56
- - lib/yard-activerecord/delegations/.DS_Store
57
53
  - lib/yard-activerecord/delegations/delegate_handler.rb
58
- - lib/yard-activerecord/fields/.DS_Store
59
54
  - lib/yard-activerecord/fields/create_table_handler.rb
60
55
  - lib/yard-activerecord/fields/define_handler.rb
61
56
  - lib/yard-activerecord/fields/field_handler.rb
62
- - lib/yard-activerecord/scopes/.DS_Store
63
57
  - lib/yard-activerecord/scopes/scope_handler.rb
64
58
  - lib/yard-activerecord/version.rb
65
59
  - test.rb
data/lib/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file