nofxx-annotate 2.1.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +12 -12
- data/annotate.gemspec +2 -2
- data/lib/{annotate_models → annotate}/annotate_models.rb +10 -6
- data/lib/{annotate_routes → annotate}/annotate_routes.rb +2 -2
- data/lib/annotate.rb +1 -1
- data/lib/tasks/annotate_models.rake +1 -1
- data/lib/tasks/annotate_routes.rake +1 -1
- data/spec/annotate/annotate_models_spec.rb +35 -0
- data/spec/annotate/annotate_routes_spec.rb +30 -0
- data/spec/annotate_spec.rb +3 -5
- metadata +5 -5
- data/config/hoe.rb +0 -69
- data/config/requirements.rb +0 -17
data/Manifest.txt
CHANGED
@@ -5,17 +5,17 @@ README.rdoc
|
|
5
5
|
Rakefile
|
6
6
|
annotate.gemspec
|
7
7
|
bin/annotate
|
8
|
-
config/hoe.rb
|
9
|
-
config/requirements.rb
|
10
8
|
lib/annotate.rb
|
11
|
-
lib/
|
12
|
-
lib/
|
9
|
+
lib/annotate/annotate_models.rb
|
10
|
+
lib/annotate/annotate_routes.rb
|
13
11
|
lib/tasks/annotate_models.rake
|
14
12
|
lib/tasks/annotate_routes.rake
|
15
13
|
script/console
|
16
14
|
script/destroy
|
17
15
|
script/generate
|
18
16
|
setup.rb
|
17
|
+
spec/annotate/annotate_models_spec.rb
|
18
|
+
spec/annotate/annotate_routes_spec.rb
|
19
19
|
spec/annotate_spec.rb
|
20
20
|
spec/spec.opts
|
21
21
|
spec/spec_helper.rb
|
@@ -27,17 +27,17 @@ README.rdoc
|
|
27
27
|
Rakefile
|
28
28
|
annotate.gemspec
|
29
29
|
bin/annotate
|
30
|
-
config/hoe.rb
|
31
|
-
config/requirements.rb
|
32
30
|
lib/annotate.rb
|
33
|
-
lib/
|
34
|
-
lib/
|
31
|
+
lib/annotate/annotate_models.rb
|
32
|
+
lib/annotate/annotate_routes.rb
|
35
33
|
lib/tasks/annotate_models.rake
|
36
34
|
lib/tasks/annotate_routes.rake
|
37
35
|
script/console
|
38
36
|
script/destroy
|
39
37
|
script/generate
|
40
38
|
setup.rb
|
39
|
+
spec/annotate/annotate_models_spec.rb
|
40
|
+
spec/annotate/annotate_routes_spec.rb
|
41
41
|
spec/annotate_spec.rb
|
42
42
|
spec/spec.opts
|
43
43
|
spec/spec_helper.rb
|
@@ -49,17 +49,17 @@ README.rdoc
|
|
49
49
|
Rakefile
|
50
50
|
annotate.gemspec
|
51
51
|
bin/annotate
|
52
|
-
config/hoe.rb
|
53
|
-
config/requirements.rb
|
54
52
|
lib/annotate.rb
|
55
|
-
lib/
|
56
|
-
lib/
|
53
|
+
lib/annotate/annotate_models.rb
|
54
|
+
lib/annotate/annotate_routes.rb
|
57
55
|
lib/tasks/annotate_models.rake
|
58
56
|
lib/tasks/annotate_routes.rake
|
59
57
|
script/console
|
60
58
|
script/destroy
|
61
59
|
script/generate
|
62
60
|
setup.rb
|
61
|
+
spec/annotate/annotate_models_spec.rb
|
62
|
+
spec/annotate/annotate_routes_spec.rb
|
63
63
|
spec/annotate_spec.rb
|
64
64
|
spec/spec.opts
|
65
65
|
spec/spec_helper.rb
|
data/annotate.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{annotate}
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.2.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marcos Piccinini"]
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.email = ["x@nofxx.com"]
|
13
13
|
s.executables = ["annotate"]
|
14
14
|
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc"]
|
15
|
-
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "annotate.gemspec", "bin/annotate", "
|
15
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "script/console", "script/destroy", "script/generate", "setup.rb", "spec/annotate/annotate_models_spec.rb", "spec/annotate/annotate_routes_spec.rb", "spec/annotate_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.homepage = %q{http://github.com/nofxx/annotate}
|
18
18
|
s.rdoc_options = ["--main", "README.rdoc"]
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module AnnotateModels
|
2
2
|
class << self
|
3
|
+
# Annotate Models plugin use this header
|
4
|
+
COMPAT_PREFIX = "== Schema Info"
|
5
|
+
PREFIX = "== Schema Information"
|
6
|
+
|
3
7
|
MODEL_DIR = "app/models"
|
4
8
|
FIXTURE_DIRS = ["test/fixtures","spec/fixtures"]
|
5
|
-
|
6
|
-
|
9
|
+
# File.join for windows reverse bar compat?
|
10
|
+
# I dont use windows, can`t test
|
11
|
+
UNIT_TEST_DIR = File.join("test", "unit" )
|
12
|
+
SPEC_MODEL_DIR = File.join("spec", "models")
|
7
13
|
# Object Daddy http://github.com/flogic/object_daddy/tree/master
|
8
|
-
EXEMPLARS_DIR = File.join(
|
9
|
-
|
10
|
-
# Annotate Models as plugin use this header
|
11
|
-
COMPAT_PREFIX = "== Schema Info"
|
14
|
+
EXEMPLARS_DIR = File.join("spec", "exemplars")
|
15
|
+
|
12
16
|
|
13
17
|
# Simple quoting for the default column value
|
14
18
|
def quote(value)
|
@@ -20,8 +20,8 @@ module AnnotateRoutes
|
|
20
20
|
PREFIX = "#== Route Info"
|
21
21
|
|
22
22
|
def self.do_annotate
|
23
|
-
routes_rb = File.join(
|
24
|
-
header = PREFIX + "\n# Generated on #{Time.now}"
|
23
|
+
routes_rb = File.join("config", "routes.rb")
|
24
|
+
header = PREFIX + "\n# Generated on #{Time.now}\n#"
|
25
25
|
if File.exists? routes_rb
|
26
26
|
routes_map = `rake routes`
|
27
27
|
routes_map = routes_map.split("\n")
|
data/lib/annotate.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
desc "Add schema information (as comments) to model and fixture files"
|
2
2
|
task :annotate_models => :environment do
|
3
|
-
require '
|
3
|
+
require 'annotate/annotate_models'
|
4
4
|
options={}
|
5
5
|
options[:position_in_class] = ENV['position_in_class'] || ENV['position']
|
6
6
|
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
require 'annotate/annotate_models'
|
3
|
+
|
4
|
+
describe AnnotateModels do
|
5
|
+
|
6
|
+
def mock_klass(stubs={})
|
7
|
+
@mock_file ||= mock("Klass", stubs)
|
8
|
+
end
|
9
|
+
|
10
|
+
def mock_column(stubs={})
|
11
|
+
@mock_column ||= mock("Column", stubs)
|
12
|
+
end
|
13
|
+
|
14
|
+
it { AnnotateModels.quote(nil).should eql("NULL") }
|
15
|
+
it { AnnotateModels.quote(true).should eql("TRUE") }
|
16
|
+
it { AnnotateModels.quote(false).should eql("FALSE") }
|
17
|
+
it { AnnotateModels.quote(25).should eql("25") }
|
18
|
+
it { AnnotateModels.quote(25.6).should eql("25.6") }
|
19
|
+
it { AnnotateModels.quote(1e-20).should eql("1.0e-20") }
|
20
|
+
|
21
|
+
it "should get schema info" do
|
22
|
+
|
23
|
+
AnnotateModels.get_schema_info(mock_klass(
|
24
|
+
:table_name => "users",
|
25
|
+
:primary_key => "id",
|
26
|
+
:column_names => ["id","login"],
|
27
|
+
:columns => [
|
28
|
+
mock_column(:type => "integer", :default => nil, :null => false, :name => "id", :limit => nil),
|
29
|
+
mock_column(:type => "string", :default => nil, :null => false, :name => "name", :limit => 50)
|
30
|
+
]), "Hello").should eql("# Hello\n#\n# Table name: users\n#\n# id :integer not null, primary key\n# id :integer not null, primary key\n#\n\n")
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
require 'annotate/annotate_routes'
|
3
|
+
|
4
|
+
describe AnnotateRoutes do
|
5
|
+
|
6
|
+
def mock_file(stubs={})
|
7
|
+
@mock_file ||= mock(File, stubs)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should check if routes.rb exists" do
|
11
|
+
File.should_receive(:join).with("config", "routes.rb").and_return(mock_file)
|
12
|
+
File.should_receive(:exists?).with(@mock_file).and_return(false)
|
13
|
+
AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb")
|
14
|
+
|
15
|
+
AnnotateRoutes.do_annotate
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should annotate!" do
|
19
|
+
File.should_receive(:join).with("config", "routes.rb").and_return("config/routes.rb")
|
20
|
+
File.should_receive(:exists?).with("config/routes.rb").and_return(true)
|
21
|
+
AnnotateRoutes.should_receive(:`).with("rake routes").and_return("bad line\ngood line")
|
22
|
+
File.should_receive(:read).with("config/routes.rb").and_return("bla")
|
23
|
+
File.should_receive(:open).with("config/routes.rb", "wb").and_yield(mock_file)
|
24
|
+
@mock_file.should_receive(:puts).with(/bla\n\n#== Route Info\n# Generated on .*\n#\n# good line/)
|
25
|
+
|
26
|
+
AnnotateRoutes.do_annotate
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
data/spec/annotate_spec.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
# http://rspec.info/
|
5
|
-
describe "Place your specs here" do
|
3
|
+
describe Annotate do
|
6
4
|
|
7
|
-
it "
|
8
|
-
|
5
|
+
it "should have a version" do
|
6
|
+
Annotate::VERSION.should be_instance_of(String)
|
9
7
|
end
|
10
8
|
|
11
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nofxx-annotate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
@@ -50,17 +50,17 @@ files:
|
|
50
50
|
- Rakefile
|
51
51
|
- annotate.gemspec
|
52
52
|
- bin/annotate
|
53
|
-
- config/hoe.rb
|
54
|
-
- config/requirements.rb
|
55
53
|
- lib/annotate.rb
|
56
|
-
- lib/
|
57
|
-
- lib/
|
54
|
+
- lib/annotate/annotate_models.rb
|
55
|
+
- lib/annotate/annotate_routes.rb
|
58
56
|
- lib/tasks/annotate_models.rake
|
59
57
|
- lib/tasks/annotate_routes.rake
|
60
58
|
- script/console
|
61
59
|
- script/destroy
|
62
60
|
- script/generate
|
63
61
|
- setup.rb
|
62
|
+
- spec/annotate/annotate_models_spec.rb
|
63
|
+
- spec/annotate/annotate_routes_spec.rb
|
64
64
|
- spec/annotate_spec.rb
|
65
65
|
- spec/spec.opts
|
66
66
|
- spec/spec_helper.rb
|
data/config/hoe.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'annotate_models/version'
|
2
|
-
|
3
|
-
AUTHOR = 'Dave Thomas' # can also be an array of Authors
|
4
|
-
EMAIL = "ctran@pragmaquest.com"
|
5
|
-
DESCRIPTION = "Add a comment summarizing the current schema to the top of each ActiveRecord model source file"
|
6
|
-
GEM_NAME = 'annotate-models' # what ppl will type to install your gem
|
7
|
-
RUBYFORGE_PROJECT = 'annotate-models' # The unix name for your project
|
8
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
-
|
11
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
-
@config = nil
|
13
|
-
RUBYFORGE_USERNAME = "unknown"
|
14
|
-
def rubyforge_username
|
15
|
-
unless @config
|
16
|
-
begin
|
17
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
-
rescue
|
19
|
-
puts <<-EOS
|
20
|
-
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
-
EOS
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
end
|
27
|
-
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
REV = nil
|
32
|
-
# UNCOMMENT IF REQUIRED:
|
33
|
-
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
-
VERS = AnnotateModels::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
-
RDOC_OPTS = ['--quiet', '--title', 'annotate_models documentation',
|
36
|
-
"--opname", "index.html",
|
37
|
-
"--line-numbers",
|
38
|
-
"--main", "README",
|
39
|
-
"--inline-source"]
|
40
|
-
|
41
|
-
class Hoe
|
42
|
-
def extra_deps
|
43
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
-
@extra_deps
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Generate all the Rake tasks
|
49
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
-
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
-
p.developer(AUTHOR, EMAIL)
|
52
|
-
p.description = DESCRIPTION
|
53
|
-
p.summary = DESCRIPTION
|
54
|
-
p.url = HOMEPATH
|
55
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
56
|
-
p.test_globs = ["test/**/test_*.rb"]
|
57
|
-
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
58
|
-
|
59
|
-
# == Optional
|
60
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
61
|
-
p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
62
|
-
p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
67
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
68
|
-
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
69
|
-
hoe.rsync_args = '-av --delete --ignore-errors'
|
data/config/requirements.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
include FileUtils
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
-
begin
|
7
|
-
require req_gem
|
8
|
-
rescue LoadError
|
9
|
-
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
-
puts "Installation: gem install #{req_gem} -y"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
-
|
17
|
-
require 'annotate_models'
|