rails-archer 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/bin/shoot +50 -0
- data/lib/rails-archer/generators/app/USAGE +15 -0
- data/lib/rails-archer/generators/app/app_builder.rb +40 -0
- data/lib/rails-archer/generators/app/app_generator.rb +50 -0
- data/lib/rails-archer/generators/app/templates/.gitkeep +0 -0
- data/lib/rails-archer/generators/app/templates/README +0 -0
- data/lib/rails-archer/generators/app/templates/app/views/layouts/application.html.erb.tt +14 -0
- data/lib/rails-archer/generators/app/templates/config/locales/en.yml +3 -0
- data/lib/rails-archer/generators/app/templates/config/locales/zh-TW.yml +3 -0
- data/lib/rails-archer/version.rb +5 -0
- data/lib/rails-archer.rb +6 -0
- data/rails-archer.gemspec +22 -0
- metadata +101 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Tse-Ching Ho
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Rails::Archer
|
2
|
+
|
3
|
+
Rails archer shoots off a rails project with helpful tools.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install rails-archer
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
$ shoot new APP_PATH
|
12
|
+
|
13
|
+
## Contributing
|
14
|
+
|
15
|
+
1. Fork it
|
16
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
17
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
18
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
19
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/shoot
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
|
7
|
+
require 'rails/version'
|
8
|
+
require 'rails-archer/version'
|
9
|
+
if ['--version', '-v'].include? ARGV.first
|
10
|
+
puts "Rails #{Rails::VERSION::STRING}"
|
11
|
+
puts "Rails-archer #{Rails::Archer::VERSION}"
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
require 'pathname'
|
17
|
+
SCRIPT_RAILS = File.join('script', 'rails')
|
18
|
+
|
19
|
+
def in_rails_application?
|
20
|
+
File.exists? SCRIPT_RAILS
|
21
|
+
end
|
22
|
+
|
23
|
+
def in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
|
24
|
+
File.exists?(File.join(path, SCRIPT_RAILS)) ||
|
25
|
+
!path.root? && in_rails_application_subdirectory?(path.parent)
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_railsrc
|
29
|
+
railsrc = File.join(File.expand_path('~'), '.railsrc')
|
30
|
+
return unless File.exist? railsrc
|
31
|
+
extra_args_string = File.open(railsrc).read
|
32
|
+
extra_args = extra_args_string.split(/\n+/).map { |l| l.split }.flatten
|
33
|
+
puts "Using #{extra_args.join(' ')} from #{railsrc}"
|
34
|
+
ARGV << extra_args
|
35
|
+
ARGV.flatten!
|
36
|
+
end
|
37
|
+
|
38
|
+
if in_rails_application? || in_rails_application_subdirectory?
|
39
|
+
puts "Can't execute inside Rails project!"
|
40
|
+
exit 0
|
41
|
+
elsif ARGV.first != 'new'
|
42
|
+
ARGV[0] = '--help'
|
43
|
+
else
|
44
|
+
ARGV.shift
|
45
|
+
load_railsrc
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
require 'rails-archer/generators/app/app_generator'
|
50
|
+
Rails::Archer::AppGenerator.start
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
The 'shoot new' command creates a new Rails application with a default
|
3
|
+
directory structure and configuration at the path you specify.
|
4
|
+
|
5
|
+
You can specify extra command-line arguments to be used every time
|
6
|
+
'shoot new' runs in the .railsrc configuration file in your home directory.
|
7
|
+
|
8
|
+
Note that the arguments specified in the .railsrc file don't affect the
|
9
|
+
defaults values shown above in this help message.
|
10
|
+
|
11
|
+
Example:
|
12
|
+
shoot new ~/Code/Ruby/trouble-maker
|
13
|
+
|
14
|
+
This generates a skeletal Rails installation in ~/Code/Ruby/trouble-maker.
|
15
|
+
See the README in the newly created application to get going.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Rails
|
2
|
+
module Archer
|
3
|
+
class AppBuilder < Rails::AppBuilder
|
4
|
+
def readme
|
5
|
+
copy_file 'README', 'README.md'
|
6
|
+
end
|
7
|
+
|
8
|
+
def app
|
9
|
+
empty_directory 'app'
|
10
|
+
inside 'app' do
|
11
|
+
empty_directory 'assets'
|
12
|
+
inside 'assets' do
|
13
|
+
empty_directory_with_gitkeep 'images'
|
14
|
+
directory 'javascripts'
|
15
|
+
directory 'stylesheets'
|
16
|
+
end
|
17
|
+
directory 'controllers'
|
18
|
+
directory 'helpers'
|
19
|
+
empty_directory_with_gitkeep 'mailers'
|
20
|
+
empty_directory_with_gitkeep 'models'
|
21
|
+
directory 'views'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def public_directory
|
26
|
+
empty_directory 'public'
|
27
|
+
inside 'public' do
|
28
|
+
template '404.html'
|
29
|
+
template '422.html'
|
30
|
+
template '500.html'
|
31
|
+
template 'favicon.ico'
|
32
|
+
template 'robots.txt'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def leftovers
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
require 'rails-archer/generators/app/app_builder'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Archer
|
7
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
8
|
+
class << self
|
9
|
+
def default_source_root
|
10
|
+
path = File.join default_generator_root, 'templates'
|
11
|
+
path if File.exists? path
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def default_generator_root
|
17
|
+
File.dirname __FILE__
|
18
|
+
end
|
19
|
+
|
20
|
+
def banner
|
21
|
+
"shoot new #{self.arguments.map(&:usage).join(' ')} [options]"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
source_root default_source_root
|
26
|
+
|
27
|
+
source_paths << default_source_root
|
28
|
+
source_paths << Rails::Generators::AppGenerator.source_root
|
29
|
+
|
30
|
+
class_option :database, default: 'mysql'
|
31
|
+
class_option :skip_test_unit, default: true
|
32
|
+
|
33
|
+
def initialize(*args)
|
34
|
+
if args[0].blank?
|
35
|
+
raise Rails::Generators::Error, <<-NOTICE.strip_heredoc
|
36
|
+
Options should be given after the application name.
|
37
|
+
For details run: shoot --help
|
38
|
+
NOTICE
|
39
|
+
end
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def get_builder_class
|
46
|
+
defined?(::AppBuilder) ? ::AppBuilder : ::Rails::Archer::AppBuilder
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= camelized %></title>
|
5
|
+
<%%= stylesheet_link_tag 'application', media: 'all' %>
|
6
|
+
<%%= csrf_meta_tags %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<%%= yield %>
|
11
|
+
|
12
|
+
<%%= javascript_include_tag 'application' %>
|
13
|
+
</body>
|
14
|
+
</html>
|
data/lib/rails-archer.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails-archer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'rails-archer'
|
8
|
+
gem.version = Rails::Archer::VERSION
|
9
|
+
gem.authors = ['Tse-Ching Ho']
|
10
|
+
gem.email = ['tsechingho@gmail.com']
|
11
|
+
gem.description = %q{Rails archer shoots off a rails project with helpful tools.}
|
12
|
+
gem.summary = %q{Shoots off a rails project with helpful tools.}
|
13
|
+
gem.homepage = 'https://github.com/tsechingho/rails-archer'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'bundler', '>= 1.2'
|
21
|
+
gem.add_dependency 'railties', '>= 3.2'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-archer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tse-Ching Ho
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: railties
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.2'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.2'
|
46
|
+
description: Rails archer shoots off a rails project with helpful tools.
|
47
|
+
email:
|
48
|
+
- tsechingho@gmail.com
|
49
|
+
executables:
|
50
|
+
- shoot
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/shoot
|
60
|
+
- lib/rails-archer.rb
|
61
|
+
- lib/rails-archer/generators/app/USAGE
|
62
|
+
- lib/rails-archer/generators/app/app_builder.rb
|
63
|
+
- lib/rails-archer/generators/app/app_generator.rb
|
64
|
+
- lib/rails-archer/generators/app/templates/.gitkeep
|
65
|
+
- lib/rails-archer/generators/app/templates/README
|
66
|
+
- lib/rails-archer/generators/app/templates/app/views/layouts/application.html.erb.tt
|
67
|
+
- lib/rails-archer/generators/app/templates/config/locales/en.yml
|
68
|
+
- lib/rails-archer/generators/app/templates/config/locales/zh-TW.yml
|
69
|
+
- lib/rails-archer/version.rb
|
70
|
+
- rails-archer.gemspec
|
71
|
+
homepage: https://github.com/tsechingho/rails-archer
|
72
|
+
licenses: []
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: -621507652504989274
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: -621507652504989274
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.24
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Shoots off a rails project with helpful tools.
|
101
|
+
test_files: []
|