Class: Mactag::Dsl
- Inherits:
-
Object
- Object
- Mactag::Dsl
- Defined in:
- lib/mactag/dsl.rb
Overview
Mactag DSL.
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Instance Method Summary collapse
-
#app(*args) ⇒ Object
DEPRECATED: Please use ‘#index’ instead.
-
#gem(*args) ⇒ Object
(also: #gems)
DEPRECATED: Please use ‘#index’ instead.
-
#index(*args) ⇒ Object
This is the method used to index.
-
#initialize(builder) ⇒ Dsl
constructor
A new instance of Dsl.
-
#plugin(*plugins) ⇒ Object
(also: #plugins)
DEPRECATED: Please use gems instead.
-
#rails(*args) ⇒ Object
DEPRECATED: Please use ‘#index’ instead.
Constructor Details
#initialize(builder) ⇒ Dsl
Returns a new instance of Dsl.
9 10 11 |
# File 'lib/mactag/dsl.rb', line 9 def initialize(builder) @builder = builder end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
7 8 9 |
# File 'lib/mactag/dsl.rb', line 7 def builder @builder end |
Instance Method Details
#app(*args) ⇒ Object
DEPRECATED: Please use ‘#index’ instead.
156 157 158 159 160 161 162 163 164 |
# File 'lib/mactag/dsl.rb', line 156 def app(*args) $stderr.puts '[DEPRECATION] Please use #index instead of #app.' if args.empty? index(:app) else index(*args) end end |
#gem(*args) ⇒ Object Also known as: gems
DEPRECATED: Please use ‘#index’ instead.
170 171 172 173 174 175 176 177 178 |
# File 'lib/mactag/dsl.rb', line 170 def gem(*args) $stderr.puts '[DEPRECATION] Please use #index instead of #gems.' if args.empty? index(:gems) else index(*args) end end |
#index(*args) ⇒ Object
This is the method used to index. Three different things can be indexed: the current project, gems and Rails (which really is a collection of gems).
App
App indexes files in the current Rails project.
Examples
Mactag do
# Index all ruby files in app and lib, recursive
index :app
# Index single file
index 'lib/super_duper.rb'
# Index all ruby files in lib, recursive
index 'lib/**/*.rb'
# Index all helper and model ruby files
index 'app/helpers/*.rb', 'app/models/*.rb'
# Same as above
index 'app/{models,helpers}/*.rb'
end
Gem
Index Ruby gems.
Examples
Mactag do
# Index all gems specified in Gemfile
index :gems
# Index the gem whenever, latest version
index 'whenever'
# Index the thinking-sphinx and carrierwave gems, latest versions
index 'thinking-sphinx', 'carrierwave'
# Index the gem simple_form, version 1.5.2
index 'simple_form', :version => '1.5.2'
end
Rails
Index Rails.
Packages
These are the packages that can be indexed. Naming does not matter, so activerecord and active_record are the same.
-
actionmailer
-
actionpack
-
activemodel
-
activerecord
-
activeresource
-
railties
-
activesupport
Lib
Lib indexes files in the current project.
Examples
Mactag do
# Index all ruby files in lib, recursive
index :lib
# Index single file
index 'lib/super_duper.rb'
# Index all ruby files in lib, recursive
index 'lib/**/*.rb'
end
Examples
Mactag do
# Index all packages, same version as application
index :rails
# Index all packages, version 3.1.3
index :rails, :version => '3.1.3'
# Index all packages except activerecord, same version as application
index :rails, :except => :activerecord
# Index only activerecord and actionview, same version as application
index :rails, :only => [:activerecord, :action_view]
# Index all packages except activerecord and actionview,
# same version as application
index :rails, :except => ['activerecord', :action_controller]
# Index all packages except actionmailer, version 3.1.3
index :rails, :except => :actionmailer, :version => '3.1.3'
end
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/mactag/dsl.rb', line 124 def index(*args) if args.first == :app app_private elsif args.first == :lib lib_private elsif args.first == :gems gem_private elsif args.first == :rails rails_private(*args) else = args.last if .is_a?(Hash) && [:version] && args.size > 2 raise ArgumentError.new('The :version option is not valid when specifying more than one gem') end if .is_a?(Hash) || args.all? { |arg| Mactag::Indexer::Gem.exist?(arg) } gem_private(*args) else if Mactag.rails_app? app_private(*args) else lib_private(*args) end end end end |
#plugin(*plugins) ⇒ Object Also known as: plugins
DEPRECATED: Please use gems instead.
202 203 204 205 206 |
# File 'lib/mactag/dsl.rb', line 202 def plugin(*plugins) $stderr.puts '[DEPRECATION] Please use gems instead of plugins.' plugin_private(*plugins) end |
#rails(*args) ⇒ Object
DEPRECATED: Please use ‘#index’ instead.
185 186 187 188 189 190 191 192 193 |
# File 'lib/mactag/dsl.rb', line 185 def rails(*args) $stderr.puts '[DEPRECATION] Please use #index instead of #rails.' if args.empty? index(:rails) else index(*args) end end |