yard-activerecord2 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'yard'
2
2
  require 'active_support/inflector'
3
3
 
4
- module YARD::Handlers::Ruby::ActiveRecord::Associations
4
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
5
5
  class Base < YARD::Handlers::Ruby::MethodHandler
6
6
  namespace_only
7
7
 
@@ -1,6 +1,6 @@
1
1
  require_relative 'plural_handler'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Associations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
4
4
  class HasAndBelongsToManyHandler < PluralHandler
5
5
  handles method_call(:has_and_belongs_to_many)
6
6
 
@@ -1,6 +1,6 @@
1
1
  require_relative 'plural_handler'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Associations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
4
4
  class HasManyHandler < PluralHandler
5
5
  handles method_call(:has_many)
6
6
 
@@ -8,4 +8,4 @@ module YARD::Handlers::Ruby::ActiveRecord::Associations
8
8
  "#{namespace} <b>has many</b> #{method_name}"
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,6 +1,6 @@
1
1
  require_relative 'singular_handler'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Associations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
4
4
  class HasOneHandler < SingularHandler
5
5
  handles method_call(:has_one)
6
6
 
@@ -8,4 +8,4 @@ module YARD::Handlers::Ruby::ActiveRecord::Associations
8
8
  "#{namespace} <b>has one</b> #{method_name}"
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,11 +1,11 @@
1
1
  require_relative 'base'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Associations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
4
4
  class PluralHandler < Base
5
5
  def class_name
6
6
  "Array<#{super(true)}>"
7
7
  end
8
-
8
+
9
9
  def return_description
10
10
  "An array of associated #{method_name}"
11
11
  end
@@ -1,11 +1,11 @@
1
1
  require_relative 'base'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Associations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Associations
4
4
  class SingularHandler < Base
5
5
  def class_name
6
6
  super(false)
7
7
  end
8
-
8
+
9
9
  def return_description
10
10
  "An associated #{method_name}"
11
11
  end
@@ -1,6 +1,6 @@
1
1
  require 'yard'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Delegations
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Delegations
4
4
  class DelegateHandler < YARD::Handlers::Ruby::MethodHandler
5
5
  handles method_call(:delegate)
6
6
  namespace_only
@@ -1,7 +1,7 @@
1
1
  require 'yard'
2
2
  require 'active_support/inflector'
3
3
 
4
- module YARD::Handlers::Ruby::ActiveRecord::Fields
4
+ module YARD::Handlers::Ruby::ActiveRecord2::Fields
5
5
  class CreateTableHandler < YARD::Handlers::Ruby::MethodHandler
6
6
  handles method_call(:create_table)
7
7
 
@@ -1,7 +1,7 @@
1
- module YARD::Handlers::Ruby::ActiveRecord::Fields
1
+ module YARD::Handlers::Ruby::ActiveRecord2::Fields
2
2
  class DefineHandler < YARD::Handlers::Ruby::MethodHandler
3
3
  handles method_call(:define)
4
-
4
+
5
5
  def process
6
6
  if statement.file == 'db/schema.rb'
7
7
  globals.ar_schema = true
@@ -1,4 +1,4 @@
1
- module YARD::Handlers::Ruby::ActiveRecord::Fields
1
+ module YARD::Handlers::Ruby::ActiveRecord2::Fields
2
2
  class FieldHandler < YARD::Handlers::Ruby::MethodHandler
3
3
  handles method_call(:string)
4
4
  handles method_call(:text)
@@ -6,45 +6,45 @@ module YARD::Handlers::Ruby::ActiveRecord::Fields
6
6
  handles method_call(:float)
7
7
  handles method_call(:boolean)
8
8
  handles method_call(:datetime)
9
-
9
+
10
10
  def process
11
11
  return unless statement.namespace.jump(:ident).source == 't'
12
12
  method_name = call_params.first
13
13
  class_name = caller_method.capitalize
14
-
14
+
15
15
  return if method_name['_id'] # Skip all id fields, associations will handle that
16
-
16
+
17
17
  if class_name == "Datetime"
18
18
  class_name = "DateTime"
19
19
  end
20
20
  ensure_loaded! P(globals.klass)
21
21
  namespace = P(globals.klass)
22
22
  return if namespace.nil?
23
-
23
+
24
24
  r_object = YARD::CodeObjects::MethodObject.new(namespace, method_name)
25
25
  r_object.docstring = description(method_name)
26
26
  r_object.docstring.add_tag get_tag(:return, '', class_name)
27
27
  r_object.dynamic = true
28
28
  register r_object
29
-
29
+
30
30
  w_object = YARD::CodeObjects::MethodObject.new(namespace, "#{method_name}=")
31
31
  w_object.docstring = description(method_name)
32
32
  w_object.docstring.add_tag get_tag(:return, '', class_name)
33
33
  w_object.dynamic = true
34
34
  register w_object
35
-
35
+
36
36
  namespace.instance_attributes[method_name.to_sym] = {
37
37
  read: r_object,
38
38
  write: w_object
39
39
  }
40
40
  end
41
-
41
+
42
42
  def description(method_name)
43
43
  "Database field value of #{method_name}. Defined in {file:db/schema.rb}"
44
44
  end
45
-
45
+
46
46
  def get_tag(tag, text, return_classes)
47
47
  YARD::Tags::Tag.new(:return, text, [return_classes].flatten)
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -1,10 +1,10 @@
1
1
  require 'active_support/inflector'
2
2
 
3
- module YARD::Handlers::Ruby::ActiveRecord::Scopes
3
+ module YARD::Handlers::Ruby::ActiveRecord2::Scopes
4
4
  class ScopeHandler < YARD::Handlers::Ruby::MethodHandler
5
5
  handles method_call(:scope)
6
6
  namespace_only
7
-
7
+
8
8
  def process
9
9
  object = YARD::CodeObjects::MethodObject.new(namespace, method_name, :class)
10
10
  object.docstring = return_description
@@ -13,18 +13,18 @@ module YARD::Handlers::Ruby::ActiveRecord::Scopes
13
13
  'http://api.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html')
14
14
  register object
15
15
  end
16
-
16
+
17
17
  private
18
18
  def method_name
19
19
  call_params[0]
20
20
  end
21
-
21
+
22
22
  def return_description
23
23
  "An array of #{ActiveSupport::Inflector.pluralize namespace.to_s} " +
24
24
  "that are #{method_name.split('_').join(' ')}. " +
25
25
  "<strong>Active Record Scope</strong>"
26
26
  end
27
-
27
+
28
28
  def class_name
29
29
  "Array<#{namespace}>"
30
30
  end
@@ -33,4 +33,4 @@ module YARD::Handlers::Ruby::ActiveRecord::Scopes
33
33
  YARD::Tags::Tag.new(tag, text, [return_classes].flatten)
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module ActiveRecord2
3
+ VERSION = "0.0.10"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ require 'yard'
2
+
3
+ module YARD::Handlers::Ruby::ActiveRecord2
4
+ end
5
+
6
+ root = File.expand_path(File.dirname(__FILE__))
7
+ $LOAD_PATH << root unless $LOAD_PATH.include? root
8
+
9
+ require 'yard-activerecord2/fields/create_table_handler'
10
+ require 'yard-activerecord2/fields/define_handler'
11
+ require 'yard-activerecord2/fields/field_handler'
12
+
13
+ require 'yard-activerecord2/associations/belongs_to_handler'
14
+ require 'yard-activerecord2/associations/has_one_handler'
15
+ require 'yard-activerecord2/associations/has_many_handler'
16
+ require 'yard-activerecord2/associations/has_and_belongs_to_many_handler'
17
+
18
+ require 'yard-activerecord2/delegations/delegate_handler'
19
+
20
+ require 'yard-activerecord2/scopes/scope_handler'
data/test.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'bundler/setup'
2
- require 'yard-activerecord'
2
+ require 'yard-activerecord2'
3
3
 
4
- YARD::Handlers::Ruby::ActiveRecord::Fields::CreateTable.new
4
+ YARD::Handlers::Ruby::ActiveRecord::Fields::CreateTable.new
@@ -1,11 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
- require "yard-activerecord/version"
4
+ require "yard-activerecord2/version"
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "yard-activerecord2"
8
- s.version = YARD::ActiveRecord::VERSION
8
+ s.version = YARD::ActiveRecord2::VERSION
9
9
  s.authors = ["Theodor Tonum"]
10
10
  s.email = ["theodor@tonum.no"]
11
11
  s.homepage = ""
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.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -58,22 +58,22 @@ files:
58
58
  - Gemfile
59
59
  - README.md
60
60
  - Rakefile
61
- - lib/yard-activerecord.rb
62
- - lib/yard-activerecord/associations/base.rb
63
- - lib/yard-activerecord/associations/belongs_to_handler.rb
64
- - lib/yard-activerecord/associations/has_and_belongs_to_many_handler.rb
65
- - lib/yard-activerecord/associations/has_many_handler.rb
66
- - lib/yard-activerecord/associations/has_one_handler.rb
67
- - lib/yard-activerecord/associations/plural_handler.rb
68
- - lib/yard-activerecord/associations/singular_handler.rb
69
- - lib/yard-activerecord/delegations/delegate_handler.rb
70
- - lib/yard-activerecord/fields/create_table_handler.rb
71
- - lib/yard-activerecord/fields/define_handler.rb
72
- - lib/yard-activerecord/fields/field_handler.rb
73
- - lib/yard-activerecord/scopes/scope_handler.rb
74
- - lib/yard-activerecord/version.rb
61
+ - lib/yard-activerecord2.rb
62
+ - lib/yard-activerecord2/associations/base.rb
63
+ - lib/yard-activerecord2/associations/belongs_to_handler.rb
64
+ - lib/yard-activerecord2/associations/has_and_belongs_to_many_handler.rb
65
+ - lib/yard-activerecord2/associations/has_many_handler.rb
66
+ - lib/yard-activerecord2/associations/has_one_handler.rb
67
+ - lib/yard-activerecord2/associations/plural_handler.rb
68
+ - lib/yard-activerecord2/associations/singular_handler.rb
69
+ - lib/yard-activerecord2/delegations/delegate_handler.rb
70
+ - lib/yard-activerecord2/fields/create_table_handler.rb
71
+ - lib/yard-activerecord2/fields/define_handler.rb
72
+ - lib/yard-activerecord2/fields/field_handler.rb
73
+ - lib/yard-activerecord2/scopes/scope_handler.rb
74
+ - lib/yard-activerecord2/version.rb
75
75
  - test.rb
76
- - yard-activerecord.gemspec
76
+ - yard-activerecord2.gemspec
77
77
  homepage: ''
78
78
  licenses: []
79
79
  post_install_message:
@@ -1,5 +0,0 @@
1
- module YARD
2
- module ActiveRecord
3
- VERSION = "0.0.9"
4
- end
5
- end
@@ -1,20 +0,0 @@
1
- require 'yard'
2
-
3
- module YARD::Handlers::Ruby::ActiveRecord
4
- end
5
-
6
- root = File.expand_path(File.dirname(__FILE__))
7
- $LOAD_PATH << root unless $LOAD_PATH.include? root
8
-
9
- require 'yard-activerecord/fields/create_table_handler'
10
- require 'yard-activerecord/fields/define_handler'
11
- require 'yard-activerecord/fields/field_handler'
12
-
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'
17
-
18
- require 'yard-activerecord/delegations/delegate_handler'
19
-
20
- require 'yard-activerecord/scopes/scope_handler'