angelic-suprails 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,92 @@
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 # saves a copy of the configfile into rails app
52
+
53
+ Installation
54
+ ============
55
+
56
+ $ sudo gem install suprails
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.2.1 - Added ability to specify a particular config file when running suprails
80
+ Added output for all commands
81
+ Updated help text when suprails is run without args (after 1st time)
82
+
83
+ 0.1.3 - Added the save command and extended the file command
84
+
85
+ 0.1.2 - Changed runcommand to runinside
86
+
87
+ 0.1.1 - Added the runcommand verb
88
+
89
+ 0.1 - The DB commands do not yet work. You have to just use the file command
90
+ instead.
91
+
92
+ 0.0.0 - Initial readme. No code.
data/TODO ADDED
@@ -0,0 +1,35 @@
1
+ 20-Nov-08
2
+ ---------
3
+
4
+ Need to provide facets with access to all standard suprails commands
5
+ - (michelangeloaltamore)
6
+
7
+ 13-Oct-08
8
+ ---------
9
+ Command list is tentatively:
10
+
11
+ sources "foldername"
12
+ rails
13
+ freeze
14
+ gems.config [:development|:test|:production] [ :gemname1 [, "gemname2" [...]]]
15
+ gems.update [ "gemname1" [, :gemname2 [...]]]
16
+ gems.unpack
17
+ plugin "pluginlocation"
18
+ generate "generator" [ :optional_argument [, "optional_argument2" [...]]]
19
+ folder "foldername"
20
+ file "sourcefile", "destfile"
21
+ delete "filename"
22
+ gpl
23
+ db.(development|test|production).(adapter|encoding|database|username|password|host) "value"
24
+ db.create
25
+ rake "rake-task"
26
+ git
27
+ svn
28
+ (facet-name)
29
+ (facet-name).(cmd) [ :optional_argument1 [, "optional_argument2" [...]]]
30
+
31
+ =========
32
+
33
+ courtesy of nice_burger on irc.freenode.net#rubyonrails
34
+
35
+ 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.
@@ -0,0 +1,95 @@
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.2.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 <<-EOF
53
+ Usage: /usr/bin/suprails /path/to/your/app [options]
54
+
55
+ Options:
56
+ -v, --version Show the Suprails version number and quit.
57
+ -c, --config filename Configuration file to use (^foo resolves to ~/.suprails/config.foo)
58
+
59
+ Description:
60
+ The 'suprails' command parses a configuration file to create a new Ruby on
61
+ Rails application customized however you'd like.
62
+
63
+ Examples:
64
+ suprails ~/dev/pro/WidgetStoreFront
65
+
66
+ This generates a Rails application in ~/dev/pro/WidgetStoreFront with all
67
+ the customizations you specified in ~/.suprails/config
68
+
69
+ suprails ~/dev/fun/BazBlog -c ^bort
70
+
71
+ This generates a Rails application in ~/dev/fun/BazBlog with all the
72
+ customizations you specified in ~/.suprails/config.bort
73
+ EOF
74
+ else
75
+ # If options include -v or --version, print the version and exit
76
+ if opts.any? {|opt| %w{-v --version}.include?(opt)}
77
+ puts "Suprails Version: #{SUPRAILS_VERSION}"
78
+ exit
79
+ end
80
+
81
+ # setup the config file, using ~/.suprails/config as default
82
+ config = opts.index('-c') || opts.index('--config') || '~/.suprails/config'
83
+ if config.is_a? Fixnum
84
+ opts.delete_at(config)
85
+ config = opts.delete_at(config)
86
+ # allow "^foo" to resolve to "~/.suprails/config.foo"
87
+ config = config.sub(/\A(\^)/, '~/.suprails/config.')
88
+ end
89
+
90
+ if opts.first =~ /^[a-zA-Z0-9]+/
91
+ Suprails.new(opts.shift).create_project(config)
92
+ else
93
+ puts 'Invalid Application Name. Must start with alphanumeric character!'
94
+ end
95
+ end
@@ -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
@@ -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
@@ -0,0 +1,56 @@
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
+ require File.dirname(__FILE__) + '/suprails_helper'
38
+
39
+ class Facet
40
+ include SuprailsHelper
41
+
42
+ @registered_facets = {}
43
+ class << self
44
+ attr_reader :registered_facets
45
+ private :new
46
+ end
47
+
48
+ def self.define(name, &block)
49
+ f = new
50
+ f.instance_eval(&block)
51
+ Facet.registered_facets[name] = f
52
+ end
53
+
54
+ extend FacetSugar
55
+ def_field :author, :version, :exposed_methods
56
+ end
@@ -0,0 +1,47 @@
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
+ InsertionHelper.insert_above file, "config.gem", to_insert[0..-2]
41
+ end
42
+
43
+ def unpack
44
+ `cd #{@app_name}; rake gems:unpack`
45
+ end
46
+ end
47
+
@@ -0,0 +1,40 @@
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 InsertionHelper
22
+
23
+ def self.insert_at filename, line_number, contents
24
+ file_contents = File.readlines(filename)
25
+ file_contents.insert(line_number-1, "#{contents}\n")
26
+ File.open(filename, 'w') {|f| f << file_contents }
27
+ end
28
+
29
+ def self.file_sub! filename, pattern, contents
30
+ file_contents = File.read(filename)
31
+ file_contents.sub!(pattern, contents)
32
+ File.open(filename, 'w') {|f| f << file_contents }
33
+ end
34
+
35
+ def self.insert_above filename, search_string, contents
36
+ file_contents = File.read(filename)
37
+ file_contents.sub!(/(^.*#{Regexp.escape(search_string)}.*$)/, "#{contents}\n\\1")
38
+ File.open(filename, 'w') {|f| f << file_contents}
39
+ end
40
+ end