codeape-annotate 2.0.0.20090212001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +28 -0
- data/License.txt +21 -0
- data/Manifest.txt +22 -0
- data/README.rdoc +95 -0
- data/Rakefile +28 -0
- data/annotate_models.gemspec +39 -0
- data/bin/annotate +22 -0
- data/lib/annotate.rb +14 -0
- data/lib/annotate/annotate_models.rb +222 -0
- data/lib/annotate/annotate_routes.rb +41 -0
- data/lib/tasks/annotate_models.rake +14 -0
- data/lib/tasks/annotate_routes.rake +5 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/setup.rb +1585 -0
- data/spec/annotate/annotate_models_spec.rb +43 -0
- data/spec/annotate/annotate_routes_spec.rb +47 -0
- data/spec/annotate_spec.rb +9 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/rspec.rake +21 -0
- metadata +97 -0
@@ -0,0 +1,43 @@
|
|
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
|
+
]), "Schema Info").should eql(<<-EOS)
|
31
|
+
# Schema Info
|
32
|
+
#
|
33
|
+
# Table name: users
|
34
|
+
#
|
35
|
+
# id :integer not null, primary key
|
36
|
+
# id :integer not null, primary key
|
37
|
+
#
|
38
|
+
|
39
|
+
EOS
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
describe "Annotate Job" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
File.should_receive(:join).with("config", "routes.rb").and_return("config/routes.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should check if routes.rb exists" do
|
17
|
+
File.should_receive(:exists?).with("config/routes.rb").and_return(false)
|
18
|
+
AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb")
|
19
|
+
AnnotateRoutes.do_annotate
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "When Annotating" do
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
File.should_receive(:exists?).with("config/routes.rb").and_return(true)
|
26
|
+
AnnotateRoutes.should_receive(:`).with("rake routes").and_return("bad line\ngood line")
|
27
|
+
File.should_receive(:open).with("config/routes.rb", "wb").and_yield(mock_file)
|
28
|
+
AnnotateRoutes.should_receive(:puts).with("Route file annotated.")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should annotate and add a newline!" do
|
32
|
+
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo")
|
33
|
+
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
|
34
|
+
AnnotateRoutes.do_annotate
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not add a newline if there are empty lines" do
|
38
|
+
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n")
|
39
|
+
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
|
40
|
+
AnnotateRoutes.do_annotate
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codeape-annotate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0.20090212001
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan Cheail
|
8
|
+
- Cuong Tran
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-02-03 00:00:00 -08:00
|
14
|
+
default_executable: annotate
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: newgem
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
version_requirement:
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.8.0
|
33
|
+
version:
|
34
|
+
description: Annotates Rails Models, routes, and others
|
35
|
+
email:
|
36
|
+
- ctran@pragmaquest.com
|
37
|
+
executables:
|
38
|
+
- annotate
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- History.txt
|
43
|
+
- License.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- History.txt
|
48
|
+
- License.txt
|
49
|
+
- Manifest.txt
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- annotate_models.gemspec
|
53
|
+
- bin/annotate
|
54
|
+
- lib/annotate.rb
|
55
|
+
- lib/annotate/annotate_models.rb
|
56
|
+
- lib/annotate/annotate_routes.rb
|
57
|
+
- lib/tasks/annotate_models.rake
|
58
|
+
- lib/tasks/annotate_routes.rake
|
59
|
+
- script/console
|
60
|
+
- script/destroy
|
61
|
+
- script/generate
|
62
|
+
- setup.rb
|
63
|
+
- spec/annotate/annotate_models_spec.rb
|
64
|
+
- spec/annotate/annotate_routes_spec.rb
|
65
|
+
- spec/annotate_spec.rb
|
66
|
+
- spec/spec.opts
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- tasks/rspec.rake
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/ctran/annotate_models
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options:
|
73
|
+
- --main
|
74
|
+
- README.rdoc
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: annotate
|
92
|
+
rubygems_version: 1.2.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: Annotates Rails Models, routes, and others
|
96
|
+
test_files: []
|
97
|
+
|