suprails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gems.rb CHANGED
@@ -33,10 +33,11 @@ class Gems
33
33
  end
34
34
 
35
35
  def config *gems
36
- @gems = gems
36
+ @gems |= gems
37
37
  to_insert = gems.inject("") {|text, g| "#{text} config.gem '#{g}'\n"}
38
38
  file = "#{@app_name}/config/environment.rb"
39
- InsertionHelper.file_sub! file, /(config\.gem)/, "#{to_insert}\\1"
39
+ # InsertionHelper.file_sub! file, /(^.*config\.gem.*$)/, "#{to_insert}\\1"
40
+ InsertionHelper.insert_above file, "config.gem", to_insert[0..-2]
40
41
  end
41
42
 
42
43
  def unpack
@@ -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
data/lib/runner.rb CHANGED
@@ -56,8 +56,10 @@ class Runner
56
56
  db = DB.new Runner.app_name
57
57
  @base = File.expand_path "./#{Runner.app_name}"
58
58
  Dir.mkdir(@base)
59
- text = File.read(@runfile).split('\n')
60
- text.each {|l| instance_eval(l)}
59
+ # text = File.read(@runfile).split('\n')
60
+ # text.each {|l| instance_eval(l)}
61
+ text = File.read(@runfile)
62
+ instance_eval(text)
61
63
  end
62
64
 
63
65
  def sources sourcefolder
@@ -158,6 +160,12 @@ class Runner
158
160
  file @runfile, "doc/suprails.config", true
159
161
  end
160
162
 
163
+ def new_file filename, contents
164
+ File.open(File.expand_path("./#{Runner.app_name}/#{filename}"), 'w') do |f|
165
+ f.puts contents
166
+ end
167
+ end
168
+
161
169
  private
162
170
 
163
171
  def shell cmd
@@ -0,0 +1,30 @@
1
+ class YAMLHelper
2
+ def self.create_yaml(file, values)
3
+ directory = File.dirname(file)
4
+ create_directory_unless_exists(directory)
5
+ File.open(file, 'w') {|f| f << YAML::dump(values) }
6
+ end
7
+
8
+ def self.modify_yaml(file, values)
9
+ if File.exist?(file)
10
+ config = YAML::load(File.open(file))
11
+ config.merge!(values)
12
+ else
13
+ config = values
14
+ end
15
+ create_yaml(file, config)
16
+ end
17
+
18
+ protected
19
+ def self.create_directory_unless_exists(directory)
20
+ directory = File.expand_path(directory)
21
+ dir_arr = directory.split('/')
22
+ curr_dir = ""
23
+ dir_arr.each do |dir|
24
+ curr_dir << "/#{dir}"
25
+ unless File.exist?(curr_dir)
26
+ Dir.mkdir(curr_dir)
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suprails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Grzesiak
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-09 00:00:00 -06:00
12
+ date: 2008-11-24 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,8 +37,10 @@ files:
37
37
  - lib/db.rb
38
38
  - lib/facet.rb
39
39
  - lib/gems.rb
40
+ - lib/insertion_helper.rb
40
41
  - lib/runner.rb
41
42
  - lib/suprails.rb
43
+ - lib/yaml_helper.rb
42
44
  - facets/haml.rb
43
45
  - bin/suprails
44
46
  - suprails.config.example