rails_assist 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +204 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/rails_assist.rb +43 -0
- data/lib/rails_assist/app.rb +13 -0
- data/lib/rails_assist/artifact.rb +34 -0
- data/lib/rails_assist/artifact/directory.rb +66 -0
- data/lib/rails_assist/artifact/files.rb +95 -0
- data/lib/rails_assist/artifact/path.rb +16 -0
- data/lib/rails_assist/directory.rb +64 -0
- data/lib/rails_assist/directory/app.rb +21 -0
- data/lib/rails_assist/directory/container.rb +24 -0
- data/lib/rails_assist/directory/root.rb +24 -0
- data/lib/rails_assist/file.rb +91 -0
- data/lib/rails_assist/file/application.rb +15 -0
- data/lib/rails_assist/file/environment.rb +16 -0
- data/lib/rails_assist/file/gem_file.rb +32 -0
- data/lib/rails_assist/file/routes_file.rb +13 -0
- data/lib/rails_assist/file/special.rb +78 -0
- data/lib/rails_assist/files.rb +153 -0
- data/lib/rails_assist/macro.rb +68 -0
- data/lib/rails_assist/namespaces.rb +11 -0
- data/lib/rails_assist/rspec.rb +1 -0
- data/lib/rails_assist/rspec/configure.rb +7 -0
- data/rails_assist.gemspec +221 -0
- data/sandbox/test.rb +16 -0
- data/sandbox/test.txt +5 -0
- data/spec/fixtures.rb +3 -0
- data/spec/fixtures/.gitignore +4 -0
- data/spec/fixtures/Gemfile +9 -0
- data/spec/fixtures/README +256 -0
- data/spec/fixtures/Rakefile +7 -0
- data/spec/fixtures/app/controllers/application_controller.rb +3 -0
- data/spec/fixtures/app/controllers/users_controller.rb +83 -0
- data/spec/fixtures/app/helpers/application_helper.rb +2 -0
- data/spec/fixtures/app/helpers/users_helper.rb +2 -0
- data/spec/fixtures/app/licenses/blogging_license.rb +0 -0
- data/spec/fixtures/app/mailers/user_mailer.rb +0 -0
- data/spec/fixtures/app/models/user.rb +2 -0
- data/spec/fixtures/app/models/user_observer.rb +0 -0
- data/spec/fixtures/app/permits/user_permit.rb +0 -0
- data/spec/fixtures/app/validators/email_validator.rb +0 -0
- data/spec/fixtures/app/views/layouts/application.html.erb +14 -0
- data/spec/fixtures/app/views/users/_form.html.erb +21 -0
- data/spec/fixtures/app/views/users/edit.html.erb +6 -0
- data/spec/fixtures/app/views/users/index.html.erb +23 -0
- data/spec/fixtures/app/views/users/new.html.erb +5 -0
- data/spec/fixtures/app/views/users/show.html.erb +10 -0
- data/spec/fixtures/config.ru +4 -0
- data/spec/fixtures/config/application.rb +43 -0
- data/spec/fixtures/config/boot.rb +13 -0
- data/spec/fixtures/config/database.yml +22 -0
- data/spec/fixtures/config/environment.rb +5 -0
- data/spec/fixtures/config/environments/development.rb +26 -0
- data/spec/fixtures/config/environments/production.rb +49 -0
- data/spec/fixtures/config/environments/test.rb +35 -0
- data/spec/fixtures/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/config/initializers/inflections.rb +10 -0
- data/spec/fixtures/config/initializers/mime_types.rb +5 -0
- data/spec/fixtures/config/initializers/my_init.rb +0 -0
- data/spec/fixtures/config/initializers/secret_token.rb +7 -0
- data/spec/fixtures/config/initializers/session_store.rb +8 -0
- data/spec/fixtures/config/locales/en.yml +5 -0
- data/spec/fixtures/config/routes.rb +60 -0
- data/spec/fixtures/db/migrate/20100831135208_create_users.rb +13 -0
- data/spec/fixtures/db/seeds.rb +7 -0
- data/spec/fixtures/lib/tasks/.gitkeep +0 -0
- data/spec/fixtures/public/404.html +26 -0
- data/spec/fixtures/public/422.html +26 -0
- data/spec/fixtures/public/500.html +26 -0
- data/spec/fixtures/public/favicon.ico +0 -0
- data/spec/fixtures/public/images/rails.png +0 -0
- data/spec/fixtures/public/index.html +239 -0
- data/spec/fixtures/public/javascripts/application.js +2 -0
- data/spec/fixtures/public/javascripts/controls.js +965 -0
- data/spec/fixtures/public/javascripts/dragdrop.js +974 -0
- data/spec/fixtures/public/javascripts/effects.js +1 -0
- data/spec/fixtures/public/javascripts/prototype.js +6001 -0
- data/spec/fixtures/public/javascripts/rails.js +175 -0
- data/spec/fixtures/public/robots.txt +5 -0
- data/spec/fixtures/public/stylesheets/.gitkeep +0 -0
- data/spec/fixtures/public/stylesheets/scaffold.css +56 -0
- data/spec/fixtures/script/rails +6 -0
- data/spec/fixtures/test/fixtures/users.yml +7 -0
- data/spec/fixtures/test/functional/users_controller_test.rb +49 -0
- data/spec/fixtures/test/performance/browsing_test.rb +9 -0
- data/spec/fixtures/test/test_helper.rb +13 -0
- data/spec/fixtures/test/unit/helpers/users_helper_test.rb +4 -0
- data/spec/fixtures/test/unit/user_test.rb +8 -0
- data/spec/fixtures/vendor/plugins/.gitkeep +0 -0
- data/spec/load_spec.rb +1 -0
- data/spec/rails_assist/app_spec.rb +31 -0
- data/spec/rails_assist/artifact/directory_spec.rb +66 -0
- data/spec/rails_assist/artifact/files_spec.rb +79 -0
- data/spec/rails_assist/artifact/path_spec.rb +23 -0
- data/spec/rails_assist/artifact_spec.rb +33 -0
- data/spec/rails_assist/directory/app_spec.rb +45 -0
- data/spec/rails_assist/directory/container_spec.rb +63 -0
- data/spec/rails_assist/directory/root_spec.rb +46 -0
- data/spec/rails_assist/directory_spec.rb +64 -0
- data/spec/rails_assist/file/application_spec.rb +33 -0
- data/spec/rails_assist/file/environment_spec.rb +49 -0
- data/spec/rails_assist/file/special_spec.rb +171 -0
- data/spec/rails_assist/file_spec.rb +115 -0
- data/spec/rails_assist/files_spec.rb +90 -0
- data/spec/rails_assist/rspec/have_app_config_spec.rb +0 -0
- data/spec/rails_assist_spec.rb +7 -0
- data/spec/spec_helper.rb +53 -0
- metadata +291 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
|
5
|
+
gem "require_all", "~> 1.2.0"
|
6
|
+
gem "sugar-high", "~> 0.3.7"
|
7
|
+
gem "activesupport", ">= 3.0.4"
|
8
|
+
# gem "migration_assist", "~> 0.1.7"
|
9
|
+
|
10
|
+
# Add dependencies to develop your gem here.
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
12
|
+
group :development do
|
13
|
+
gem "rspec", ">= 2.3.0"
|
14
|
+
gem "bundler", "~> 1.0.0"
|
15
|
+
gem "jeweler", "~> 1.5.2"
|
16
|
+
gem "rcov", ">= 0"
|
17
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Kristian Mandrup
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
# Rails Assistant
|
2
|
+
|
3
|
+
Includes various helpers to assist operating on a Rails 3 application.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
<code>gem install rails_assist</code>
|
8
|
+
|
9
|
+
## File Assistants
|
10
|
+
|
11
|
+
There are file assistants for the following Rails 3 artifacts:
|
12
|
+
* locale
|
13
|
+
* javascript
|
14
|
+
* stylesheet
|
15
|
+
* controller
|
16
|
+
* helper
|
17
|
+
* view
|
18
|
+
* model
|
19
|
+
* mailer
|
20
|
+
* observer
|
21
|
+
* permit
|
22
|
+
* view
|
23
|
+
|
24
|
+
* [name]_file
|
25
|
+
* [name]_files
|
26
|
+
* create_[name]_file
|
27
|
+
* remove_[name]_file
|
28
|
+
* remove_all__[name]s
|
29
|
+
* remove_[name]s
|
30
|
+
|
31
|
+
Example usage:
|
32
|
+
|
33
|
+
<pre>
|
34
|
+
remove_locales 'blip.en', 'blip.dk'
|
35
|
+
remove_all_stylesheets
|
36
|
+
create_stylesheet 'my_styles.css' do
|
37
|
+
%{
|
38
|
+
.mystyle {font: bold;}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
remove_stylesheet 'my_styles.css'
|
42
|
+
|
43
|
+
locale_files
|
44
|
+
locale_files 'permit.dk'
|
45
|
+
locale_files /permit/ do |files|
|
46
|
+
# ...
|
47
|
+
end
|
48
|
+
|
49
|
+
view_files :person
|
50
|
+
erb_view_files(:user).file_names.should include 'show.html.erb'
|
51
|
+
haml_view_files(:user)
|
52
|
+
</pre>
|
53
|
+
|
54
|
+
## Directory Assistants
|
55
|
+
|
56
|
+
There are dir helpers for the following
|
57
|
+
|
58
|
+
* app
|
59
|
+
* config
|
60
|
+
* db
|
61
|
+
* public
|
62
|
+
* lib
|
63
|
+
* log
|
64
|
+
* doc
|
65
|
+
* test
|
66
|
+
* spec
|
67
|
+
|
68
|
+
* locale
|
69
|
+
* initializer
|
70
|
+
* javascript
|
71
|
+
* stylesheet
|
72
|
+
* controller
|
73
|
+
* helper
|
74
|
+
* view
|
75
|
+
* model
|
76
|
+
* mailer
|
77
|
+
* observer
|
78
|
+
* permit
|
79
|
+
* view
|
80
|
+
|
81
|
+
Example usage:
|
82
|
+
|
83
|
+
<pre>
|
84
|
+
config_dir
|
85
|
+
observer_dir_
|
86
|
+
db_dir :root_path => MY_RAILS_ROOT
|
87
|
+
rails_dir_for :migrations
|
88
|
+
db_dir_for :migrations
|
89
|
+
config_dir_for :initializers, :root_path => MY_RAILS_ROOT
|
90
|
+
app_dir_for :models
|
91
|
+
</pre>
|
92
|
+
|
93
|
+
## Special Rails mutators
|
94
|
+
|
95
|
+
* insert_application_config
|
96
|
+
* insert_before_application_init
|
97
|
+
* insert_after_application_init
|
98
|
+
|
99
|
+
Special file helpers:
|
100
|
+
|
101
|
+
* application_file
|
102
|
+
* environment_file
|
103
|
+
* seed_file
|
104
|
+
|
105
|
+
* read_[special]_file
|
106
|
+
* remove_[special]_file
|
107
|
+
* append_to_[special]_file
|
108
|
+
* replace_in_[special]_file :where => ... :with => ...
|
109
|
+
* remove_from_[special]_file
|
110
|
+
|
111
|
+
Example
|
112
|
+
|
113
|
+
<pre>
|
114
|
+
remove_from_application_file /config.root = (\w+?)/
|
115
|
+
append_to_seed_file do
|
116
|
+
%{
|
117
|
+
Person.new :name => 'Mike'
|
118
|
+
}
|
119
|
+
end
|
120
|
+
</pre>
|
121
|
+
|
122
|
+
### Usage
|
123
|
+
|
124
|
+
Set the root if not already set, then use the special assist methods to include the modules with all the goodies!
|
125
|
+
See the *Assistants* section below for more info on how to do this.
|
126
|
+
|
127
|
+
### Rails root
|
128
|
+
|
129
|
+
You have to set the class variable <code>RailsAssist::Directory.rails_root</code> to the location of your Rails root directory if you are using this gem outside of Rails, fx for testing purposes or something.
|
130
|
+
|
131
|
+
Note: If this variable is not set, it will assume it is used in a Rails app and therefore assume the root is <code>Rails.root</code>.
|
132
|
+
|
133
|
+
In the specs of this projct, I use the *rails_root* class variable to avoid having to set a Rails app specific variable, which I deemed unnecessary for most of the tests.
|
134
|
+
|
135
|
+
### Assistants
|
136
|
+
|
137
|
+
Generators are often designed to create Rails 3 artifacts or update existing artifacts. It's often useful to include one or more Rails 3 artifact assistants along
|
138
|
+
with a generator assistant (see above).
|
139
|
+
|
140
|
+
This combination greatly facilitates your work in developing the generator, as much of the heavy lifting will be done for you in the assistants.
|
141
|
+
|
142
|
+
To use a specific assistant/helper, simply call:
|
143
|
+
|
144
|
+
*assist_with [list of assistant symbols]*
|
145
|
+
|
146
|
+
Example:
|
147
|
+
|
148
|
+
<code>assist_with :controller, :model, :view, :permit</code>
|
149
|
+
|
150
|
+
Aliases: *use_helpers* and *use_helper*
|
151
|
+
|
152
|
+
Available helpers:
|
153
|
+
|
154
|
+
Artifacts
|
155
|
+
* controller
|
156
|
+
* model
|
157
|
+
* view
|
158
|
+
* helper
|
159
|
+
* observer
|
160
|
+
* mailer
|
161
|
+
* migration
|
162
|
+
* permit
|
163
|
+
|
164
|
+
Misc.
|
165
|
+
* file
|
166
|
+
* files
|
167
|
+
* directory
|
168
|
+
|
169
|
+
### Using Assistants
|
170
|
+
|
171
|
+
<pre>
|
172
|
+
class MyGenerator < Rails::Generators:NamedBase
|
173
|
+
extend RailsAssist::UseMacro
|
174
|
+
|
175
|
+
use_orm :active_record
|
176
|
+
use_helpers :file, :files, :controller, :observer, :migration
|
177
|
+
...
|
178
|
+
end
|
179
|
+
</pre>
|
180
|
+
|
181
|
+
### Assistant in RSpec
|
182
|
+
|
183
|
+
The assistants are preconfigured to be available within RSpec constructs.
|
184
|
+
|
185
|
+
<pre>
|
186
|
+
describe 'My Controller' do
|
187
|
+
use_helpers :directory, :files, :helper, :mailer
|
188
|
+
...
|
189
|
+
end
|
190
|
+
</pre>
|
191
|
+
|
192
|
+
## Note on Patches/Pull Requests
|
193
|
+
|
194
|
+
* Fork the project.
|
195
|
+
* Make your feature addition or bug fix.
|
196
|
+
* Add tests for it. This is important so I don't break it in a
|
197
|
+
future version unintentionally.
|
198
|
+
* Commit, do not mess with rakefile, version, or history.
|
199
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
200
|
+
* Send me a pull request. Bonus points for topic branches.
|
201
|
+
|
202
|
+
## Copyright
|
203
|
+
|
204
|
+
Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= rails_assist
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to rails_assist
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Kristian Mandrup. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "rails_assist"
|
16
|
+
gem.summary = %Q{File operation helpers for Rails 3 artifacts}
|
17
|
+
gem.description = %Q{Basic file operation helpers for working with Rails 3 artifacts}
|
18
|
+
gem.email = "kmandrup@gmail.com"
|
19
|
+
gem.homepage = "http://github.com/kristianmandrup/rails3-assist"
|
20
|
+
gem.authors = ["Kristian Mandrup"]
|
21
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
22
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
23
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
24
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "rails_assist #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
data/lib/rails_assist.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# require 'thor'
|
2
|
+
require 'require_all'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rake'
|
5
|
+
require 'active_support/inflector'
|
6
|
+
|
7
|
+
require 'sugar-high/alias'
|
8
|
+
require 'sugar-high/file'
|
9
|
+
require 'sugar-high/regexp'
|
10
|
+
require 'sugar-high/array'
|
11
|
+
|
12
|
+
require 'rails_assist/namespaces'
|
13
|
+
|
14
|
+
module RailsAssist
|
15
|
+
def self.artifacts
|
16
|
+
[:observer, :controller, :helper, :mailer, :model, :migration, :permit]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.specials type=nil
|
20
|
+
case type
|
21
|
+
when :config
|
22
|
+
[:initializer, :locale]
|
23
|
+
when :public
|
24
|
+
[:stylesheet, :javascript]
|
25
|
+
else
|
26
|
+
raise ArgumentError, "Unknown specials type #{type}. Specify :config or :public" if type && type != :all
|
27
|
+
[:initializer, :locale] + [:stylesheet, :javascript]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :debug_on
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rails_assist/app'
|
37
|
+
require 'rails_assist/directory'
|
38
|
+
require 'rails_assist/file'
|
39
|
+
require 'rails_assist/files'
|
40
|
+
require 'rails_assist/artifact'
|
41
|
+
require 'rails_assist/macro'
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module RailsAssist::Artifact
|
2
|
+
module Methods
|
3
|
+
def helper_list
|
4
|
+
RailsAssist.artifacts + [:view]
|
5
|
+
end
|
6
|
+
|
7
|
+
def app_artifacts
|
8
|
+
[:controller, :mailer, :helper, :view, :model, :permit, :license, :validator]
|
9
|
+
end
|
10
|
+
|
11
|
+
def rails_artifacts
|
12
|
+
@rails_artifacts ||= begin
|
13
|
+
files_methods = RailsAssist::Artifact::Files.instance_methods
|
14
|
+
files_symbols = files_methods.grep(/_files$/).map{|f| f.to_s.gsub(/^(.*)_files/, '\1').to_sym }
|
15
|
+
|
16
|
+
# dir_methods = RailsAssist::Artifact::Directory.instance_methods
|
17
|
+
# dir_symbols = dir_methods.map{|dir| dir.to_s.gsub(/^(.*)_dir/, '\1').to_sym }
|
18
|
+
dir_symbols = []
|
19
|
+
|
20
|
+
(files_symbols + dir_symbols).uniq
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid_artifact? type
|
25
|
+
rails_artifacts.include?(type)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
extend Methods
|
30
|
+
include Methods
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
require_all File.dirname(__FILE__) + '/artifact'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module RailsAssist::Artifact
|
2
|
+
module Directory
|
3
|
+
module Methods
|
4
|
+
DIR = RailsAssist::Directory
|
5
|
+
APP_DIR = RailsAssist::Directory::App
|
6
|
+
|
7
|
+
# :controller, :mailer, :helper, :view, :model, :permit
|
8
|
+
#
|
9
|
+
# controller_dir, mailer_dir ...
|
10
|
+
RailsAssist::Artifact.app_artifacts.each do |name|
|
11
|
+
class_eval %{
|
12
|
+
def #{name}_dirpath options={}
|
13
|
+
[APP_DIR.app_dirpath(options), '#{name.to_s.pluralize}'].file_join
|
14
|
+
end
|
15
|
+
|
16
|
+
def #{name}_dir options={}
|
17
|
+
#{name}_dirpath(options).dir
|
18
|
+
end
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# initializer_dir, locale_dir
|
23
|
+
# stylesheet_dir, javascript_dir
|
24
|
+
{:config => RailsAssist.specials(:config), :public => RailsAssist.specials(:public)}.each_pair do |container, names|
|
25
|
+
names.each do |name|
|
26
|
+
class_eval %{
|
27
|
+
def #{name}_dirpath options={}
|
28
|
+
RailsAssist::Directory.#{container}_dir_for(:#{name.to_s.pluralize}, options).path
|
29
|
+
end
|
30
|
+
|
31
|
+
def #{name}_dir options={}
|
32
|
+
#{name}_dirpath(options).dir
|
33
|
+
end
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
[:stylesheet, :javascript].each do |name|
|
39
|
+
class_eval %{
|
40
|
+
def #{name}_dirpath options={}
|
41
|
+
RailsAssist::Directory.public_dir_for(:#{name.to_s.pluralize}, options).path
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def migration_dirpath options={}
|
47
|
+
[DIR.db_dir(options), 'migrate'].file_join
|
48
|
+
end
|
49
|
+
|
50
|
+
def migration_dir options={}
|
51
|
+
migration_dirpath(options).dir
|
52
|
+
end
|
53
|
+
|
54
|
+
def observer_dirpath options={}
|
55
|
+
model_dir(options).path
|
56
|
+
end
|
57
|
+
|
58
|
+
def observer_dir options={}
|
59
|
+
observer_dirpath(options).dir
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
extend Methods
|
64
|
+
include Methods
|
65
|
+
end
|
66
|
+
end
|