plezi 0.12.13 → 0.12.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f12a2dfa8c950088854171c45e5dc7ee421f4ec
4
- data.tar.gz: 97a219277d93b9202c0a07a15285c3d6f1f395f6
3
+ metadata.gz: d6b0b52b7ab1f233bf4d1e35c75df9579a0f1456
4
+ data.tar.gz: 1f927d686228dd20ebec6397b3977dbb68bdcf3f
5
5
  SHA512:
6
- metadata.gz: a5a885d9cdc4aba8fd45185b585b8edafe34419cba34af216b1bb0387b041fd7e29fe1f8e35b941f979190e08e0ebb168b00f30ec489667a6b89fc362ea93cd7
7
- data.tar.gz: b952c39778f6a130b637e8175f10d1b3897a7d0da8093025744d84e8e5cbbb6cbb6441c0a774af20b20e58ea58bb9d0e98bea7e7385eba5e95c1e24d8ec70db2
6
+ metadata.gz: 54a35d6840cbfd4477e52b68552c958458f886b85204360c2e7951d76b62836737622e83c8ad915469cc0f892fa459bb99a31b5650d3d21bfd7528f997b4c273
7
+ data.tar.gz: c9e5d79dade6f7fd1416cd5d34fb189fd31dd6fd9b0fdf6f6ef2df823de5b5203c84b51bd95f733e23436667d5c3bc16b623068792e708849b32a1a090c1aa15
@@ -2,6 +2,14 @@
2
2
 
3
3
  ***
4
4
 
5
+ Change log v.0.12.14
6
+
7
+ **Update**: `Controller#redirect_to` will now attempt to guess the URL using `url_for`, unless the URL given is a String. It also leverages the new `redirect_to` Iodine::Response method, allowing you to set the FUTURE response's status_code.
8
+
9
+ **Update**: Error page rendering is now performed within a controller class called `ErrorCtrl`. This means that the error templates have acess to all the helper methods and properties of a controller, including `render`, `redirect_to`, etc'.
10
+
11
+ ***
12
+
5
13
  Change log v.0.12.13
6
14
 
7
15
  **Fix**: fixed an error in te rendering engine, where the default :format was an empty String instead of 'html'.
data/bin/plezi CHANGED
@@ -64,7 +64,7 @@ if ARGV[0] == 'new' || ARGV[0] == 'n' || ARGV[0] == "force" || ARGV[0] == 'mini'
64
64
  end
65
65
 
66
66
  # building
67
- template = Plezi::AppBuilder.new
67
+ template = Plezi::Base::AppBuilder.new
68
68
  (ARGV[0] == 'mini' || ARGV[0] == 'm' ) ? template.build_mini(ARGV[1]) : template.build(ARGV[1])
69
69
  elsif ARGV[0] == 'server' || ARGV[0] == 'start' || ARGV[0] == 's'
70
70
  ARGV.shift
@@ -29,8 +29,6 @@ require 'plezi/common/settings.rb'
29
29
  require 'plezi/common/renderer.rb'
30
30
 
31
31
  ### helpers
32
-
33
- require 'plezi/helpers/http_sender.rb'
34
32
  require 'plezi/helpers/magic_helpers.rb'
35
33
  require 'plezi/helpers/mime_types.rb'
36
34
 
@@ -45,6 +43,9 @@ require 'plezi/handlers/placebo.rb'
45
43
  require 'plezi/handlers/stubs.rb'
46
44
  require 'plezi/handlers/session.rb'
47
45
 
46
+ # error and last resort handling
47
+ require 'plezi/helpers/http_sender.rb'
48
+
48
49
  ## erb templating
49
50
  begin
50
51
  require 'erb'
@@ -0,0 +1,59 @@
1
+ require 'plezi/builders/builder'
2
+
3
+ module Plezi
4
+
5
+ module Base
6
+
7
+
8
+ module ACModelBuilder
9
+ @gem_root = ::Plezi::Builder::GEM_ROOT
10
+
11
+ # ActiveRecord::Base.connection.tables
12
+ # # Checks for existence of kittens table (Kitten model)
13
+ # ActiveRecord::Base.connection.table_exists? 'kittens'
14
+
15
+ # # Tells you all migrations run
16
+ # ActiveRecord::Migrator.get_all_versions
17
+ # # Tells you the current schema version
18
+ # ActiveRecord::Migrator.current_version
19
+
20
+ # # Check a column exists
21
+ # column_exists?(:suppliers, :name)
22
+
23
+ # # Check a column exists of a particular type
24
+ # column_exists?(:suppliers, :name, :string)
25
+
26
+ # # Check a column exists with a specific definition
27
+ # column_exists?(:suppliers, :name, :string, limit: 100)
28
+ # column_exists?(:suppliers, :name, :string, default: 'default')
29
+ # column_exists?(:suppliers, :name, :string, null: false)
30
+ # column_exists?(:suppliers, :tax, :decimal, precision: 8, scale: 2)
31
+
32
+ def self.parse_args
33
+ return unless ARGS[0][0] == 'g'
34
+ struct = {}
35
+ ARGS[1..-1].each do |s|
36
+ s = s.split /[\:\.]/
37
+ raise "Cannot parse parameters - need to be defined as name.type or name:type." if s.count !=2
38
+ struct[s[0]] = DB_TYPES[s[1].downcase] || (raise "Unrecognized type #{s[1]}.")
39
+ end
40
+ struct
41
+ end
42
+ end
43
+
44
+ # require 'sequel'
45
+
46
+ # ## Connect to the database
47
+ # DB = Sequel.sqlite('./ex1.db')
48
+
49
+ # unless DB.table_exists? :posts
50
+ # DB.create_table :posts do
51
+ # primary_key :id
52
+ # varchar :title
53
+ # text :body
54
+ # end
55
+ # end
56
+
57
+
58
+ end
59
+ end
@@ -1,132 +1,134 @@
1
1
  require 'plezi/builders/builder'
2
2
  module Plezi
3
3
 
4
+ module Base
4
5
 
5
- class AppBuilder
6
- def initialize
7
- @end_comments = []
8
- @app_tree ||= {}
9
- @root = ::Plezi::Builder::GEM_ROOT
10
- end
11
- def app_tree
12
- @app_tree ||= {}
13
- end
14
- def build_mini app_name = ARGV[1]
15
- require 'plezi/version'
16
- app_tree["#{app_name}"] ||= IO.read( File.join(@root, "resources" ,"mini_exec.rb")).gsub('appname', app_name)
17
- app_tree["#{app_name}.rb"] ||= IO.read( File.join(@root, "resources" ,"mini_app.rb")).gsub('appname', app_name).gsub('appsecret', "#{app_name}_#{SecureRandom.hex}")
18
- app_tree["Procfile"] ||= String.new
19
- app_tree["Procfile"] << "\nweb: bundle exec ruby ./#{app_name} -p $PORT\n"
20
- app_tree["Gemfile"] ||= String.new
21
- app_tree["Gemfile"] << "source 'https://rubygems.org'\n\n####################\n# core gems\n\n# include the basic plezi framework and server\ngem 'plezi', '~> #{Plezi::VERSION}'\n"
22
- app_tree["Gemfile"] << "\n\n\nruby '#{RUBY_VERSION}'\n"
23
- app_tree["templates"] ||= {}
24
- app_tree["templates"]["404.html.erb"] ||= IO.read(File.join(@root, "resources" ,"404.erb"))
25
- app_tree["templates"]["500.html.erb"] ||= IO.read(File.join(@root, "resources" ,"500.erb"))
26
- app_tree["templates"]["welcome.html.erb"] ||= IO.read(File.join(@root, "resources" ,"mini_welcome_page.html")).gsub('appname', app_name)
27
- app_tree["assets"] ||= {}
28
- app_tree["assets"]["websocket.js"] ||= IO.read(File.join(@root, "resources" ,"websockets.js")).gsub('appname', app_name)
29
- finalize app_name
30
- end
6
+ class AppBuilder
7
+ def initialize
8
+ @end_comments = []
9
+ @app_tree ||= {}
10
+ @root = ::Plezi::Base::Builder::GEM_ROOT
11
+ end
12
+ def app_tree
13
+ @app_tree ||= {}
14
+ end
15
+ def build_mini app_name = ARGV[1]
16
+ require 'plezi/version'
17
+ app_tree["#{app_name}"] ||= IO.read( File.join(@root, "resources" ,"mini_exec.rb")).gsub('appname', app_name)
18
+ app_tree["#{app_name}.rb"] ||= IO.read( File.join(@root, "resources" ,"mini_app.rb")).gsub('appname', app_name).gsub('appsecret', "#{app_name}_#{SecureRandom.hex}")
19
+ app_tree["Procfile"] ||= String.new
20
+ app_tree["Procfile"] << "\nweb: bundle exec ruby ./#{app_name} -p $PORT\n"
21
+ app_tree["Gemfile"] ||= String.new
22
+ app_tree["Gemfile"] << "source 'https://rubygems.org'\n\n####################\n# core gems\n\n# include the basic plezi framework and server\ngem 'plezi', '~> #{Plezi::VERSION}'\n"
23
+ app_tree["Gemfile"] << "\n\n\nruby '#{RUBY_VERSION}'\n"
24
+ app_tree["templates"] ||= {}
25
+ app_tree["templates"]["404.html.erb"] ||= IO.read(File.join(@root, "resources" ,"404.erb"))
26
+ app_tree["templates"]["500.html.erb"] ||= IO.read(File.join(@root, "resources" ,"500.erb"))
27
+ app_tree["templates"]["welcome.html.erb"] ||= IO.read(File.join(@root, "resources" ,"mini_welcome_page.html")).gsub('appname', app_name)
28
+ app_tree["assets"] ||= {}
29
+ app_tree["assets"]["websocket.js"] ||= IO.read(File.join(@root, "resources" ,"websockets.js")).gsub('appname', app_name)
30
+ finalize app_name
31
+ end
31
32
 
32
- def build app_name = ARGV[1]
33
- require 'plezi/version'
34
- # plezi run script
35
- app_tree["#{app_name}"] ||= IO.read File.join(@root,"resources" ,"code.rb")
33
+ def build app_name = ARGV[1]
34
+ require 'plezi/version'
35
+ # plezi run script
36
+ app_tree["#{app_name}"] ||= IO.read File.join(@root,"resources" ,"code.rb")
36
37
 
37
- # set up application files
38
- app_tree["app"] ||= {}
39
- app_tree["app"]["controllers"] ||= {}
40
- app_tree["app"]["controllers"]["sample_controller.rb"] ||= IO.read(File.join(@root,"resources" ,"controller.rb"))
41
- app_tree["app"]["models"] ||= {}
42
- app_tree["app"]["views"] ||= {}
38
+ # set up application files
39
+ app_tree["app"] ||= {}
40
+ app_tree["app"]["controllers"] ||= {}
41
+ app_tree["app"]["controllers"]["sample_controller.rb"] ||= IO.read(File.join(@root,"resources" ,"controller.rb"))
42
+ app_tree["app"]["models"] ||= {}
43
+ app_tree["app"]["views"] ||= {}
43
44
 
44
- # set up templates for status error codes
45
- app_tree["app"]["views"]["404.html"] ||= IO.read(File.join(@root,"resources" ,"404.html"))
46
- app_tree["app"]["views"]["500.html"] ||= IO.read(File.join(@root,"resources" ,"500.html"))
47
- app_tree["app"]["views"]["404.html.erb"] ||= IO.read(File.join(@root,"resources" ,"404.erb"))
48
- app_tree["app"]["views"]["500.html.erb"] ||= IO.read(File.join(@root,"resources" ,"500.erb"))
49
- app_tree["app"]["views"]["404.html.slim"] ||= IO.read(File.join(@root,"resources" ,"404.slim"))
50
- app_tree["app"]["views"]["500.html.slim"] ||= IO.read(File.join(@root,"resources" ,"500.slim"))
51
- app_tree["app"]["views"]["404.html.haml"] ||= IO.read(File.join(@root,"resources" ,"404.haml"))
52
- app_tree["app"]["views"]["500.html.haml"] ||= IO.read(File.join(@root,"resources" ,"500.haml"))
45
+ # set up templates for status error codes
46
+ app_tree["app"]["views"]["404.html"] ||= IO.read(File.join(@root,"resources" ,"404.html"))
47
+ app_tree["app"]["views"]["500.html"] ||= IO.read(File.join(@root,"resources" ,"500.html"))
48
+ app_tree["app"]["views"]["404.html.erb"] ||= IO.read(File.join(@root,"resources" ,"404.erb"))
49
+ app_tree["app"]["views"]["500.html.erb"] ||= IO.read(File.join(@root,"resources" ,"500.erb"))
50
+ app_tree["app"]["views"]["404.html.slim"] ||= IO.read(File.join(@root,"resources" ,"404.slim"))
51
+ app_tree["app"]["views"]["500.html.slim"] ||= IO.read(File.join(@root,"resources" ,"500.slim"))
52
+ app_tree["app"]["views"]["404.html.haml"] ||= IO.read(File.join(@root,"resources" ,"404.haml"))
53
+ app_tree["app"]["views"]["500.html.haml"] ||= IO.read(File.join(@root,"resources" ,"500.haml"))
53
54
 
54
- # set up the assets folder
55
- app_tree["assets"] ||= {}
56
- app_tree["assets"]["stylesheets"] ||= {}
57
- app_tree["assets"]["javascripts"] ||= {}
58
- app_tree["assets"]["javascripts"]["websocket.js"] ||= IO.read(File.join(@root,"resources" ,"websockets.js")).gsub('appname', app_name)
59
- app_tree["assets"]["welcome.html"] ||= IO.read(File.join(@root,"resources" ,"welcome_page.html")).gsub('appname', app_name)
55
+ # set up the assets folder
56
+ app_tree["assets"] ||= {}
57
+ app_tree["assets"]["stylesheets"] ||= {}
58
+ app_tree["assets"]["javascripts"] ||= {}
59
+ app_tree["assets"]["javascripts"]["websocket.js"] ||= IO.read(File.join(@root,"resources" ,"websockets.js")).gsub('appname', app_name)
60
+ app_tree["assets"]["welcome.html"] ||= IO.read(File.join(@root,"resources" ,"welcome_page.html")).gsub('appname', app_name)
60
61
 
61
- # app core files.
62
- app_tree["initialize.rb"] ||= IO.read File.join(@root,"resources" ,"initialize.rb").gsub('appname', app_name)
63
- app_tree["routes.rb"] ||= IO.read File.join(@root,"resources" ,"routes.rb")
64
- app_tree["rakefile"] ||= IO.read File.join(@root,"resources" ,"rakefile")
65
- app_tree["Procfile"] ||= ""
66
- app_tree["Procfile"] << "\nweb: bundle exec ruby ./#{app_name} -p $PORT\n"
67
- app_tree["Gemfile"] ||= ''
68
- app_tree["Gemfile"] << "source 'https://rubygems.org'\n\n####################\n# core gems\n\n# include the basic plezi framework and server\ngem 'plezi', '~> #{Plezi::VERSION}'\n"
69
- app_tree["Gemfile"] << IO.read( File.join(@root,"resources" ,"Gemfile"))
70
- app_tree["Gemfile"] << "\n\n\nruby '#{RUBY_VERSION}'\n"
62
+ # app core files.
63
+ app_tree["initialize.rb"] ||= IO.read File.join(@root,"resources" ,"initialize.rb").gsub('appname', app_name)
64
+ app_tree["routes.rb"] ||= IO.read File.join(@root,"resources" ,"routes.rb")
65
+ app_tree["rakefile"] ||= IO.read File.join(@root,"resources" ,"rakefile")
66
+ app_tree["Procfile"] ||= ""
67
+ app_tree["Procfile"] << "\nweb: bundle exec ruby ./#{app_name} -p $PORT\n"
68
+ app_tree["Gemfile"] ||= ''
69
+ app_tree["Gemfile"] << "source 'https://rubygems.org'\n\n####################\n# core gems\n\n# include the basic plezi framework and server\ngem 'plezi', '~> #{Plezi::VERSION}'\n"
70
+ app_tree["Gemfile"] << IO.read( File.join(@root,"resources" ,"Gemfile"))
71
+ app_tree["Gemfile"] << "\n\n\nruby '#{RUBY_VERSION}'\n"
71
72
 
72
- # set up config files
73
- app_tree["initialize"] ||= {}
74
- app_tree["initialize"]["oauth.rb"] ||= IO.read(File.join(@root,"resources" ,"oauth_config.rb"))
75
- app_tree["initialize"]["active_record.rb"] ||= IO.read(File.join(@root,"resources" ,"db_ac_config.rb"))
76
- app_tree["initialize"]["sequel.rb"] ||= IO.read(File.join(@root,"resources" ,"db_sequel_config.rb"))
77
- app_tree["initialize"]["datamapper.rb"] ||= IO.read(File.join(@root,"resources" ,"db_dm_config.rb"))
78
- app_tree["initialize"]["haml.rb"] ||= IO.read(File.join(@root,"resources" ,"haml_config.rb"))
79
- app_tree["initialize"]["slim.rb"] ||= IO.read(File.join(@root,"resources" ,"slim_config.rb"))
80
- app_tree["initialize"]["i18n.rb"] ||= IO.read(File.join(@root,"resources" ,"i18n_config.rb"))
81
- app_tree["initialize"]["redis.rb"] ||= (IO.read(File.join(@root,"resources" ,"redis_config.rb"))).gsub('appsecret', "#{app_name}_#{SecureRandom.hex}")
73
+ # set up config files
74
+ app_tree["initialize"] ||= {}
75
+ app_tree["initialize"]["oauth.rb"] ||= IO.read(File.join(@root,"resources" ,"oauth_config.rb"))
76
+ app_tree["initialize"]["active_record.rb"] ||= IO.read(File.join(@root,"resources" ,"db_ac_config.rb"))
77
+ app_tree["initialize"]["sequel.rb"] ||= IO.read(File.join(@root,"resources" ,"db_sequel_config.rb"))
78
+ app_tree["initialize"]["datamapper.rb"] ||= IO.read(File.join(@root,"resources" ,"db_dm_config.rb"))
79
+ app_tree["initialize"]["haml.rb"] ||= IO.read(File.join(@root,"resources" ,"haml_config.rb"))
80
+ app_tree["initialize"]["slim.rb"] ||= IO.read(File.join(@root,"resources" ,"slim_config.rb"))
81
+ app_tree["initialize"]["i18n.rb"] ||= IO.read(File.join(@root,"resources" ,"i18n_config.rb"))
82
+ app_tree["initialize"]["redis.rb"] ||= (IO.read(File.join(@root,"resources" ,"redis_config.rb"))).gsub('appsecret', "#{app_name}_#{SecureRandom.hex}")
82
83
 
83
- #set up database stub folders
84
- app_tree["db"] ||= {}
85
- app_tree["db"]["migrate"] ||= {}
86
- app_tree["db"]["fixtures"] ||= {}
87
- app_tree["db"]["config.yml"] ||= IO.read(File.join(@root,"resources" ,"database.yml"))
84
+ #set up database stub folders
85
+ app_tree["db"] ||= {}
86
+ app_tree["db"]["migrate"] ||= {}
87
+ app_tree["db"]["fixtures"] ||= {}
88
+ app_tree["db"]["config.yml"] ||= IO.read(File.join(@root,"resources" ,"database.yml"))
88
89
 
89
- #set up the extras folder, to be filled with future goodies.
90
- # app_tree["extras"] ||= {}
91
- # app_tree["extras"]["config.ru"] ||= IO.read File.join(@root,"resources" ,"config.ru")
90
+ #set up the extras folder, to be filled with future goodies.
91
+ # app_tree["extras"] ||= {}
92
+ # app_tree["extras"]["config.ru"] ||= IO.read File.join(@root,"resources" ,"config.ru")
92
93
 
93
- #set up I18n stub
94
- app_tree["locales"] ||= {}
95
- app_tree["locales"]["en.yml"] ||= IO.read File.join(@root,"resources" ,"en.yml")
94
+ #set up I18n stub
95
+ app_tree["locales"] ||= {}
96
+ app_tree["locales"]["en.yml"] ||= IO.read File.join(@root,"resources" ,"en.yml")
96
97
 
97
- # create library, log and tmp folders
98
- app_tree["logs"] ||= {}
99
- app_tree["lib"] ||= {}
100
- app_tree["tmp"] ||= {}
98
+ # create library, log and tmp folders
99
+ app_tree["logs"] ||= {}
100
+ app_tree["lib"] ||= {}
101
+ app_tree["tmp"] ||= {}
101
102
 
102
103
 
103
- # set up a public folder for static file service
104
- app_tree["public"] ||= {}
105
- app_tree["public"]["assets"] ||= {}
106
- app_tree["public"]["assets"]["stylesheets"] ||= {}
107
- app_tree["public"]["assets"]["javascripts"] ||= {}
108
- app_tree["public"]["images"] ||= {}
109
- finalize app_name
110
- end
111
- def finalize app_name = ARGV[1]
112
- begin
113
- Dir.mkdir app_name
114
- puts "created the #{app_name} application directory.".green
115
- rescue Exception => e
116
- puts "the #{app_name} application directory exists - trying to rebuild (no overwrite).".pink
104
+ # set up a public folder for static file service
105
+ app_tree["public"] ||= {}
106
+ app_tree["public"]["assets"] ||= {}
107
+ app_tree["public"]["assets"]["stylesheets"] ||= {}
108
+ app_tree["public"]["assets"]["javascripts"] ||= {}
109
+ app_tree["public"]["images"] ||= {}
110
+ finalize app_name
111
+ end
112
+ def finalize app_name = ARGV[1]
113
+ begin
114
+ Dir.mkdir app_name
115
+ puts "created the #{app_name} application directory.".green
116
+ rescue => e
117
+ puts "the #{app_name} application directory exists - trying to rebuild (no overwrite).".pink
118
+ end
119
+ Dir.chdir app_name
120
+ puts "starting to write template data...".red
121
+ puts ""
122
+ Builder.write_files app_tree
123
+ File.chmod 0775, "#{app_name}" rescue true
124
+ puts "done."
125
+ puts "\n#{@end_comments.join("\n")}" unless @end_comments.empty?
126
+ puts ""
127
+ puts "please change directory into the app directory: cd #{app_name}"
128
+ puts ""
129
+ puts "run the #{app_name} app using: ./#{app_name} or using: plezi s"
130
+ puts ""
117
131
  end
118
- Dir.chdir app_name
119
- puts "starting to write template data...".red
120
- puts ""
121
- Builder.write_files app_tree
122
- File.chmod 0775, "#{app_name}" rescue true
123
- puts "done."
124
- puts "\n#{@end_comments.join("\n")}" unless @end_comments.empty?
125
- puts ""
126
- puts "please change directory into the app directory: cd #{app_name}"
127
- puts ""
128
- puts "run the #{app_name} app using: ./#{app_name} or using: plezi s"
129
- puts ""
130
132
  end
131
133
  end
132
134
  end
@@ -1,36 +1,38 @@
1
1
  module Plezi
2
- module Builder
2
+ module Base
3
+ module Builder
3
4
 
4
- GEM_ROOT = ::File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
5
+ GEM_ROOT = ::File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
5
6
 
6
- def self.write_files files, parent = "."
7
- if files.is_a? Hash
8
- files.each do |k, v|
9
- if v.is_a? Hash
10
- begin
11
- Dir.mkdir k
12
- puts " created #{parent}/#{k}".green
13
- rescue Exception => e
14
- puts " exists #{parent}/#{k}".red
15
- end
16
- Dir.chdir k
17
- write_files v, (parent + "/" + k)
18
- Dir.chdir ".."
19
- elsif v.is_a? String
20
- if ::File.exists? k
21
- if false #%w{Gemfile rakefile.rb}.include? k
22
- # old = IO.read k
23
- # old = (old.lines.map {|l| "\##{l}"}).join
24
- # IO.write k, "#####################\n#\n# OLD DATA COMMENTED OUT - PLEASE REVIEW\n#\n##{old}\n#{v}"
25
- # puts " #{parent}/#{k} WAS OVERWRITTEN, old data was preserved by comenting it out.".pink
26
- # puts " #{parent}/#{k} PLEASE REVIEW.".pink
27
- # @end_comments << "#{parent}/#{k} WAS OVERWRITTEN, old data was preserved by comenting it out. PLEASE REVIEW."
7
+ def self.write_files files, parent = "."
8
+ if files.is_a? Hash
9
+ files.each do |k, v|
10
+ if v.is_a? Hash
11
+ begin
12
+ Dir.mkdir k
13
+ puts " created #{parent}/#{k}".green
14
+ rescue => e
15
+ puts " exists #{parent}/#{k}".red
16
+ end
17
+ Dir.chdir k
18
+ write_files v, (parent + "/" + k)
19
+ Dir.chdir ".."
20
+ elsif v.is_a? String
21
+ if ::File.exists? k
22
+ if false #%w{Gemfile rakefile.rb}.include? k
23
+ # old = IO.read k
24
+ # old = (old.lines.map {|l| "\##{l}"}).join
25
+ # IO.write k, "#####################\n#\n# OLD DATA COMMENTED OUT - PLEASE REVIEW\n#\n##{old}\n#{v}"
26
+ # puts " #{parent}/#{k} WAS OVERWRITTEN, old data was preserved by comenting it out.".pink
27
+ # puts " #{parent}/#{k} PLEASE REVIEW.".pink
28
+ # @end_comments << "#{parent}/#{k} WAS OVERWRITTEN, old data was preserved by comenting it out. PLEASE REVIEW."
29
+ else
30
+ puts " EXISTS(!) #{parent}/#{k}".red
31
+ end
28
32
  else
29
- puts " EXISTS(!) #{parent}/#{k}".red
33
+ IO.write k, v
34
+ puts " wrote #{parent}/#{k}".yellow
30
35
  end
31
- else
32
- IO.write k, v
33
- puts " wrote #{parent}/#{k}".yellow
34
36
  end
35
37
  end
36
38
  end
@@ -2,23 +2,26 @@ require 'plezi/builders/builder'
2
2
 
3
3
  module Plezi
4
4
 
5
- module FormBuilder
5
+ module Base
6
6
 
7
- FORM_BUILDERS = %w{ Slim ERB }
8
- MODEL_BUILDERS = %w{ Squel }
7
+ module FormBuilder
9
8
 
10
- DB_TYPES = %w{primary_key string text integer float decimal datetime time date binary boolean}
9
+ FORM_BUILDERS = %w{ Slim ERB }
10
+ MODEL_BUILDERS = %w{ Squel }
11
11
 
12
- @gem_root = ::Plezi::Builder::GEM_ROOT
13
- def self.parse_args
14
- return unless ARGS[0][0] == 'g'
15
- struct = {}
16
- ARGS[1..-1].each do |s|
17
- s = s.split /[\:\.]/
18
- raise "Cannot parse parameters - need to be defined as name.type or name:type." if s.count !=2
19
- struct[s[0]] = DB_TYPES[s[1].downcase] || (raise "Unrecognized type #{s[1]}.")
12
+ DB_TYPES = %w{primary_key string text integer float decimal datetime time date binary boolean}
13
+
14
+ @gem_root = ::Plezi::Builder::GEM_ROOT
15
+ def self.parse_args
16
+ return unless ARGS[0][0] == 'g'
17
+ struct = {}
18
+ ARGS[1..-1].each do |s|
19
+ s = s.split /[\:\.]/
20
+ raise "Cannot parse parameters - need to be defined as name.type or name:type." if s.count !=2
21
+ struct[s[0]] = DB_TYPES[s[1].downcase] || (raise "Unrecognized type #{s[1]}.")
22
+ end
23
+ struct
20
24
  end
21
- struct
22
25
  end
23
26
  end
24
27
  end