mactag 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,46 +5,72 @@ an editor that supports Ctags (Emacs, Vim, TextMate, jEdit, ...). With
5
5
  Ctags you can follow tags (of functions, variables, macros, whatever)
6
6
  to their definitions.
7
7
 
8
+
8
9
  # Exuberant Ctags
9
10
  First off you must install [Ctags](http://ctags.sourceforge.net/).
10
11
  Some systems comes with a ctags command already. If you have the ctags
11
12
  executable, but have problems creating the tags file. Then make sure
12
13
  that you are using **Exuberant Ctags** and not some other version.
13
14
 
15
+
14
16
  # Installation
15
17
 
16
- ## Plugin
18
+ ## Rails 2.x
19
+ Version 0.0.5 is the latest version supporting Rails 2.x.
17
20
 
21
+ ### Plugin
18
22
  Install the plugin:
23
+ $ ./script/plugin install git://github.com/rejeep/mactag.git --revision 'tags/v0.0.5'
19
24
 
20
- $ ./script/plugin install git://github.com/rejeep/mactag.git
21
-
22
- ## Gem
23
-
25
+ ### Gem
24
26
  Install the gem:
27
+ $ sudo gem install mactag --version='0.0.5'
28
+
29
+ Load the gem in **config/environments/development.rb**:
30
+ config.gem 'mactag'
25
31
 
26
- $ sudo gem install mactag
32
+ ## Rails 3.x
33
+ Version 0.1.1 is the only version supporting Rails 3.x.
27
34
 
28
- If you install mactag as a gem you must also include it's rake tasks in your *Rakefile*.
35
+ ### Plugin
36
+ Install the plugin:
37
+ $ rails plugin install git://github.com/rejeep/mactag.git --revision 'tags/v0.1.1'
38
+
39
+ ### Gem
40
+ Install the gem:
41
+ $ sudo gem install mactag --version='0.1.1'
42
+
43
+ Load the gem in **Gemfile**:
44
+ group :development do
45
+ gem 'mactag'
46
+ end
29
47
 
48
+ ## Note when installing as Gem
49
+ When you install mactag as a gem you must also include it's rake tasks
50
+ in your **Rakefile**.
30
51
  require 'mactag/tasks'
52
+
31
53
 
32
54
  # Configuration
33
-
34
55
  Generate a basic configuration file:
35
56
 
57
+ ## Rails 2.x
36
58
  $ ./script/generate mactag
59
+
60
+ ## Rails 3.x
61
+ $ rails generate mactag
62
+
63
+ This will create the file **config/mactag.rb**, which contains some
64
+ examples of how to configure Mactag.
37
65
 
38
- This will create the file **config/mactag.rb**, which contains
39
- some examples of how to set it up.
40
66
 
41
67
  ## Options
42
68
 
43
- * **Mactag::Config.gem_home:** The path where the gems are located. Defaults to **/usr/lib/ruby/gems/1.8/gems**
69
+ * **Mactag::Config.gem_home:** The path where the gems are located. Defaults to **/Library/Ruby/Gems/1.8/gems**
44
70
  * **Mactag::Config.binary:** The command to run when creating the TAGS-file. Defaults to **ctags -o TAGS -e**
45
71
 
46
72
  ## Example mactag.rb file
47
- Mactag::Config.gem_home = "/usr/lib/ruby/gems/1.9/gems"
73
+ Mactag::Config.gem_home = "/usr/lib/ruby/gems/1.8/gems"
48
74
  Mactag::Config.binary = "etags -o TAGS"
49
75
 
50
76
  Mactag::Table.generate do
@@ -58,11 +84,11 @@ some examples of how to set it up.
58
84
  rails :except => :actionmailer, :version => "2.3.5"
59
85
  end
60
86
 
61
- # Usage
62
87
 
88
+ # Usage
63
89
  To create the TAGS file. Simply run:
64
90
  $ rake mactag
65
91
 
66
- # License
67
92
 
93
+ # License
68
94
  Copyright (c) 2010 Johan Andersson, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -7,7 +7,7 @@ Given /^mactag is installed$/ do
7
7
 
8
8
  FileUtils.mkdir_p(mactag)
9
9
 
10
- [ "lib", "tasks", "Rakefile", "init.rb" ].each do |name|
10
+ [ "lib", "Rakefile", "init.rb" ].each do |name|
11
11
  file = File.join(File.dirname(__FILE__), "..", "..", name)
12
12
 
13
13
  FileUtils.cp_r(file, mactag)
@@ -1,10 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'active_support'
3
3
  require 'active_support/test_case'
4
+ require 'active_support/core_ext'
5
+ require 'test/unit/assertions'
4
6
 
5
7
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
6
-
7
8
  require 'mactag'
8
- require 'test/unit/assertions'
9
9
 
10
10
  World(Test::Unit::Assertions)
@@ -19,7 +19,7 @@ class RailsApp
19
19
  end
20
20
 
21
21
  def install_plugin(plugin)
22
- system "cd #{rails_root} && ./script/generate plugin #{plugin} &> /dev/null"
22
+ system "cd #{rails_root} && rails generate plugin #{plugin} &> /dev/null"
23
23
  end
24
24
 
25
25
  def install_gem(gem, version)
@@ -0,0 +1,11 @@
1
+ require 'rails/generators'
2
+
3
+ class MactagGenerator < Rails::Generators::Base
4
+ def install_mactag
5
+ copy_file 'mactag.rb', 'config/mactag.rb'
6
+ end
7
+
8
+ def self.source_root
9
+ File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ # Default gem home is the standard one on Mac OS (/Library/Ruby/Gems/1.8/gems).
2
+ # Change to whatever your system is using, if not the default.
3
+ #
4
+ # Most GNU/Linux systems:
5
+ # Mactag::Config.gem_home = "/usr/lib/ruby/gems/1.8/gems"
6
+
7
+ # Change the binary option if you are not satisfied with the standard
8
+ # command (ctags -o TAGS -e) used to create the TAGS table.
9
+ # Mactag::Config.binary = "etags -o TAGS"
10
+
11
+ # Example configuration. Change according to your application.
12
+ Mactag::Table.generate do
13
+ # Index all ruby files in app recursive and all ruby files directly under lib.
14
+ # app "app/**/*.rb", "lib/*.rb"
15
+
16
+ # Index the plugins thinking-sphinx and formtastic.
17
+ # plugins "thinking-sphinx", "formtastic"
18
+
19
+ # Index the gems paperclip and authlogic.
20
+ # gems "paperclip", "authlogic"
21
+
22
+ # Index the gem formtastic version 0.9.7.
23
+ # gem "formtastic", :version => "0.9.7"
24
+
25
+ # Index all rails packages, except actionmailer.
26
+ # rails :except => :actionmailer
27
+
28
+ # Index only rails packages activerecord and activesupport.
29
+ # rails :only => [:activerecord, :active_support]
30
+
31
+ # Index all rails packages, version 2.3.5.
32
+ # rails :version => "2.3.5"
33
+ end
@@ -3,4 +3,7 @@ require 'mactag/table'
3
3
  require 'mactag/tag'
4
4
 
5
5
  module Mactag
6
+ def self.warn(message)
7
+ puts "MACTAG WARNING: #{message}"
8
+ end
6
9
  end
@@ -1,19 +1,14 @@
1
1
  module Mactag
2
- # Configuration options.
3
- #
4
- # ==== Binary
5
- # The command to run when creating the TAGS-file.
6
- # Mactag::Config.binary = "etags -o TAGS"
7
- #
8
- # ==== Gem Home
9
- # The folder where the gems are stored.
10
- # Mactag::Config.gem_home = "/usr/lib/ruby/gems/1.9/gems"
11
2
  class Config
12
3
 
4
+ # The command to run when creating the TAGS-file.
5
+ # Mactag::Config.binary = "etags -o TAGS"
13
6
  @@binary = "ctags -o TAGS -e"
14
7
  cattr_accessor :binary
15
-
16
- @@gem_home = "/usr/lib/ruby/gems/1.8/gems"
8
+
9
+ # The folder where the gems are stored.
10
+ # Mactag::Config.gem_home = "/Library/Ruby/Gems/1.8/gems"
11
+ @@gem_home = "/Library/Ruby/Gems/1.8/gems"
17
12
  cattr_accessor :gem_home
18
13
 
19
14
  end
@@ -9,12 +9,12 @@ module Mactag
9
9
  # ==== Example
10
10
  # Mactag::Table.generate do
11
11
  # app "app/**/*.rb", "lib/*.rb"
12
- #
12
+ #
13
13
  # plugins "thinking-sphinx", "whenever"
14
- #
14
+ #
15
15
  # gems "paperclip", "authlogic"
16
16
  # gem "formtastic", :version => "0.9.7"
17
- #
17
+ #
18
18
  # rails :except => :actionmailer, :version => "2.3.5"
19
19
  # end
20
20
  #
@@ -39,6 +39,14 @@ module Mactag
39
39
  @@tags.uniq!
40
40
  @@tags.join(' ')
41
41
  end
42
+
43
+ def create
44
+ unless File.directory?(Mactag::Config.gem_home)
45
+ Mactag.warn "Gem home path does not exist on your system"
46
+ end
47
+
48
+ system "cd #{Rails.root} && #{Mactag::Config.binary} #{Mactag::Table.tags}"
49
+ end
42
50
  end
43
51
 
44
52
  end
@@ -1,8 +1,9 @@
1
1
  require 'mactag/tag/versioned'
2
2
 
3
+
3
4
  module Mactag
4
5
  module Tag
5
-
6
+
6
7
  # Tag for gems.
7
8
  #
8
9
  # ==== Examples
@@ -22,22 +23,28 @@ module Mactag
22
23
  class Gem
23
24
 
24
25
  include Versioned
25
-
26
+
26
27
  def initialize(*gems)
27
28
  @options = gems.extract_options!
28
29
  @gems = gems.blank? ? ::Rails.configuration.gems.collect(&:name) : gems
29
30
  end
30
31
 
31
32
  def files
32
- @gems.collect do |gem|
33
+ result = []
34
+ @gems.each do |gem_name|
33
35
  if version = @options[:version]
34
- gem = File.join(Mactag::Config.gem_home, "#{gem}-#{version}")
36
+ gem = File.join(Mactag::Config.gem_home, "#{gem_name}-#{version}")
35
37
  else
36
- gem = latest(gem)
38
+ gem = latest(gem_name)
37
39
  end
38
40
 
39
- File.join(gem, "lib", "**", "*.rb")
41
+ if gem
42
+ result << File.join(gem, "lib", "**", "*.rb")
43
+ else
44
+ $stderr.puts "Gem #{gem_name} not found"
45
+ end
40
46
  end
47
+ result
41
48
  end
42
49
 
43
50
  end
@@ -1,6 +1,6 @@
1
1
  module Mactag
2
2
  module Tag
3
-
3
+
4
4
  # Tag for the current project plugins.
5
5
  #
6
6
  # ==== Examples
@@ -12,21 +12,27 @@ module Mactag
12
12
  # plugins "thinking-sphinx", "formtastic"
13
13
  # do
14
14
  class Plugin
15
-
15
+
16
16
  PLUGIN_PATH = File.join("vendor", "plugins")
17
-
17
+
18
18
  def initialize(*plugins)
19
19
  @plugins = plugins
20
20
  end
21
-
21
+
22
22
  def files
23
23
  return File.join(PLUGIN_PATH, "*", "lib", "**", "*.rb") if @plugins.empty?
24
24
 
25
- @plugins.collect do |plugin|
26
- File.join(PLUGIN_PATH, plugin, "lib", "**", "*.rb")
25
+ result = []
26
+ @plugins.each do |plugin|
27
+ if File.exist?(File.join(PLUGIN_PATH, plugin))
28
+ result << File.join(PLUGIN_PATH, plugin, "lib", "**", "*.rb")
29
+ else
30
+ $stderr.puts "Plugin #{plugin} not found"
31
+ end
27
32
  end
33
+ result
28
34
  end
29
-
35
+
30
36
  end
31
37
  end
32
38
  end
@@ -4,5 +4,5 @@ desc "Creates a Ctags file"
4
4
  task :mactag => :environment do
5
5
  require File.join(Rails.root, "config", "mactag")
6
6
 
7
- system "cd #{Rails.root} && #{Mactag::Config.binary} #{Mactag::Table.tags}"
7
+ Mactag::Table.create
8
8
  end
@@ -1,10 +1,10 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ConfigTest < ActiveSupport::TestCase
4
-
4
+
5
5
  should "have correct default options" do
6
6
  assert_equal "ctags -o TAGS -e", Mactag::Config.binary
7
- assert_equal "/usr/lib/ruby/gems/1.8/gems", Mactag::Config.gem_home
7
+ assert_equal "/Library/Ruby/Gems/1.8/gems", Mactag::Config.gem_home
8
8
  end
9
-
9
+
10
10
  end
@@ -1,17 +1,17 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class GemTest < ActiveSupport::TestCase
4
-
4
+
5
5
  context "gem with version" do
6
6
  setup do
7
7
  @gem = Mactag::Tag::Gem.new("thinking-sphinx", :version => "1.0.0")
8
8
  end
9
-
9
+
10
10
  should "return the gem with that version" do
11
11
  assert_contains @gem.files, File.join(Mactag::Config.gem_home, "thinking-sphinx-1.0.0", "lib", "**", "*.rb")
12
12
  end
13
13
  end
14
-
14
+
15
15
  context "gem without version" do
16
16
  context "one gem" do
17
17
  setup do
@@ -19,24 +19,38 @@ class GemTest < ActiveSupport::TestCase
19
19
 
20
20
  @gem = Mactag::Tag::Gem.new("whenever")
21
21
  end
22
-
22
+
23
23
  should "return that gem" do
24
24
  assert_contains @gem.files, "whenever/lib/**/*.rb"
25
25
  end
26
26
  end
27
-
27
+
28
28
  context "multiple gems" do
29
29
  setup do
30
30
  Dir.stubs(:glob).returns(["whenever-0.3.7", "whenever-0.3.6"])
31
-
31
+
32
32
  @gem = Mactag::Tag::Gem.new("whenever")
33
33
  end
34
-
34
+
35
35
  should "return the gem with the latest version" do
36
36
  assert_contains @gem.files, "whenever-0.3.7/lib/**/*.rb"
37
37
  assert_does_not_contain @gem.files, "whenever-0.3.6/lib/**/*.rb"
38
38
  end
39
39
  end
40
40
  end
41
-
41
+
42
+ context "gem that does not exist" do
43
+ setup do
44
+ Dir.stubs(:glob).returns([nil])
45
+
46
+ @gem = Mactag::Tag::Gem.new("whenever")
47
+ end
48
+
49
+ should "not raise exception because no such gem" do
50
+ assert_nothing_raised do
51
+ assert_equal [], @gem.files
52
+ end
53
+ end
54
+ end
55
+
42
56
  end
@@ -5,9 +5,11 @@ class PluginTest < ActiveSupport::TestCase
5
5
  should "have correct plugin path" do
6
6
  assert_equal "vendor/plugins", Mactag::Tag::Plugin::PLUGIN_PATH
7
7
  end
8
-
8
+
9
9
  context "without arguments" do
10
10
  setup do
11
+ File.stubs(:exist?).returns(true)
12
+
11
13
  @plugin = Mactag::Tag::Plugin.new
12
14
  end
13
15
 
@@ -15,26 +17,44 @@ class PluginTest < ActiveSupport::TestCase
15
17
  assert_equal @plugin.files, "vendor/plugins/*/lib/**/*.rb"
16
18
  end
17
19
  end
18
-
20
+
19
21
  context "with one plugin argument" do
20
22
  setup do
23
+ File.stubs(:exist?).returns(true)
24
+
21
25
  @plugin = Mactag::Tag::Plugin.new("thinking-sphinx")
22
26
  end
23
-
27
+
24
28
  should "return the path to that plugin" do
25
29
  assert_equal ["vendor/plugins/thinking-sphinx/lib/**/*.rb"], @plugin.files
26
30
  end
27
31
  end
28
-
32
+
29
33
  context "with more thatn one plugin argument" do
30
34
  setup do
35
+ File.stubs(:exist?).returns(true)
36
+
31
37
  @plugin = Mactag::Tag::Plugin.new("thinking-sphinx", "formtastic")
32
38
  end
33
-
39
+
34
40
  should "return the paths to those plugins" do
35
41
  assert_contains @plugin.files, "vendor/plugins/thinking-sphinx/lib/**/*.rb"
36
42
  assert_contains @plugin.files, "vendor/plugins/formtastic/lib/**/*.rb"
37
43
  end
38
44
  end
39
-
45
+
46
+ context "plugin that does not exist" do
47
+ setup do
48
+ File.stubs(:exist?).returns(false)
49
+
50
+ @plugin = Mactag::Tag::Plugin.new("typo")
51
+ end
52
+
53
+ should "not raise exception because no such plugin" do
54
+ assert_nothing_raised do
55
+ assert_equal [], @plugin.files
56
+ end
57
+ end
58
+ end
59
+
40
60
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mactag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Johan Andersson
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-13 00:00:00 +00:00
17
+ date: 2010-03-11 00:00:00 +00:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -25,8 +30,8 @@ extra_rdoc_files:
25
30
  files:
26
31
  - README.markdown
27
32
  - VERSION
28
- - generators/mactag/mactag_generator.rb
29
- - generators/mactag/templates/mactag.rb
33
+ - lib/generators/mactag/mactag_generator.rb
34
+ - lib/generators/mactag/templates/mactag.rb
30
35
  - lib/mactag.rb
31
36
  - lib/mactag/config.rb
32
37
  - lib/mactag/table.rb
@@ -37,8 +42,7 @@ files:
37
42
  - lib/mactag/tag/plugin.rb
38
43
  - lib/mactag/tag/rails.rb
39
44
  - lib/mactag/tag/versioned.rb
40
- - lib/mactag/tasks.rb
41
- - tasks/mactag_tasks.rake
45
+ - lib/tasks/mactag.rake
42
46
  - TODO
43
47
  has_rdoc: true
44
48
  homepage: http://github.com/rejeep/mactag
@@ -53,18 +57,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
57
  requirements:
54
58
  - - ">="
55
59
  - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
56
62
  version: "0"
57
- version:
58
63
  required_rubygems_version: !ruby/object:Gem::Requirement
59
64
  requirements:
60
65
  - - ">="
61
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
62
69
  version: "0"
63
- version:
64
70
  requirements: []
65
71
 
66
72
  rubyforge_project:
67
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.6
68
74
  signing_key:
69
75
  specification_version: 3
70
76
  summary: Ctags for Rails
@@ -82,7 +88,6 @@ test_files:
82
88
  - features/step_definitions/rails_steps.rb
83
89
  - features/step_definitions/gem_steps.rb
84
90
  - features/step_definitions/mactab_steps.rb
85
- - features/support/core_ext.rb
86
91
  - features/support/tags_file.rb
87
92
  - features/support/env.rb
88
93
  - features/support/rails_app.rb
@@ -1,5 +0,0 @@
1
- class String
2
- def quote
3
- "\"#{self}\""
4
- end
5
- end
@@ -1,10 +0,0 @@
1
- class MactagGenerator < Rails::Generator::Base
2
-
3
- def manifest
4
- record do |m|
5
- m.directory "config"
6
- m.template "mactag.rb", File.join("config", "mactag.rb")
7
- end
8
- end
9
-
10
- end
@@ -1,11 +0,0 @@
1
- Mactag::Table.generate do
2
- app "app/**/*.rb", "lib/*.rb"
3
-
4
- plugins "thinking-sphinx", "formtastic"
5
-
6
- gems "paperclip", "authlogic"
7
- gem "formtastic", :version => "0.9.7"
8
-
9
- rails :except => :actionmailer
10
- rails :only => [:activerecord, :active_support]
11
- end
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '/../lib/mactag/tasks')