angelic-suprails 0.2.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.
@@ -0,0 +1,74 @@
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__) + '/suprails_helper'
22
+ require File.dirname(__FILE__) + '/facet'
23
+
24
+ class Runner
25
+ include SuprailsHelper
26
+
27
+ class << self
28
+ attr_accessor :app_name
29
+ attr_accessor :runfile
30
+ attr_accessor :sources
31
+ attr_accessor :facets_source
32
+ attr_accessor :base
33
+
34
+ def sources sourcefolder
35
+ @sources = File.expand_path "#{sourcefolder}/"
36
+ end
37
+
38
+ def init_variables(app_name, runfile)
39
+ @app_name = app_name
40
+ @runfile = File.expand_path(runfile)
41
+ @sources = File.expand_path('~/.suprails/sources/')
42
+ @facets_source = File.expand_path('~/.suprails/facets/')
43
+ @base = File.expand_path "./#{@app_name}"
44
+ end
45
+ end
46
+
47
+ def initialize(app_name, runfile = "~/.suprails/config")
48
+ Runner.init_variables(app_name, runfile)
49
+ Dir["#{Runner.facets_source}/*.rb"].each{|x| load x }
50
+
51
+ Facet.registered_facets.each do |name, facet|
52
+ self.class.send(:define_method, name) {}
53
+ instance_eval do
54
+ self.class.send(:define_method, name) do |*args|
55
+ args.unshift(Runner.app_name)
56
+ facet.go *args
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ def methods
63
+ super.each{|x| puts x}
64
+ end
65
+
66
+ def run
67
+ gems = Gems.new Runner.app_name
68
+ db = DB.new Runner.app_name
69
+
70
+ Dir.mkdir(Runner.base)
71
+ text = File.read(Runner.runfile)
72
+ instance_eval(text)
73
+ end
74
+ end
@@ -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 config_file
34
+ Runner.new(@app_name, config_file).run
35
+ end
36
+
37
+ def to_s
38
+ "Rails appname: #{@app_name}\n"
39
+ end
40
+
41
+ end
@@ -0,0 +1,104 @@
1
+ require File.dirname(__FILE__) + '/insertion_helper'
2
+ require File.dirname(__FILE__) + '/db'
3
+ require File.dirname(__FILE__) + '/gems'
4
+
5
+ module SuprailsHelper
6
+ def rails
7
+ shell "rails #{Runner.app_name}"
8
+ end
9
+
10
+ def frozen_rails
11
+ shell "rails #{Runner.app_name} --freeze"
12
+ end
13
+
14
+ def debug p = ''
15
+ puts "debug: #{p}"
16
+ end
17
+
18
+ def plugin plugin_location
19
+ runinside("script/plugin install #{plugin_location}")
20
+ end
21
+
22
+ def generate generator, *opts
23
+ runinside("script/generate #{generator} #{opts.join(' ')}")
24
+ end
25
+
26
+ def folder folder_name
27
+ path = "#{Runner.base}/"
28
+ puts "New folder: #{Runner.base}"
29
+ paths = folder_name.split('/')
30
+ paths.each do |p|
31
+ path += "#{p}/"
32
+ Dir.mkdir path if !File.exists? path
33
+ end
34
+ end
35
+
36
+ def file source_file, destination, absolute = false
37
+ require 'ftools'
38
+ if absolute
39
+ source = File.expand_path "#{source_file}"
40
+ else
41
+ source = File.expand_path "#{@sources}/#{source_file}"
42
+ end
43
+ dest = File.expand_path "./#{Runner.app_name}/#{destination}"
44
+ File.copy(source, dest, true) if File.exists? source
45
+ end
46
+
47
+ def delete file_name
48
+ file_name = "#{Runner.base}/#{file_name}"
49
+ puts "Deleting: #{file_name}"
50
+ File.delete file_name if File.exists?(file_name)
51
+ end
52
+
53
+ def gpl
54
+ puts 'Installing the GPL into COPYING'
55
+ require 'net/http'
56
+ http = Net::HTTP.new('www.gnu.org')
57
+ path = '/licenses/gpl-3.0.txt'
58
+ begin
59
+ resp = http.get(path)
60
+ if resp.code == '200'
61
+ File.open("#{Runner.base}/COPYING", 'w') do |f|
62
+ f.puts(resp.body)
63
+ end
64
+ else
65
+ puts "Error #{resp.code} while retrieving GPL text."
66
+ end
67
+ rescue SocketError
68
+ puts 'SocketError: You might not be connected to the internet. GPL retrieval failed.'
69
+ end
70
+ end
71
+
72
+ def rake *opts
73
+ runinside("rake #{opts.join(' ')}")
74
+ end
75
+
76
+ def git
77
+ runinside('git init')
78
+ end
79
+
80
+ def svn
81
+ runinside('svnadmin create')
82
+ end
83
+
84
+ def runinside *opts
85
+ shell "cd #{Runner.app_name}; #{opts.join(' ')}"
86
+ end
87
+
88
+ def save
89
+ file Runner.runfile, "doc/suprails.config", true
90
+ end
91
+
92
+ def new_file filename, contents
93
+ File.open(File.expand_path("./#{Runner.app_name}/#{filename}"), 'w') do |f|
94
+ f.puts contents
95
+ end
96
+ puts "Generating file: #{filename}"
97
+ end
98
+
99
+ private
100
+
101
+ def shell cmd
102
+ puts `#{cmd}`
103
+ end
104
+ end
@@ -0,0 +1,53 @@
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 'yaml'
22
+
23
+ class YAMLHelper
24
+ def self.create_yaml(file, values)
25
+ directory = File.dirname(file)
26
+ create_directory_unless_exists(directory)
27
+ File.open(file, 'w') {|f| f << YAML::dump(values) }
28
+ end
29
+
30
+ def self.modify_yaml(file, values)
31
+ if File.exist?(file)
32
+ config = YAML::load(File.open(file))
33
+ config.merge!(values)
34
+ else
35
+ config = values
36
+ end
37
+ create_yaml(file, config)
38
+ end
39
+
40
+ protected
41
+ def self.create_directory_unless_exists(directory)
42
+ directory = File.expand_path(directory)
43
+ starts_with_slash = directory.index('/') == 0
44
+ dir_arr = directory.split('/')
45
+ curr_dir = starts_with_slash ? '/' : ''
46
+ dir_arr.each do |dir|
47
+ curr_dir << "#{dir}/"
48
+ unless File.exist?(curr_dir)
49
+ Dir.mkdir(curr_dir)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,143 @@
1
+ #
2
+ # This is the example configuration file for Suprails
3
+ #
4
+
5
+ # It is important to realize that this file is essentially a ruby source file.
6
+ # Every statement that is not commented out with a '#' character, will be
7
+ # executed as a ruby expression. The most important aspect of this is that all
8
+ # string-based arguments must either be a symbol (where syntax allows) or
9
+ # enclosed in quotes. Additionally, arguments must be separated by a comma,
10
+ # just like a ruby method call.
11
+ #
12
+ # Example (will NOT work):
13
+ # gems.update rspec rspec-rails haml
14
+ # Example (will work):
15
+ # gems.update :rspec, "rspec-rails", :haml
16
+ #
17
+ # Also, the commands in this file are run in order. In other words, this file
18
+ # is functional, rather than declarative. If you try to update the rails gem
19
+ # after running the rails command, the update to rails will NOT take effect.
20
+
21
+ # Declare the location for your files to copy from. Let's say you have a
22
+ # helper file you always have, and you'd like it to be installed into the
23
+ # lib/ folder. This command defines the location of your master helper file
24
+ # (or any other similar files). Ideally, this should be one of your first
25
+ # commands
26
+ # Example (also the default):
27
+ # sources "~/.suprails/sources"
28
+
29
+ # Declare the gems you'd like to update. Keep in mind that this will likely
30
+ # require you to enter your root password, as sudo will probably be called
31
+ # You should probably do this before issuing the rails command
32
+ # Example:
33
+ # gems.update :rspec, "rspec-rails", :haml, :capistrano
34
+ # NOTE: symbols will generally work, but if the gem has a hyphen, it needs to
35
+ # be enclosed in quotes
36
+ #
37
+ # You could instead update all gems
38
+ # Example:
39
+ # gems.update
40
+
41
+ # There are two ways to run the rails generator: rails and frozen_rails.
42
+ # Only one should be called, so if you want frozen rails, comment out the
43
+ # rails command
44
+ #
45
+ # frozen_rails
46
+ rails
47
+
48
+ # Now, define the gems you wish to mention in the config/environment.rb file
49
+ # Example:
50
+ # gems.config :haml
51
+
52
+ # You can unpack the gems that you defined with gems.config by calling
53
+ # gems.unpack
54
+ # Example:
55
+ # gems.unpack
56
+
57
+ # Plugins are also available for installation.
58
+ # plugin "git://github.com/rails/exception_notification"
59
+
60
+ # And you can generate stuff, too
61
+ # Example:
62
+ # generate :rspec
63
+ # generate "model", "Model", "name:string"
64
+
65
+ # Creating new folders is easy. Here's one for Haml/Sass
66
+ # Example:
67
+ # folder "public/stylesheets/sass"
68
+
69
+ # You can also create new files with pre-existing content. Suprails looks for
70
+ # the existing file in the folder specified above in sources
71
+ # Example:
72
+ # file "site.sass", "public/stylesheets/sass/"
73
+
74
+ # You can delete files too
75
+ # Example:
76
+ # delete "public/index.html"
77
+ delete "public/index.html"
78
+
79
+ # There's a convenience method for the GPL. Because... you know... the GPL
80
+ # is good. and stuff. Note: this method accesses the GPL from the net.
81
+ # Example:
82
+ # gpl
83
+
84
+ # You can setup your database, too. Unfortunately, this is NOT YET IMPLEMENTED.
85
+ # Use 'file' to copy your database.yml file instead.
86
+ # Examples:
87
+ # db.development.adapter :sqlite3
88
+ # db.development.db "db/development.sqlite3"
89
+ # db.development.timeout 5000
90
+ # db.create
91
+ # db.migrate
92
+ #
93
+ # For the time being, you can instead use db.save_yaml
94
+ # Example:
95
+ # db.save_yaml({ "development" =>
96
+ # {"adapter" => 'sqlite3', 'database' => 'db/dev.sqlite3' }
97
+ # })
98
+
99
+ # Rake works too
100
+ # Example:
101
+ # rake
102
+
103
+ # Like Git? Set it up!
104
+ # Example:
105
+ # git
106
+ git
107
+
108
+ # Perhaps you like subversion? Use that instead!
109
+ # Example:
110
+ # svn
111
+
112
+ # Need a command not supplied (yet!) by suprails?
113
+ # You can extend it by using runinside
114
+ # Example:
115
+ # runinside "capify ."
116
+
117
+ # Oh yeah, you can use suprails plugins, too. Except, to prevent confusion with
118
+ # real rails plugins, we call them facets for suprails. They should be
119
+ # installed at:
120
+ # ~/.suprails/facets
121
+ # Haml is one such facet. It requires special attention because installing it
122
+ # as a plugin does not complete its installation into the rails app
123
+ # Example:
124
+ # haml
125
+
126
+ # If you want to create a new file from within this file (for archival
127
+ # purposes compared to the 'file' command), use the new_file command
128
+ # Example:
129
+ # new_file '.gitignore', <<-EOF
130
+ # log/*.log
131
+ # tmp/**/*
132
+ # .DS_Store
133
+ # doc/api
134
+ # doc/app
135
+ # coverage
136
+ # db/*.sqlite3
137
+ # EOF
138
+
139
+ # Finally, you can save a copy of this configuration file into your rails app's
140
+ # doc directory with the 'save' command
141
+ # Example:
142
+ # save
143
+ save
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angelic-suprails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Bradley Grzesiak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-30 00:00:00 -08:00
13
+ default_executable: suprails
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: This project is intended to be a replacement for the "rails" command. It does not replace the rails framework but rather provides a starting point for a rails application far beyond what the "rails" command provides. During execution, in fact, the suprails command calls the rails command.
25
+ email: listrophy@gmail.com
26
+ executables:
27
+ - suprails
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - README
34
+ - COPYING
35
+ - TODO
36
+ - lib/db.rb
37
+ - lib/facet.rb
38
+ - lib/gems.rb
39
+ - lib/insertion_helper.rb
40
+ - lib/runner.rb
41
+ - lib/suprails.rb
42
+ - lib/yaml_helper.rb
43
+ - lib/suprails_helper.rb
44
+ - facets/haml.rb
45
+ - bin/suprails
46
+ - suprails.config.example
47
+ has_rdoc: false
48
+ homepage: http://suprails.org
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: suprails
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: Suprails provides a wrapper to the rails command
73
+ test_files: []
74
+