suprails 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +674 -0
- data/README +88 -0
- data/TODO +29 -0
- data/bin/suprails +72 -0
- data/facets/haml.rb +28 -0
- data/lib/db.rb +80 -0
- data/lib/facet.rb +52 -0
- data/lib/gems.rb +46 -0
- data/lib/runner.rb +167 -0
- data/lib/suprails.rb +41 -0
- data/suprails.config.example +124 -0
- metadata +72 -0
data/README
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Copyright 2008 Bradley Grzesiak
|
2
|
+
# This file is part of Suprails.
|
3
|
+
#
|
4
|
+
# Suprails is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# Suprails is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
Suprails
|
18
|
+
========
|
19
|
+
|
20
|
+
This project is intended to be a replacement for the "rails" command. It
|
21
|
+
does not replace the rails framework but rather provides a starting point
|
22
|
+
for a rails application far beyond what the "rails" command provides.
|
23
|
+
During execution, in fact, the suprails command calls the rails command.
|
24
|
+
|
25
|
+
Suprails has a website at http://suprails.org Eventually, it will be a place
|
26
|
+
where suprails users can exchange config files and facets.
|
27
|
+
|
28
|
+
How it works
|
29
|
+
============
|
30
|
+
|
31
|
+
Suprails is unlike most other "Rails plus other stuff" projects out there.
|
32
|
+
Instead of me, the Suprails author, deciding what you should have in your rails
|
33
|
+
app, you get to decide. In addition, any time you execute Suprails, you have
|
34
|
+
the option to update any gems that would otherwise be out-of-date.
|
35
|
+
|
36
|
+
Example configuration file (~/.suprails/config)
|
37
|
+
===============================================
|
38
|
+
|
39
|
+
# Notice that ruby comments work just fine!
|
40
|
+
# gems.update "rspec", "rails", "rspec-rails", "haml", "capistrano"
|
41
|
+
frozen_rails
|
42
|
+
gems.config :haml
|
43
|
+
gems.unpack
|
44
|
+
plugin "git://github.com/rails/exception_notification"
|
45
|
+
generate :rspec
|
46
|
+
folder "public/stylesheets/sass"
|
47
|
+
delete "public/index.html"
|
48
|
+
gpl
|
49
|
+
git
|
50
|
+
haml
|
51
|
+
save
|
52
|
+
|
53
|
+
Installation
|
54
|
+
============
|
55
|
+
|
56
|
+
$ sudo gem install listrophy-suprails --source http://gems.github.com
|
57
|
+
|
58
|
+
Execution
|
59
|
+
============
|
60
|
+
|
61
|
+
First, run suprails without any arguments:
|
62
|
+
|
63
|
+
$ suprails
|
64
|
+
|
65
|
+
This will initialize your ~/.suprails/ folder and configuration in that folder
|
66
|
+
|
67
|
+
You will now want to edit the configuration file to your liking. It is located
|
68
|
+
at: ~/.suprails/config
|
69
|
+
|
70
|
+
Now, run suprails instead of rails:
|
71
|
+
|
72
|
+
$ suprails AppName
|
73
|
+
|
74
|
+
History/Bugs
|
75
|
+
====
|
76
|
+
|
77
|
+
gems.config currently only accepts one arg.
|
78
|
+
|
79
|
+
0.1.3 - Added the save command and extended the file command
|
80
|
+
|
81
|
+
0.1.2 - Changed runcommand to runinside
|
82
|
+
|
83
|
+
0.1.1 - Added the runcommand verb
|
84
|
+
|
85
|
+
0.1 - The DB commands do not yet work. You have to just use the file command
|
86
|
+
instead.
|
87
|
+
|
88
|
+
0.0.0 - Initial readme. No code.
|
data/TODO
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
13-Oct-08
|
2
|
+
---------
|
3
|
+
Command list is tentatively:
|
4
|
+
|
5
|
+
sources "foldername"
|
6
|
+
rails
|
7
|
+
freeze
|
8
|
+
gems.config [:development|:test|:production] [ :gemname1 [, "gemname2" [...]]]
|
9
|
+
gems.update [ "gemname1" [, :gemname2 [...]]]
|
10
|
+
gems.unpack
|
11
|
+
plugin "pluginlocation"
|
12
|
+
generate "generator" [ :optional_argument [, "optional_argument2" [...]]]
|
13
|
+
folder "foldername"
|
14
|
+
file "sourcefile", "destfile"
|
15
|
+
delete "filename"
|
16
|
+
gpl
|
17
|
+
db.(development|test|production).(adapter|encoding|database|username|password|host) "value"
|
18
|
+
db.create
|
19
|
+
rake "rake-task"
|
20
|
+
git
|
21
|
+
svn
|
22
|
+
(facet-name)
|
23
|
+
(facet-name).(cmd) [ :optional_argument1 [, "optional_argument2" [...]]]
|
24
|
+
|
25
|
+
=========
|
26
|
+
|
27
|
+
courtesy of nice_burger on irc.freenode.net#rubyonrails
|
28
|
+
|
29
|
+
I18n,globalize2 for that. map.root in route.db to welcome or something. install haml, if only to get sass. freeze rails, action_mailer stuff for restful_auth, exception_notifier is good, capify, shoulda for tests, app_config plugin, put something nice in README, set up on github (ssh keys stuff to worry about). um, for starters.
|
data/bin/suprails
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Suprails: The customizable wrapper to the rails command
|
4
|
+
#
|
5
|
+
# Copyright 2008 Bradley Grzesiak
|
6
|
+
# This file is part of Suprails.
|
7
|
+
#
|
8
|
+
# Suprails is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Suprails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#
|
21
|
+
|
22
|
+
require File.dirname(__FILE__) + '/../lib/suprails'
|
23
|
+
opts = ARGV
|
24
|
+
SUPRAILS_VERSION = 0.1
|
25
|
+
|
26
|
+
def is_setup?
|
27
|
+
File.exists?(File.expand_path('~/.suprails'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_suprails
|
31
|
+
Dir.mkdir(File.expand_path('~/.suprails'))
|
32
|
+
Dir.mkdir(File.expand_path('~/.suprails/sources'))
|
33
|
+
Dir.mkdir(File.expand_path('~/.suprails/facets'))
|
34
|
+
require 'ftools'
|
35
|
+
config_source = File.expand_path(File.dirname(__FILE__) + '/../suprails.config.example')
|
36
|
+
config_dest = File.expand_path('~/.suprails/config')
|
37
|
+
File.copy(config_source, config_dest, false)
|
38
|
+
Dir[File.dirname(__FILE__) + '/../facets/*.rb'].each do |f|
|
39
|
+
File.copy(f, File.expand_path('~/.suprails/facets/'), false)
|
40
|
+
end
|
41
|
+
puts "Finished setting up suprails in #{File.expand_path('~/.suprails')}"
|
42
|
+
puts "You probably want to edit the config file in there now."
|
43
|
+
end
|
44
|
+
|
45
|
+
# Does the ~/.suprails folder exist?
|
46
|
+
if !is_setup?
|
47
|
+
setup_suprails
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
if opts.length == 0
|
52
|
+
puts 'You must provide a Rails Application Name'
|
53
|
+
else
|
54
|
+
# If options include -v or --version, print the version and exit
|
55
|
+
if opts.any? {|opt| %w{-v --version}.include?(opt)}
|
56
|
+
puts SUPRAILS_VERSION
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
|
60
|
+
# setup the config file, using ~/.suprails/config as default
|
61
|
+
config = opts.index('-c') || opts.index('--config') || '~/.suprails/config'
|
62
|
+
if config.is_a? Fixnum
|
63
|
+
opts.delete_at(config)
|
64
|
+
config = opts.delete_at(config)
|
65
|
+
end
|
66
|
+
|
67
|
+
if opts.first =~ /^[a-zA-Z0-9]+/
|
68
|
+
Suprails.new(opts.shift).create_project
|
69
|
+
else
|
70
|
+
puts 'Invalid Application Name. Must start with alphanumeric character!'
|
71
|
+
end
|
72
|
+
end
|
data/facets/haml.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Haml Facet for Suprails
|
3
|
+
# Copyright 2008 Bradley Grzesiak
|
4
|
+
# This file is part of Suprails.
|
5
|
+
#
|
6
|
+
# Suprails is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Suprails is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
Facet.define "haml" do
|
21
|
+
author "Bradley Grzesiak"
|
22
|
+
version "0.1"
|
23
|
+
|
24
|
+
def go app_name
|
25
|
+
puts 'Running haml'
|
26
|
+
`haml --rails #{app_name}`
|
27
|
+
end
|
28
|
+
end
|
data/lib/db.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Suprails: The customizable wrapper to the rails command
|
3
|
+
#
|
4
|
+
# Copyright 2008 Bradley Grzesiak
|
5
|
+
# This file is part of Suprails.
|
6
|
+
#
|
7
|
+
# Suprails is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Suprails is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require File.dirname(__FILE__) + '/yaml_helper'
|
22
|
+
|
23
|
+
class DB
|
24
|
+
attr_reader :development, :test, :production
|
25
|
+
class Environment
|
26
|
+
def initialize db_type
|
27
|
+
@db_type = db_type
|
28
|
+
end
|
29
|
+
def adapter adapter
|
30
|
+
# puts "db.#{@db_type}.adapter #{adapter}"
|
31
|
+
puts 'database.yml modification not yet implemented'
|
32
|
+
end
|
33
|
+
def db db
|
34
|
+
# puts "db.#{@db_type}.db #{db}"
|
35
|
+
puts 'database.yml modification not yet implemented'
|
36
|
+
end
|
37
|
+
def database datab
|
38
|
+
db datab
|
39
|
+
end
|
40
|
+
def host h
|
41
|
+
# puts "db.#{@db_type}.host #{h}"
|
42
|
+
puts 'database.yml modification not yet implemented'
|
43
|
+
end
|
44
|
+
def username uname
|
45
|
+
# puts "db.#{@db_type}.username #{uname}"
|
46
|
+
puts 'database.yml modification not yet implemented'
|
47
|
+
end
|
48
|
+
def password passwd
|
49
|
+
# puts "db.#{@db_type}.password #{passwd}"
|
50
|
+
puts 'database.yml modification not yet implemented'
|
51
|
+
end
|
52
|
+
def socket s
|
53
|
+
# puts "db.#{@db_type}.socket #{s}"
|
54
|
+
puts 'database.yml modification not yet implemented'
|
55
|
+
end
|
56
|
+
def timeout to
|
57
|
+
# puts "db.#{@db_type}.timeout #{to}"
|
58
|
+
puts 'database.yml modification not yet implemented'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
def initialize app_name
|
62
|
+
@development = Environment.new 'development'
|
63
|
+
@test = Environment.new 'test'
|
64
|
+
@production = Environment.new 'production'
|
65
|
+
@app_name = app_name
|
66
|
+
end
|
67
|
+
|
68
|
+
def save_yaml database_hash
|
69
|
+
file = "#{@app_name}/config/database.yml"
|
70
|
+
YAMLHelper.create_yaml file, database_hash
|
71
|
+
end
|
72
|
+
|
73
|
+
def create
|
74
|
+
`cd #{@app_name}; rake db:create`
|
75
|
+
end
|
76
|
+
def migrate
|
77
|
+
`cd #{@app_name}; rake db:migrate`
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
data/lib/facet.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Suprails: The customizable wrapper to the rails command
|
3
|
+
#
|
4
|
+
# Copyright 2008 Bradley Grzesiak
|
5
|
+
# This file is part of Suprails.
|
6
|
+
#
|
7
|
+
# Suprails is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Suprails is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
# See: http://eigenclass.org/hiki.rb?ruby+plugins
|
22
|
+
module FacetSugar
|
23
|
+
def def_field(*names)
|
24
|
+
class_eval do
|
25
|
+
names.each do |name|
|
26
|
+
define_method(name) do |*args|
|
27
|
+
case args.size
|
28
|
+
when 0: instance_variable_get("@#{name}")
|
29
|
+
else instance_variable_set("@#{name}", *args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Facet
|
38
|
+
@registered_facets = {}
|
39
|
+
class << self
|
40
|
+
attr_reader :registered_facets
|
41
|
+
private :new
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.define(name, &block)
|
45
|
+
f = new
|
46
|
+
f.instance_eval(&block)
|
47
|
+
Facet.registered_facets[name] = f
|
48
|
+
end
|
49
|
+
|
50
|
+
extend FacetSugar
|
51
|
+
def_field :author, :version, :exposed_methods
|
52
|
+
end
|
data/lib/gems.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Suprails: The customizable wrapper to the rails command
|
3
|
+
#
|
4
|
+
# Copyright 2008 Bradley Grzesiak
|
5
|
+
# This file is part of Suprails.
|
6
|
+
#
|
7
|
+
# Suprails is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Suprails is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
class Gems
|
22
|
+
def initialize app_name
|
23
|
+
@app_name = app_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def update *gems
|
27
|
+
args = gems.inject('') {|text, g| "#{text} #{g}"}
|
28
|
+
result = `gem update #{args}`
|
29
|
+
if result
|
30
|
+
puts 'Gem update failed. Please enter your admin password for sudo gem update:'
|
31
|
+
`sudo gem update #{args}`
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def config *gems
|
36
|
+
@gems = gems
|
37
|
+
to_insert = gems.inject("") {|text, g| "#{text} config.gem '#{g}'\n"}
|
38
|
+
file = "#{@app_name}/config/environment.rb"
|
39
|
+
InsertionHelper.file_sub! file, /(config\.gem)/, "#{to_insert}\\1"
|
40
|
+
end
|
41
|
+
|
42
|
+
def unpack
|
43
|
+
`cd #{@app_name}; rake gems:unpack`
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/runner.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
#
|
2
|
+
# Suprails: The customizable wrapper to the rails command
|
3
|
+
#
|
4
|
+
# Copyright 2008 Bradley Grzesiak
|
5
|
+
# This file is part of Suprails.
|
6
|
+
#
|
7
|
+
# Suprails is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Suprails is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require File.dirname(__FILE__) + '/insertion_helper'
|
22
|
+
require File.dirname(__FILE__) + '/db'
|
23
|
+
require File.dirname(__FILE__) + '/gems'
|
24
|
+
require File.dirname(__FILE__) + '/facet'
|
25
|
+
|
26
|
+
class Runner
|
27
|
+
|
28
|
+
class << self
|
29
|
+
attr_accessor :app_name
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(app_name, runfile = "~/.suprails/config")
|
33
|
+
Runner.app_name = app_name
|
34
|
+
@runfile = File.expand_path(runfile)
|
35
|
+
@sources = File.expand_path('~/.suprails/sources/')
|
36
|
+
@facets_source = File.expand_path('~/.suprails/facets/')
|
37
|
+
Dir["#{@facets_source}/*.rb"].each{|x| load x }
|
38
|
+
|
39
|
+
Facet.registered_facets.each do |name, facet|
|
40
|
+
self.class.send(:define_method, name) {}
|
41
|
+
instance_eval do
|
42
|
+
self.class.send(:define_method, name) do |*args|
|
43
|
+
args.unshift(Runner.app_name)
|
44
|
+
facet.go *args
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def methods
|
51
|
+
super.each{|x| puts x}
|
52
|
+
end
|
53
|
+
|
54
|
+
def run
|
55
|
+
gems = Gems.new Runner.app_name
|
56
|
+
db = DB.new Runner.app_name
|
57
|
+
@base = File.expand_path "./#{Runner.app_name}"
|
58
|
+
Dir.mkdir(@base)
|
59
|
+
text = File.read(@runfile).split('\n')
|
60
|
+
text.each {|l| instance_eval(l)}
|
61
|
+
end
|
62
|
+
|
63
|
+
def sources sourcefolder
|
64
|
+
@sources = File.expand_path "#{sourcefolder}/"
|
65
|
+
end
|
66
|
+
|
67
|
+
def rails
|
68
|
+
`rails #{Runner.app_name}`
|
69
|
+
end
|
70
|
+
|
71
|
+
def frozen_rails
|
72
|
+
`rails #{Runner.app_name} --freeze`
|
73
|
+
end
|
74
|
+
|
75
|
+
def debug p = ''
|
76
|
+
puts "debug: #{p}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def plugin plugin_location
|
80
|
+
runinside("script/plugin install #{plugin_location}")
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate generator, *opts
|
84
|
+
runinside("script/generate #{generator} #{opts.join(' ')}")
|
85
|
+
end
|
86
|
+
|
87
|
+
def folder folder_name
|
88
|
+
path = "#{@base}/"
|
89
|
+
paths = folder_name.split('/')
|
90
|
+
paths.each do |p|
|
91
|
+
path += "#{p}/"
|
92
|
+
Dir.mkdir path if !File.exists? path
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def file source_file, destination, absolute = false
|
97
|
+
require 'ftools'
|
98
|
+
if absolute
|
99
|
+
source = File.expand_path "#{source_file}"
|
100
|
+
else
|
101
|
+
source = File.expand_path "#{@sources}/#{source_file}"
|
102
|
+
end
|
103
|
+
dest = File.expand_path "./#{Runner.app_name}/#{destination}"
|
104
|
+
File.copy(source, dest, false) if File.exists? source
|
105
|
+
end
|
106
|
+
|
107
|
+
def delete file_name
|
108
|
+
file_name = "#{@base}/#{file_name}"
|
109
|
+
File.delete file_name if File.exists?(file_name)
|
110
|
+
end
|
111
|
+
|
112
|
+
def gpl
|
113
|
+
puts 'Installing the GPL into COPYING'
|
114
|
+
require 'net/http'
|
115
|
+
http = Net::HTTP.new('www.gnu.org')
|
116
|
+
path = '/licenses/gpl-3.0.txt'
|
117
|
+
begin
|
118
|
+
resp = http.get(path)
|
119
|
+
if resp.code == '200'
|
120
|
+
File.open("#{@base}/COPYING", 'w') do |f|
|
121
|
+
f.puts(resp.body)
|
122
|
+
end
|
123
|
+
else
|
124
|
+
puts "Error #{resp.code} while retrieving GPL text."
|
125
|
+
end
|
126
|
+
rescue SocketError
|
127
|
+
puts 'SocketError: You might not be connected to the internet. GPL retrieval failed.'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def rake *opts
|
132
|
+
runinside("rake #{opts.join(' ')}")
|
133
|
+
end
|
134
|
+
|
135
|
+
def git
|
136
|
+
gem = false
|
137
|
+
begin
|
138
|
+
gem = require 'git'
|
139
|
+
rescue LoadError => e
|
140
|
+
nil
|
141
|
+
end
|
142
|
+
if gem
|
143
|
+
g = Git.init(@base)
|
144
|
+
else
|
145
|
+
runinside 'git init'
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def svn
|
150
|
+
runinside 'svnadmin create'
|
151
|
+
end
|
152
|
+
|
153
|
+
def runinside *opts
|
154
|
+
shell "cd #{Runner.app_name}; #{opts.join(' ')}"
|
155
|
+
end
|
156
|
+
|
157
|
+
def save
|
158
|
+
file @runfile, "doc/suprails.config", true
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def shell cmd
|
164
|
+
`#{cmd}`
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
data/lib/suprails.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Suprails: The customizable wrapper to the rails command
|
3
|
+
#
|
4
|
+
# Copyright 2008 Bradley Grzesiak
|
5
|
+
# This file is part of Suprails.
|
6
|
+
#
|
7
|
+
# Suprails is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Suprails is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Suprails. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
# require 'rubygems'
|
22
|
+
require File.dirname(__FILE__) + '/runner'
|
23
|
+
|
24
|
+
class Suprails
|
25
|
+
|
26
|
+
attr_accessor :app_name
|
27
|
+
|
28
|
+
def initialize(app_name = "")
|
29
|
+
@app_name = app_name
|
30
|
+
@run_file = ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_project
|
34
|
+
Runner.new(@app_name).run
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
"Rails appname: #{@app_name}\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|