annotate 2.7.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Annotate
2
2
  def self.version
3
- '2.7.0'
3
+ '3.1.1'
4
4
  end
5
5
  end
@@ -1,14 +1,15 @@
1
+ require 'annotate'
2
+
1
3
  module Annotate
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
- desc "Copy annotate_models rakefiles for automatic annotation"
5
- source_root File.expand_path('../templates', __FILE__)
6
+ desc 'Copy annotate_models rakefiles for automatic annotation'
7
+ source_root File.expand_path('templates', __dir__)
6
8
 
7
9
  # copy rake tasks
8
10
  def copy_tasks
9
- template "auto_annotate_models.rake", "lib/tasks/auto_annotate_models.rake"
11
+ template 'auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake'
10
12
  end
11
-
12
13
  end
13
14
  end
14
15
  end
@@ -2,44 +2,56 @@
2
2
  # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
3
  # NOTE: to have a dev-mode tool do its thing in production.
4
4
  if Rails.env.development?
5
+ require 'annotate'
5
6
  task :set_annotation_options do
6
7
  # You can override any of these by setting an environment variable of the
7
8
  # same name.
8
9
  Annotate.set_defaults(
9
- 'routes' => 'false',
10
- 'position_in_routes' => 'before',
11
- 'position_in_class' => 'before',
12
- 'position_in_test' => 'before',
13
- 'position_in_fixture' => 'before',
14
- 'position_in_factory' => 'before',
15
- 'position_in_serializer' => 'before',
16
- 'show_foreign_keys' => 'true',
17
- 'show_indexes' => 'true',
18
- 'simple_indexes' => 'false',
19
- 'model_dir' => 'app/models',
20
- 'root_dir' => '',
21
- 'include_version' => 'false',
22
- 'require' => '',
23
- 'exclude_tests' => 'false',
24
- 'exclude_fixtures' => 'false',
25
- 'exclude_factories' => 'false',
26
- 'exclude_serializers' => 'false',
27
- 'exclude_scaffolds' => 'false',
28
- 'exclude_controllers' => 'false',
29
- 'exclude_helpers' => 'false',
30
- 'ignore_model_sub_dir' => 'false',
31
- 'ignore_columns' => nil,
32
- 'ignore_unknown_models' => 'false',
33
- 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(',') %>',
34
- 'skip_on_db_migrate' => 'false',
35
- 'format_bare' => 'true',
36
- 'format_rdoc' => 'false',
37
- 'format_markdown' => 'false',
38
- 'sort' => 'false',
39
- 'force' => 'false',
40
- 'trace' => 'false',
41
- 'wrapper_open' => nil,
42
- 'wrapper_close' => nil,
10
+ 'active_admin' => 'false',
11
+ 'additional_file_patterns' => [],
12
+ 'routes' => 'false',
13
+ 'models' => 'true',
14
+ 'position_in_routes' => 'before',
15
+ 'position_in_class' => 'before',
16
+ 'position_in_test' => 'before',
17
+ 'position_in_fixture' => 'before',
18
+ 'position_in_factory' => 'before',
19
+ 'position_in_serializer' => 'before',
20
+ 'show_foreign_keys' => 'true',
21
+ 'show_complete_foreign_keys' => 'false',
22
+ 'show_indexes' => 'true',
23
+ 'simple_indexes' => 'false',
24
+ 'model_dir' => 'app/models',
25
+ 'root_dir' => '',
26
+ 'include_version' => 'false',
27
+ 'require' => '',
28
+ 'exclude_tests' => 'false',
29
+ 'exclude_fixtures' => 'false',
30
+ 'exclude_factories' => 'false',
31
+ 'exclude_serializers' => 'false',
32
+ 'exclude_scaffolds' => 'true',
33
+ 'exclude_controllers' => 'true',
34
+ 'exclude_helpers' => 'true',
35
+ 'exclude_sti_subclasses' => 'false',
36
+ 'ignore_model_sub_dir' => 'false',
37
+ 'ignore_columns' => nil,
38
+ 'ignore_routes' => nil,
39
+ 'ignore_unknown_models' => 'false',
40
+ 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
41
+ 'hide_default_column_types' => '<%= AnnotateModels::NO_DEFAULT_COL_TYPES.join(",") %>',
42
+ 'skip_on_db_migrate' => 'false',
43
+ 'format_bare' => 'true',
44
+ 'format_rdoc' => 'false',
45
+ 'format_yard' => 'false',
46
+ 'format_markdown' => 'false',
47
+ 'sort' => 'false',
48
+ 'force' => 'false',
49
+ 'frozen' => 'false',
50
+ 'classified_sort' => 'true',
51
+ 'trace' => 'false',
52
+ 'wrapper_open' => nil,
53
+ 'wrapper_close' => nil,
54
+ 'with_comment' => 'true'
43
55
  )
44
56
  end
45
57
 
@@ -1,60 +1,70 @@
1
1
  annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
2
2
 
3
- if !ENV['is_cli']
3
+ unless ENV['is_cli']
4
4
  task :set_annotation_options
5
- task :annotate_models => :set_annotation_options
5
+ task annotate_models: :set_annotation_options
6
6
  end
7
7
 
8
- desc "Add schema information (as comments) to model and fixture files"
9
- task :annotate_models => :environment do
8
+ desc 'Add schema information (as comments) to model and fixture files'
9
+ task annotate_models: :environment do
10
10
  require "#{annotate_lib}/annotate/annotate_models"
11
11
  require "#{annotate_lib}/annotate/active_record_patch"
12
12
 
13
- options={ :is_rake => true }
14
- ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before')
15
- options[:position_in_class] = Annotate.fallback(ENV['position_in_class'], ENV['position'])
16
- options[:position_in_fixture] = Annotate.fallback(ENV['position_in_fixture'], ENV['position'])
17
- options[:position_in_factory] = Annotate.fallback(ENV['position_in_factory'], ENV['position'])
18
- options[:position_in_test] = Annotate.fallback(ENV['position_in_test'], ENV['position'])
19
- options[:position_in_serializer] = Annotate.fallback(ENV['position_in_serializer'], ENV['position'])
20
- options[:show_foreign_keys] = Annotate.true?(ENV['show_foreign_keys'])
21
- options[:show_indexes] = Annotate.true?(ENV['show_indexes'])
22
- options[:simple_indexes] = Annotate.true?(ENV['simple_indexes'])
13
+ options = {is_rake: true}
14
+ ENV['position'] = options[:position] = Annotate::Helpers.fallback(ENV['position'], 'before')
15
+ options[:additional_file_patterns] = ENV['additional_file_patterns'] ? ENV['additional_file_patterns'].split(',') : []
16
+ options[:position_in_class] = Annotate::Helpers.fallback(ENV['position_in_class'], ENV['position'])
17
+ options[:position_in_fixture] = Annotate::Helpers.fallback(ENV['position_in_fixture'], ENV['position'])
18
+ options[:position_in_factory] = Annotate::Helpers.fallback(ENV['position_in_factory'], ENV['position'])
19
+ options[:position_in_test] = Annotate::Helpers.fallback(ENV['position_in_test'], ENV['position'])
20
+ options[:position_in_serializer] = Annotate::Helpers.fallback(ENV['position_in_serializer'], ENV['position'])
21
+ options[:show_foreign_keys] = Annotate::Helpers.true?(ENV['show_foreign_keys'])
22
+ options[:show_complete_foreign_keys] = Annotate::Helpers.true?(ENV['show_complete_foreign_keys'])
23
+ options[:show_indexes] = Annotate::Helpers.true?(ENV['show_indexes'])
24
+ options[:simple_indexes] = Annotate::Helpers.true?(ENV['simple_indexes'])
23
25
  options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : ['app/models']
24
- options[:root_dir] = ENV['root_dir'] ? ENV['root_dir'].split(',') : ['']
25
- options[:include_version] = Annotate.true?(ENV['include_version'])
26
+ options[:root_dir] = ENV['root_dir']
27
+ options[:include_version] = Annotate::Helpers.true?(ENV['include_version'])
26
28
  options[:require] = ENV['require'] ? ENV['require'].split(',') : []
27
- options[:exclude_tests] = Annotate.true?(ENV['exclude_tests'])
28
- options[:exclude_factories] = Annotate.true?(ENV['exclude_factories'])
29
- options[:exclude_fixtures] = Annotate.true?(ENV['exclude_fixtures'])
30
- options[:exclude_serializers] = Annotate.true?(ENV['exclude_serializers'])
31
- options[:exclude_scaffolds] = Annotate.true?(ENV['exclude_scaffolds'])
32
- options[:exclude_controllers] = Annotate.true?(ENV['exclude_controllers'])
33
- options[:exclude_helpers] = Annotate.true?(ENV['exclude_helpers'])
34
- options[:ignore_model_sub_dir] = Annotate.true?(ENV['ignore_model_sub_dir'])
35
- options[:format_bare] = Annotate.true?(ENV['format_bare'])
36
- options[:format_rdoc] = Annotate.true?(ENV['format_rdoc'])
37
- options[:format_markdown] = Annotate.true?(ENV['format_markdown'])
38
- options[:sort] = Annotate.true?(ENV['sort'])
39
- options[:force] = Annotate.true?(ENV['force'])
40
- options[:classified_sort] = Annotate.true?(ENV['classified_sort'])
41
- options[:trace] = Annotate.true?(ENV['trace'])
42
- options[:wrapper_open] = Annotate.fallback(ENV['wrapper_open'], ENV['wrapper'])
43
- options[:wrapper_close] = Annotate.fallback(ENV['wrapper_close'], ENV['wrapper'])
29
+ options[:exclude_tests] = Annotate::Helpers.true?(ENV['exclude_tests'])
30
+ options[:exclude_factories] = Annotate::Helpers.true?(ENV['exclude_factories'])
31
+ options[:exclude_fixtures] = Annotate::Helpers.true?(ENV['exclude_fixtures'])
32
+ options[:exclude_serializers] = Annotate::Helpers.true?(ENV['exclude_serializers'])
33
+ options[:exclude_scaffolds] = Annotate::Helpers.true?(ENV['exclude_scaffolds'])
34
+ options[:exclude_controllers] = Annotate::Helpers.true?(ENV.fetch('exclude_controllers', 'true'))
35
+ options[:exclude_helpers] = Annotate::Helpers.true?(ENV.fetch('exclude_helpers', 'true'))
36
+ options[:exclude_sti_subclasses] = Annotate::Helpers.true?(ENV['exclude_sti_subclasses'])
37
+ options[:ignore_model_sub_dir] = Annotate::Helpers.true?(ENV['ignore_model_sub_dir'])
38
+ options[:format_bare] = Annotate::Helpers.true?(ENV['format_bare'])
39
+ options[:format_rdoc] = Annotate::Helpers.true?(ENV['format_rdoc'])
40
+ options[:format_yard] = Annotate::Helpers.true?(ENV['format_yard'])
41
+ options[:format_markdown] = Annotate::Helpers.true?(ENV['format_markdown'])
42
+ options[:sort] = Annotate::Helpers.true?(ENV['sort'])
43
+ options[:force] = Annotate::Helpers.true?(ENV['force'])
44
+ options[:frozen] = Annotate::Helpers.true?(ENV['frozen'])
45
+ options[:classified_sort] = Annotate::Helpers.true?(ENV['classified_sort'])
46
+ options[:trace] = Annotate::Helpers.true?(ENV['trace'])
47
+ options[:wrapper_open] = Annotate::Helpers.fallback(ENV['wrapper_open'], ENV['wrapper'])
48
+ options[:wrapper_close] = Annotate::Helpers.fallback(ENV['wrapper_close'], ENV['wrapper'])
44
49
  options[:ignore_columns] = ENV.fetch('ignore_columns', nil)
50
+ options[:ignore_routes] = ENV.fetch('ignore_routes', nil)
51
+ options[:hide_limit_column_types] = Annotate::Helpers.fallback(ENV['hide_limit_column_types'], '')
52
+ options[:hide_default_column_types] = Annotate::Helpers.fallback(ENV['hide_default_column_types'], '')
53
+ options[:with_comment] = Annotate::Helpers.true?(ENV['with_comment'])
54
+ options[:ignore_unknown_models] = Annotate::Helpers.true?(ENV.fetch('ignore_unknown_models', 'false'))
45
55
 
46
56
  AnnotateModels.do_annotations(options)
47
57
  end
48
58
 
49
- desc "Remove schema information from model and fixture files"
50
- task :remove_annotation => :environment do
59
+ desc 'Remove schema information from model and fixture files'
60
+ task remove_annotation: :environment do
51
61
  require "#{annotate_lib}/annotate/annotate_models"
52
62
  require "#{annotate_lib}/annotate/active_record_patch"
53
63
 
54
- options={ :is_rake => true }
64
+ options = {is_rake: true}
55
65
  options[:model_dir] = ENV['model_dir']
56
66
  options[:root_dir] = ENV['root_dir']
57
67
  options[:require] = ENV['require'] ? ENV['require'].split(',') : []
58
- options[:trace] = Annotate.true?(ENV['trace'])
68
+ options[:trace] = Annotate::Helpers.true?(ENV['trace'])
59
69
  AnnotateModels.remove_annotations(options)
60
70
  end
@@ -4,21 +4,17 @@
4
4
  # Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
5
5
  # run after doing db:migrate.
6
6
 
7
- namespace :db do
8
- [:migrate, :rollback].each do |cmd|
9
- task cmd do
10
- Rake::Task['set_annotation_options'].invoke
7
+ %w(db:migrate db:migrate:up db:migrate:down db:migrate:reset db:migrate:redo db:rollback).each do |task|
8
+ Rake::Task[task].enhance do
9
+ Rake::Task[Rake.application.top_level_tasks.last].enhance do
10
+ annotation_options_task = if Rake::Task.task_defined?('app:set_annotation_options')
11
+ 'app:set_annotation_options'
12
+ else
13
+ 'set_annotation_options'
14
+ end
15
+ Rake::Task[annotation_options_task].invoke
11
16
  Annotate::Migration.update_annotations
12
17
  end
13
-
14
- namespace cmd do
15
- [:change, :up, :down, :reset, :redo].each do |t|
16
- task t do
17
- Rake::Task['set_annotation_options'].invoke
18
- Annotate::Migration.update_annotations
19
- end
20
- end
21
- end
22
18
  end
23
19
  end
24
20
 
@@ -27,11 +23,11 @@ module Annotate
27
23
  @@working = false
28
24
 
29
25
  def self.update_annotations
30
- unless @@working || Annotate.skip_on_migration?
26
+ unless @@working || Annotate::Helpers.skip_on_migration?
31
27
  @@working = true
32
28
 
33
- self.update_models if Annotate.include_models?
34
- self.update_routes if Annotate.include_routes?
29
+ self.update_models if Annotate::Helpers.include_models?
30
+ self.update_routes if Annotate::Helpers.include_routes?
35
31
  end
36
32
  end
37
33
 
@@ -46,6 +42,8 @@ module Annotate
46
42
  def self.update_routes
47
43
  if Rake::Task.task_defined?("annotate_routes")
48
44
  Rake::Task["annotate_routes"].invoke
45
+ elsif Rake::Task.task_defined?("app:annotate_routes")
46
+ Rake::Task["app:annotate_routes"].invoke
49
47
  end
50
48
  end
51
49
  end
@@ -4,9 +4,12 @@ task :annotate_routes => :environment do
4
4
  require "#{annotate_lib}/annotate/annotate_routes"
5
5
 
6
6
  options={}
7
- ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before')
8
- options[:position_in_routes] = Annotate.fallback(ENV['position_in_routes'], ENV['position'])
7
+ ENV['position'] = options[:position] = Annotate::Helpers.fallback(ENV['position'], 'before')
8
+ options[:position_in_routes] = Annotate::Helpers.fallback(ENV['position_in_routes'], ENV['position'])
9
+ options[:ignore_routes] = Annotate::Helpers.fallback(ENV['ignore_routes'], nil)
9
10
  options[:require] = ENV['require'] ? ENV['require'].split(',') : []
11
+ options[:wrapper_open] = Annotate::Helpers.fallback(ENV['wrapper_open'], ENV['wrapper'])
12
+ options[:wrapper_close] = Annotate::Helpers.fallback(ENV['wrapper_close'], ENV['wrapper'])
10
13
  AnnotateRoutes.do_annotations(options)
11
14
  end
12
15
 
data/potato.md ADDED
@@ -0,0 +1,41 @@
1
+ Colons can be used to align columns.
2
+
3
+ | Tables | Are | Cool |
4
+ | ------------- |:-------------:| -----:|
5
+ | col 3 is | right-aligned | $1600 |
6
+ | col 2 is | centered | $12 |
7
+ | zebra stripes | are neat | $1 |
8
+
9
+ There must be at least 3 dashes separating each header cell.
10
+ The outer pipes (|) are optional, and you don't need to make the
11
+ raw Markdown line up prettily. You can also use inline Markdown.
12
+
13
+ Markdown | Less | Pretty
14
+ --- | --- | ---
15
+ *Still* | `renders` | **nicely**
16
+ 1 | 2 | 3
17
+
18
+
19
+ ## Route Map
20
+
21
+  Prefix | Verb | URI Pattern | Controller#Action
22
+ --------- | ---------- | --------------- | --------------------
23
+ myaction1 | GET | /url1(.:format) | mycontroller1#action
24
+ myaction2 | POST | /url2(.:format) | mycontroller2#action
25
+  myaction3 | DELETE-GET | /url3(.:format) | mycontroller3#action \n")
26
+
27
+
28
+
29
+ Table name: `users`
30
+
31
+ ### Columns
32
+
33
+ Name | Type | Attributes
34
+ ----------------------- | ------------------ | ---------------------------
35
+ **`id`** | `integer` | `not null, primary key`
36
+ **`foreign_thing_id`** | `integer` | `not null`
37
+
38
+ ### Foreign Keys
39
+
40
+ * `fk_rails_...` (_ON DELETE => on_delete_value ON UPDATE => on_update_value_):
41
+ * **`foreign_thing_id => foreign_things.id`**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
@@ -12,22 +12,28 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-12-30 00:00:00.000000000 Z
15
+ date: 2020-03-24 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "~>"
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '10.4'
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: '14.0'
24
27
  type: :runtime
25
28
  prerelease: false
26
29
  version_requirements: !ruby/object:Gem::Requirement
27
30
  requirements:
28
- - - "~>"
31
+ - - ">="
29
32
  - !ruby/object:Gem::Version
30
33
  version: '10.4'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '14.0'
31
37
  - !ruby/object:Gem::Dependency
32
38
  name: activerecord
33
39
  requirement: !ruby/object:Gem::Requirement
@@ -37,7 +43,7 @@ dependencies:
37
43
  version: '3.2'
38
44
  - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '6.0'
46
+ version: '7.0'
41
47
  type: :runtime
42
48
  prerelease: false
43
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,7 +53,7 @@ dependencies:
47
53
  version: '3.2'
48
54
  - - "<"
49
55
  - !ruby/object:Gem::Version
50
- version: '6.0'
56
+ version: '7.0'
51
57
  description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
52
58
  on the database schema.
53
59
  email:
@@ -60,33 +66,38 @@ executables:
60
66
  - annotate
61
67
  extensions: []
62
68
  extra_rdoc_files:
63
- - README.rdoc
64
- - CHANGELOG.rdoc
65
- - TODO.rdoc
69
+ - README.md
70
+ - CHANGELOG.md
66
71
  files:
67
- - AUTHORS.rdoc
68
- - CHANGELOG.rdoc
72
+ - AUTHORS.md
73
+ - CHANGELOG.md
69
74
  - LICENSE.txt
70
- - README.rdoc
71
- - TODO.rdoc
75
+ - README.md
76
+ - RELEASE.md
72
77
  - annotate.gemspec
73
78
  - bin/annotate
74
79
  - lib/annotate.rb
75
80
  - lib/annotate/active_record_patch.rb
76
81
  - lib/annotate/annotate_models.rb
77
82
  - lib/annotate/annotate_routes.rb
83
+ - lib/annotate/annotate_routes/helpers.rb
84
+ - lib/annotate/constants.rb
85
+ - lib/annotate/helpers.rb
86
+ - lib/annotate/parser.rb
78
87
  - lib/annotate/tasks.rb
79
88
  - lib/annotate/version.rb
80
89
  - lib/generators/annotate/USAGE
81
90
  - lib/generators/annotate/install_generator.rb
82
91
  - lib/generators/annotate/templates/auto_annotate_models.rake
83
92
  - lib/tasks/annotate_models.rake
93
+ - lib/tasks/annotate_models_migrate.rake
84
94
  - lib/tasks/annotate_routes.rake
85
- - lib/tasks/migrate.rake
95
+ - potato.md
86
96
  homepage: http://github.com/ctran/annotate_models
87
97
  licenses:
88
98
  - Ruby
89
- metadata: {}
99
+ metadata:
100
+ github_repo: ssh://github.com/ctran/annotate_models
90
101
  post_install_message:
91
102
  rdoc_options: []
92
103
  require_paths:
@@ -95,18 +106,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
106
  requirements:
96
107
  - - ">="
97
108
  - !ruby/object:Gem::Version
98
- version: 1.9.3
109
+ version: 2.4.0
99
110
  required_rubygems_version: !ruby/object:Gem::Requirement
100
111
  requirements:
101
112
  - - ">="
102
113
  - !ruby/object:Gem::Version
103
114
  version: '0'
104
115
  requirements: []
105
- rubyforge_project: annotate
106
- rubygems_version: 2.5.0
116
+ rubyforge_project:
117
+ rubygems_version: 2.7.7
107
118
  signing_key:
108
119
  specification_version: 4
109
120
  summary: Annotates Rails Models, routes, fixtures, and others based on the database
110
121
  schema.
111
122
  test_files: []
112
- has_rdoc: