listrophy-suprails 0.1.2 → 0.1.3

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/README CHANGED
@@ -48,6 +48,7 @@ delete "public/index.html"
48
48
  gpl
49
49
  git
50
50
  haml
51
+ save
51
52
 
52
53
  Installation
53
54
  ============
@@ -73,6 +74,10 @@ $ suprails AppName
73
74
  History/Bugs
74
75
  ====
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
+
76
81
  0.1.2 - Changed runcommand to runinside
77
82
 
78
83
  0.1.1 - Added the runcommand verb
data/bin/suprails CHANGED
@@ -32,12 +32,14 @@ def setup_suprails
32
32
  Dir.mkdir(File.expand_path('~/.suprails/sources'))
33
33
  Dir.mkdir(File.expand_path('~/.suprails/facets'))
34
34
  require 'ftools'
35
- config_source = File.expand_path(File.dirname(__FILE__) + '/../.suprails.example')
35
+ config_source = File.expand_path(File.dirname(__FILE__) + '/../suprails.config.example')
36
36
  config_dest = File.expand_path('~/.suprails/config')
37
37
  File.copy(config_source, config_dest, false)
38
38
  Dir[File.dirname(__FILE__) + '/../facets/*.rb'].each do |f|
39
39
  File.copy(f, File.expand_path('~/.suprails/facets/'), false)
40
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."
41
43
  end
42
44
 
43
45
  # Does the ~/.suprails folder exist?
@@ -50,7 +52,7 @@ if opts.length == 0
50
52
  puts 'You must provide a Rails Application Name'
51
53
  else
52
54
  # If options include -v or --version, print the version and exit
53
- if opts.any? {|opt| %w{-v --version}.include?(x)}
55
+ if opts.any? {|opt| %w{-v --version}.include?(opt)}
54
56
  puts SUPRAILS_VERSION
55
57
  exit
56
58
  end
data/lib/db.rb CHANGED
@@ -18,6 +18,8 @@
18
18
  # along with Suprails. If not, see <http://www.gnu.org/licenses/>.
19
19
  #
20
20
 
21
+ require File.dirname(__FILE__) + '/yaml_helper'
22
+
21
23
  class DB
22
24
  attr_reader :development, :test, :production
23
25
  class Environment
@@ -62,6 +64,11 @@ class DB
62
64
  @production = Environment.new 'production'
63
65
  @app_name = app_name
64
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
65
72
 
66
73
  def create
67
74
  `cd #{@app_name}; rake db:create`
data/lib/gems.rb CHANGED
@@ -22,56 +22,21 @@ class Gems
22
22
  def initialize app_name
23
23
  @app_name = app_name
24
24
  end
25
+
25
26
  def update *gems
26
- if gems.length
27
- args = ''
28
- gems.each {|x| args += " #{x}"}
29
- result = `gem update #{args}`
30
- if result
31
- puts 'Gem update failed. Please enter your admin password for sudo gem update:'
32
- `sudo gem update #{args}`
33
- end
34
- else
35
- result = `gem update`
36
- if result
37
- puts 'Gem update failed. Please enter your admin password for sudo gem update:'
38
- `sudo gem update`
39
- end
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}`
40
32
  end
41
- end
42
-
33
+ end
34
+
43
35
  def config *gems
44
- # need to do some file editing here
45
- to_insert = []
46
- @gems = []
47
-
48
- gems.each do |g|
49
- to_insert << " config.gem '#{g}'\n"
50
- @gems << g
51
- end
52
-
53
- file_contents = []
54
-
55
- File.open("#{@app_name}/config/environment.rb", 'r') do |f|
56
- f.each {|l| file_contents << l }
57
- end
58
-
59
- insertion_point = 0
60
- file_contents.reverse.each_index do |i|
61
- if file_contents[i] =~ /config\.gem/
62
- insertion_point = i
63
- break
64
- end
65
- end
66
-
67
- to_insert.each {|x| file_contents.insert(insertion_point, x) }
68
-
69
- File.open("#{@app_name}/config/environment.rb", 'w') do |f|
70
- file_contents.each do |l|
71
- f.puts l
72
- end
73
- end
74
- # `cd #{@app_name}; rake gems:install`
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"
75
40
  end
76
41
 
77
42
  def unpack
data/lib/runner.rb CHANGED
@@ -18,6 +18,7 @@
18
18
  # along with Suprails. If not, see <http://www.gnu.org/licenses/>.
19
19
  #
20
20
 
21
+ require File.dirname(__FILE__) + '/insertion_helper'
21
22
  require File.dirname(__FILE__) + '/db'
22
23
  require File.dirname(__FILE__) + '/gems'
23
24
  require File.dirname(__FILE__) + '/facet'
@@ -38,8 +39,9 @@ class Runner
38
39
  Facet.registered_facets.each do |name, facet|
39
40
  self.class.send(:define_method, name) {}
40
41
  instance_eval do
41
- self.class.send(:define_method, name) do
42
- facet.go Runner.app_name
42
+ self.class.send(:define_method, name) do |*args|
43
+ args.unshift(Runner.app_name)
44
+ facet.go *args
43
45
  end
44
46
  end
45
47
  end
@@ -91,9 +93,13 @@ class Runner
91
93
  end
92
94
  end
93
95
 
94
- def file source_file, destination
96
+ def file source_file, destination, absolute = false
95
97
  require 'ftools'
96
- source = File.expand_path "#{@sources}/#{source_file}"
98
+ if absolute
99
+ source = File.expand_path "#{source_file}"
100
+ else
101
+ source = File.expand_path "#{@sources}/#{source_file}"
102
+ end
97
103
  dest = File.expand_path "./#{Runner.app_name}/#{destination}"
98
104
  File.copy(source, dest, false) if File.exists? source
99
105
  end
@@ -148,6 +154,10 @@ class Runner
148
154
  shell "cd #{Runner.app_name}; #{opts.join(' ')}"
149
155
  end
150
156
 
157
+ def save
158
+ file @runfile, "doc/suprails.config", true
159
+ end
160
+
151
161
  private
152
162
 
153
163
  def shell cmd
@@ -30,7 +30,9 @@
30
30
  # require you to enter your root password, as sudo will probably be called
31
31
  # You should probably do this before issuing the rails command
32
32
  # Example:
33
- # gems.update :rspec, "rspec-rails", :haml, :capistrano
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
34
36
  #
35
37
  # You could instead update all gems
36
38
  # Example:
@@ -53,14 +55,14 @@ rails
53
55
  # gems.unpack
54
56
 
55
57
  # Plugins are also available for installation.
56
- plugin "git://github.com/rails/exception_notification"
58
+ # plugin "git://github.com/rails/exception_notification"
57
59
 
58
60
  # And you can generate stuff, too
59
61
  # Example:
60
62
  # generate :rspec
61
63
  # generate "model", "Model", "name:string"
62
64
 
63
- # Creating new folders is easy. Here's one for Haml
65
+ # Creating new folders is easy. Here's one for Haml/Sass
64
66
  # Example:
65
67
  # folder "public/stylesheets/sass"
66
68
 
@@ -102,14 +104,21 @@ git
102
104
  # svn
103
105
 
104
106
  # Need a command not supplied (yet!) by suprails?
105
- # You can extend it by using runcommand
107
+ # You can extend it by using runinside
106
108
  # Example:
107
- # runcommand "capify ."
109
+ # runinside "capify ."
108
110
 
109
- # Oh yeah, you can use plugins, too. Except, to prevent confusion with real
110
- # rails plugins, we call them facets for suprails. They should be installed at:
111
+ # Oh yeah, you can use suprails plugins, too. Except, to prevent confusion with
112
+ # real rails plugins, we call them facets for suprails. They should be
113
+ # installed at:
111
114
  # ~/.suprails/facets
112
115
  # Haml is one such facet. It requires special attention because installing it
113
116
  # as a plugin does not complete its installation into the rails app
114
117
  # Example:
115
118
  # haml
119
+
120
+ # Finally, you can save a copy of this configuration file into your rails app's
121
+ # doc directory with the 'save' command
122
+ # Example:
123
+ # save
124
+ save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listrophy-suprails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Grzesiak
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-31 00:00:00 -07:00
13
- default_executable:
12
+ date: 2008-11-09 00:00:00 -08:00
13
+ default_executable: suprails
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -40,9 +40,9 @@ files:
40
40
  - lib/suprails.rb
41
41
  - facets/haml.rb
42
42
  - bin/suprails
43
- - .suprails.example
43
+ - suprails.config.example
44
44
  has_rdoc: false
45
- homepage: http://github.com/listrophy/suprails
45
+ homepage: http://suprails.org
46
46
  post_install_message:
47
47
  rdoc_options: []
48
48
 
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version:
63
63
  requirements: []
64
64
 
65
- rubyforge_project:
65
+ rubyforge_project: suprails
66
66
  rubygems_version: 1.2.0
67
67
  signing_key:
68
68
  specification_version: 2