mactag 0.0.1

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.
Files changed (42) hide show
  1. data/README.markdown +68 -0
  2. data/VERSION +1 -0
  3. data/features/app.feature +35 -0
  4. data/features/gem.feature +59 -0
  5. data/features/plugin.feature +41 -0
  6. data/features/rails/actionmailer/lib/action_mailer/base.rb +9 -0
  7. data/features/rails/actionpack/lib/action_controller/caching/actions.rb +11 -0
  8. data/features/rails/actionpack/lib/action_view/action_view/helpers/form_tag_helper.rb +9 -0
  9. data/features/rails/activerecord/lib/active_record/associations.rb +9 -0
  10. data/features/rails/activeresource/lib/active_resource/connection.rb +7 -0
  11. data/features/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +5 -0
  12. data/features/rails_gem.feature +69 -0
  13. data/features/rails_vendor.feature +46 -0
  14. data/features/step_definitions/app_steps.rb +11 -0
  15. data/features/step_definitions/gem_steps.rb +40 -0
  16. data/features/step_definitions/mactab_steps.rb +53 -0
  17. data/features/step_definitions/plugin_steps.rb +34 -0
  18. data/features/step_definitions/rails_steps.rb +62 -0
  19. data/features/support/core_ext.rb +5 -0
  20. data/features/support/env.rb +10 -0
  21. data/features/support/rails_app.rb +74 -0
  22. data/features/support/tags_file.rb +21 -0
  23. data/generators/mactag/mactag_generator.rb +10 -0
  24. data/generators/mactag/templates/mactag.rb +11 -0
  25. data/lib/mactag.rb +6 -0
  26. data/lib/mactag/config.rb +20 -0
  27. data/lib/mactag/table.rb +45 -0
  28. data/lib/mactag/tag.rb +8 -0
  29. data/lib/mactag/tag/app.rb +30 -0
  30. data/lib/mactag/tag/gem.rb +46 -0
  31. data/lib/mactag/tag/parser.rb +33 -0
  32. data/lib/mactag/tag/plugin.rb +32 -0
  33. data/lib/mactag/tag/rails.rb +138 -0
  34. data/lib/mactag/tasks.rb +10 -0
  35. data/tasks/mactag_tasks.rake +1 -0
  36. data/test/mactag/config_test.rb +10 -0
  37. data/test/mactag/tag/app_test.rb +16 -0
  38. data/test/mactag/tag/gem_test.rb +42 -0
  39. data/test/mactag/tag/plugin_test.rb +40 -0
  40. data/test/mactag/tag/rails_test.rb +182 -0
  41. data/test/mactag_test.rb +4 -0
  42. metadata +94 -0
@@ -0,0 +1,68 @@
1
+ # Mactag
2
+
3
+ Mactag is a plugin for Rails developers that do their development in
4
+ an editor that supports Ctags (Emacs, Vim, jEdit, ...). With Ctags
5
+ you can follow tags (of functions, variables, macros, whatever) to
6
+ their definitions.
7
+
8
+ # Exuberant Ctags
9
+ First off you must install [Ctags](http://ctags.sourceforge.net/).
10
+ Some systems comes with a ctags command already. If you have the ctags
11
+ executable, but have problems creating the tags file. Then make sure
12
+ that you are using *Exuberant Ctags* and not some other version.
13
+
14
+ # Installation
15
+
16
+ ## Plugin
17
+
18
+ Install the plugin:
19
+
20
+ $ ./script/plugin install git://github.com/rejeep/mactag.git
21
+
22
+ ## Gem
23
+
24
+ Install the gem:
25
+
26
+ $ sudo gem install mactag
27
+
28
+ If you install mactag as a gem you must also include it's rake tasks in your *Rakefile*.
29
+
30
+ require 'mactag/tasks'
31
+
32
+ # Configuration
33
+
34
+ Generate a basic configuration file:
35
+
36
+ $ ./script/generate mactag
37
+
38
+ This will create the file **config/mactag.rb**, which contains
39
+ some examples of how to set it up.
40
+
41
+ ## Options
42
+
43
+ * **Mactag::Config.gem_home:** The path where the gems are located. Defaults to **/usr/lib/ruby/gems/1.8/gems**
44
+ * **Mactag::Config.binary:** The command to run when creating the TAGS-file. Defaults to **ctags -o TAGS -e**
45
+
46
+ ## Example mactag.rb file
47
+ Mactag::Config.gem_home = "/usr/lib/ruby/gems/1.9/gems"
48
+ Mactag::Config.binary = "etags -o TAGS"
49
+
50
+ Mactag::Table.generate do
51
+ app "app/**/*.rb", "lib/*.rb"
52
+
53
+ plugins "thinking-sphinx", "whenever"
54
+
55
+ gems "paperclip", "authlogic"
56
+ gem "formtastic", :version => "0.9.7"
57
+
58
+ rails :except => :actionmailer, :version => "2.3.5"
59
+ end
60
+
61
+ # Usage
62
+
63
+ To create the TAGS file. Simpy run:
64
+ $ rake mactag
65
+
66
+ # License
67
+
68
+ Copyright (c) 2010 Johan Andersson, released under the MIT license
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,35 @@
1
+ Feature: Tag application files
2
+ In order to create a TAGS file
3
+ As a user
4
+ I want to tag application files
5
+
6
+ Background:
7
+ Given a Rails application
8
+ And mactag is installed
9
+
10
+ Scenario: Tag single file
11
+ Given a javascript function "show" in "whitebox"
12
+ And an app mactag config with the following tags
13
+ | tag |
14
+ | public/javascripts/whitebox.js |
15
+ When I create the tags file
16
+ Then the tags file should contain "show"
17
+
18
+ Scenario: Tag multiple files
19
+ Given a javascript function "hide" in "whitebox"
20
+ And a ruby method "to_s" in the "user" model
21
+ And an app mactag config with the following tags
22
+ | tag |
23
+ | public/javascripts/whitebox.js |
24
+ | app/models/user.rb |
25
+ When I create the tags file
26
+ Then the tags file should contain "hide"
27
+ And the tags file should contain "to_s"
28
+
29
+ Scenario: Tag files recursive
30
+ Given a ruby method "kill!" in the "user" model
31
+ And an app mactag config with the following tags
32
+ | tag |
33
+ | app/**/*.rb |
34
+ When I create the tags file
35
+ Then the tags file should contain "kill!"
@@ -0,0 +1,59 @@
1
+ Feature: Tag Gems
2
+ In order to create a TAGS file
3
+ As a user
4
+ I want to tag gems
5
+
6
+ Background:
7
+ Given a Rails application
8
+ And mactag is installed
9
+
10
+ Scenario: Tag single gem
11
+ Given the gem "superduper" version "1.0.0" is installed
12
+ And an acts as method for the "superduper-1.0.0" gem
13
+ And a gem mactag config with the following tags
14
+ | tag |
15
+ | superduper |
16
+ When I create the tags file
17
+ Then the tags file should contain "acts_as_superduper"
18
+
19
+ Scenario: Tag multiple gems
20
+ Given the gem "superduper" version "1.0.0" is installed
21
+ And the gem "dunder" version "1.0.0" is installed
22
+ And an acts as method for the "superduper-1.0.0" gem
23
+ And an acts as method for the "dunder-1.0.0" gem
24
+ And a gem mactag config with the following tags
25
+ | tag |
26
+ | superduper |
27
+ | dunder |
28
+ When I create the tags file
29
+ Then the tags file should contain "acts_as_superduper"
30
+ Then the tags file should contain "acts_as_dunder"
31
+
32
+ Scenario: Tag specific version
33
+ Given the gem "superduper" version "1.0.0" is installed
34
+ And the gem "superduper" version "1.0.1" is installed
35
+ And an acts as method for the "superduper-1.0.0" gem
36
+ And an acts as method for the "superduper-1.0.1" gem
37
+ And a gem mactag config with the following tags
38
+ | tag | version |
39
+ | superduper | 1.0.0 |
40
+ When I create the tags file
41
+ Then the tags file should contain "acts_as_superduper"
42
+ And the tags file should contain "1.0.0"
43
+ And the tags file should not contain "1.0.1"
44
+
45
+ Scenario: Tag latest version
46
+ Given the gem "superduper" version "1.0.2" is installed
47
+ And the gem "superduper" version "1.0.1" is installed
48
+ And the gem "superduper" version "1.0.0" is installed
49
+ And an acts as method for the "superduper-1.0.2" gem
50
+ And an acts as method for the "superduper-1.0.1" gem
51
+ And an acts as method for the "superduper-1.0.0" gem
52
+ And a gem mactag config with the following tags
53
+ | tag |
54
+ | superduper |
55
+ When I create the tags file
56
+ Then the tags file should contain "acts_as_superduper"
57
+ And the tags file should contain "1.0.2"
58
+ And the tags file should not contain "1.0.0"
59
+ And the tags file should not contain "1.0.1"
@@ -0,0 +1,41 @@
1
+ Feature: Tag Plugins
2
+ In order to create a TAGS file
3
+ As a user
4
+ I want to tag plugins
5
+
6
+ Background:
7
+ Given a Rails application
8
+ And mactag is installed
9
+
10
+ Scenario: Tag single plugin
11
+ Given the plugin "superduper" is installed
12
+ And an acts as method for the "superduper" plugin
13
+ And a plugin mactag config with the following tags
14
+ | tag |
15
+ | superduper |
16
+ When I create the tags file
17
+ Then the tags file should contain "acts_as_superduper"
18
+
19
+ Scenario: Tag multiple plugins
20
+ Given the plugin "superduper" is installed
21
+ And the plugin "dunder" is installed
22
+ And an acts as method for the "superduper" plugin
23
+ And an acts as method for the "dunder" plugin
24
+ And a plugin mactag config with the following tags
25
+ | tag |
26
+ | superduper |
27
+ | dunder |
28
+ When I create the tags file
29
+ Then the tags file should contain "acts_as_superduper"
30
+ Then the tags file should contain "acts_as_dunder"
31
+
32
+ Scenario: Tag all plugins
33
+ Given the plugin "superduper" is installed
34
+ And the plugin "dunder" is installed
35
+ And an acts as method for the "superduper" plugin
36
+ And an acts as method for the "dunder" plugin
37
+ And a plugin mactag config with the following tags
38
+ | tag |
39
+ When I create the tags file
40
+ Then the tags file should contain "acts_as_superduper"
41
+ Then the tags file should contain "acts_as_dunder"
@@ -0,0 +1,9 @@
1
+ module ActionMailer #:nodoc:
2
+ class Base
3
+ class << self
4
+ def deliver(mail)
5
+ # ...
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module ActionController
2
+ module Caching
3
+ module Actions
4
+ module ClassMethods
5
+ def caches_action(*actions)
6
+ # ...
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module ActionView
2
+ module Helpers
3
+ module FormTagHelper
4
+ def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block)
5
+ # ...
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveRecord
2
+ module Association
3
+ module ClassMethods
4
+ def has_many(association_id, options = {}, &extension)
5
+ # ...
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module ActiveResource
2
+ class Connection
3
+ def get(path, headers = {})
4
+ # ...
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class Hash
2
+ def diff(h2)
3
+ # ...
4
+ end
5
+ end
@@ -0,0 +1,69 @@
1
+ Feature: Tag Rails as a Gem
2
+ In order to create a TAGS file
3
+ As a user
4
+ I want to tag Rails
5
+
6
+ Background:
7
+ Given a Rails application
8
+ And mactag is installed
9
+
10
+ Scenario: Tag all packages
11
+ Given rails is installed as a gem
12
+ And a rails mactag config with the following tags
13
+ | tag |
14
+ When I create the tags file
15
+ Then the tags file should contain "diff"
16
+ And the tags file should contain "get"
17
+ And the tags file should contain "has_many"
18
+ And the tags file should contain "deliver"
19
+ And the tags file should contain "caches_action"
20
+ And the tags file should contain "form_tag"
21
+
22
+ Scenario: Tag only some packages
23
+ Given rails is installed as a gem
24
+ And a rails mactag config with the following tags
25
+ | only |
26
+ | activerecord |
27
+ | activesupport |
28
+ When I create the tags file
29
+ Then the tags file should contain "diff"
30
+ And the tags file should contain "has_many"
31
+ And the tags file should not contain "get"
32
+ And the tags file should not contain "deliver"
33
+ And the tags file should not contain "caches_action"
34
+ And the tags file should not contain "form_tag"
35
+
36
+ Scenario: Tag all except some packages
37
+ Given rails is installed as a gem
38
+ And a rails mactag config with the following tags
39
+ | except |
40
+ | actioncontroller |
41
+ | actionview |
42
+ When I create the tags file
43
+ Then the tags file should contain "diff"
44
+ And the tags file should contain "has_many"
45
+ And the tags file should contain "get"
46
+ And the tags file should contain "deliver"
47
+ And the tags file should not contain "caches_action"
48
+ And the tags file should not contain "form_tag"
49
+
50
+ Scenario: Tag specific version
51
+ Given rails version "3.0.0" is installed as a gem
52
+ And rails version "2.3.5" is installed as a gem
53
+ And a rails mactag config with the following tags
54
+ | version |
55
+ | 3.0.0 |
56
+ When I create the tags file
57
+ Then the tags file should contain "3.0.0"
58
+ And the tags file should not contain "2.3.5"
59
+
60
+ Scenario: Tag latest version
61
+ Given rails version "3.0.0" is installed as a gem
62
+ And rails version "2.3.5" is installed as a gem
63
+ And rails version "2.3.2" is installed as a gem
64
+ And a rails mactag config with the following tags
65
+ | tag |
66
+ When I create the tags file
67
+ Then the tags file should contain "3.0.0"
68
+ And the tags file should not contain "2.3.2"
69
+ And the tags file should not contain "2.3.5"
@@ -0,0 +1,46 @@
1
+ Feature: Tag Rails in vendor
2
+ In order to create a TAGS file
3
+ As a user
4
+ I want to tag Rails
5
+
6
+ Background:
7
+ Given a Rails application
8
+ And mactag is installed
9
+ And rails lives in vendor
10
+
11
+ Scenario: Tag all packages
12
+ Given a rails mactag config with the following tags
13
+ | tag |
14
+ When I create the tags file
15
+ Then the tags file should contain "diff"
16
+ And the tags file should contain "get"
17
+ And the tags file should contain "has_many"
18
+ And the tags file should contain "deliver"
19
+ And the tags file should contain "caches_action"
20
+ And the tags file should contain "form_tag"
21
+
22
+ Scenario: Tag only some packages
23
+ Given a rails mactag config with the following tags
24
+ | only |
25
+ | activerecord |
26
+ | active_support |
27
+ When I create the tags file
28
+ Then the tags file should contain "diff"
29
+ And the tags file should contain "has_many"
30
+ And the tags file should not contain "get"
31
+ And the tags file should not contain "deliver"
32
+ And the tags file should not contain "caches_action"
33
+ And the tags file should not contain "form_tag"
34
+
35
+ Scenario: Tag all except some packages
36
+ Given a rails mactag config with the following tags
37
+ | except |
38
+ | action_controller |
39
+ | actionview |
40
+ When I create the tags file
41
+ Then the tags file should contain "diff"
42
+ And the tags file should contain "has_many"
43
+ And the tags file should contain "get"
44
+ And the tags file should contain "deliver"
45
+ And the tags file should not contain "caches_action"
46
+ And the tags file should not contain "form_tag"
@@ -0,0 +1,11 @@
1
+ Given /^an app mactag config with the following tags$/ do |table|
2
+ tags = table.rows.flatten.collect(&:quote).join(", ")
3
+
4
+ @app.puts "config/mactag.rb" do
5
+ <<-eos
6
+ Mactag::Table.generate do
7
+ app #{tags}
8
+ end
9
+ eos
10
+ end
11
+ end
@@ -0,0 +1,40 @@
1
+ Given /^the gem "([^\"]*)" version "([^\"]*)" is installed$/ do |gem, version|
2
+ @app.install_gem(gem, version)
3
+ end
4
+
5
+ Given /^an acts as method for the "([^\"]*)" gem$/ do |gem|
6
+ file = File.join("vendor", "gems", gem, "lib", "#{gem}.rb")
7
+ @app.puts file do
8
+ <<-eos
9
+ module #{gem.camelize}
10
+ def self.included(base)
11
+ base.send :extend, ClassMethods
12
+ end
13
+
14
+ module ClassMethods
15
+ def acts_as_#{gem}
16
+ # ...
17
+ end
18
+ end
19
+ end
20
+ eos
21
+ end
22
+ end
23
+
24
+ Given /^a gem mactag config with the following tags$/ do |table|
25
+ if version = table.hashes.first["version"]
26
+ tags = "#{table.hashes.first["tag"].quote}, :version => #{version.quote}"
27
+ else
28
+ tags = table.rows.flatten.collect(&:quote).join(", ")
29
+ end
30
+
31
+ @app.puts "config/mactag.rb" do
32
+ <<-eos
33
+ Mactag::Config.gem_home = File.join("vendor", "gems")
34
+
35
+ Mactag::Table.generate do
36
+ gems #{tags}
37
+ end
38
+ eos
39
+ end
40
+ end
@@ -0,0 +1,53 @@
1
+ Given /^a Rails application$/ do
2
+ @app = RailsApp.new
3
+ end
4
+
5
+ Given /^mactag is installed$/ do
6
+ mactag = File.join(@app.rails_root, "vendor", "plugins", "mactag")
7
+
8
+ FileUtils.mkdir_p(mactag)
9
+
10
+ [ "lib", "tasks", "Rakefile", "init.rb" ].each do |name|
11
+ file = File.join(File.dirname(__FILE__), "..", "..", name)
12
+
13
+ FileUtils.cp_r(file, mactag)
14
+ end
15
+ end
16
+
17
+ Given /^a javascript function "([^\"]*)" in "([^\"]*)"$/ do |function, file|
18
+ @app.puts "public/javascripts/#{file}.js" do
19
+ <<-eos
20
+ function #{function}() {
21
+ // ...
22
+ }
23
+ eos
24
+ end
25
+ end
26
+
27
+ Given /^a ruby method "([^\"]*)" in the "([^\"]*)" model$/ do |method, model|
28
+ @app.puts "app/models/#{model}.rb" do
29
+ <<-eos
30
+ class #{model.camelize}
31
+ def #{method}
32
+ # ...
33
+ end
34
+ end
35
+ eos
36
+ end
37
+ end
38
+
39
+ When /^I create the tags file$/ do
40
+ @tags = TagsFile.new(@app)
41
+ end
42
+
43
+ Then /^the tags file should contain "([^\"]*)"$/ do |tag|
44
+ assert @tags.contain?(tag)
45
+ end
46
+
47
+ Then /^the tags file should not contain "([^\"]*)"$/ do |tag|
48
+ assert !@tags.contain?(tag)
49
+ end
50
+
51
+ After do
52
+ @app.destroy
53
+ end