sinatra-chassis 1.0.1 → 1.0.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dee18d111fd9c81d315b44e6fc176c6410bb65f
4
+ data.tar.gz: 4ef2b7f3b4bd25c912278b997946224481815c99
5
+ SHA512:
6
+ metadata.gz: 05fd9b565adfa76bd0a9286313c6602b30b8063cc0634fec5882fc839477392d0b62449932c0cfc225d310bf578c081167f29a64609b46ee919cc50077ff8c8e
7
+ data.tar.gz: 9f8e6cecca2519a2f4e5af8b6258c6d2e8cd122600cc534876f7e36743c59c132816802fe5e70e0fbbe49a7fa2e52dd0166c9c649cc3756db3e9dedaec764832
data/bin/chassis CHANGED
@@ -11,27 +11,27 @@ switches = {
11
11
  }
12
12
 
13
13
  # Internal: Parses command options and runs associated methods.
14
- #
14
+ #
15
15
  # Example
16
16
  # ~: chassis -g -h ~/Projects/my_new_app
17
- #
17
+ #
18
18
  # Each command is self documenting.
19
19
  options = OptionParser.new do |opt|
20
20
  opt.banner = 'Options:'
21
-
21
+
22
22
  opt.on('-g', '--git', 'Init a git repo, add the first commit') { switches[:git] = true }
23
-
23
+
24
24
  opt.on('-h', '--heroku', 'Create a Heroku app') { switches[:heroku] = true }
25
-
25
+
26
26
  opt.on('--skip-bundle', 'Don\'t run bundle install') { switches[:bundler] = false }
27
-
27
+
28
28
  opt.parse!
29
29
  end
30
30
 
31
31
  # If app name is given, create application.
32
32
  if ARGV[0]
33
33
  app = ARGV[0]
34
-
34
+
35
35
  unless File.exists? app
36
36
  puts " Creating #{app}:"
37
37
  puts LABELS[:add] + app
@@ -40,27 +40,27 @@ if ARGV[0]
40
40
  puts "#{app} already exists."
41
41
  exit
42
42
  end
43
-
43
+
44
44
  copy_directory "#{TEMPLATES}/chassis", app
45
-
45
+
46
46
  if switches[:bundler]
47
47
  puts LABELS[:run] + 'bundle'
48
48
  system "cd #{app} && bundle install"
49
49
  end
50
-
50
+
51
51
  puts LABELS[:run] + 'chmod -r 0755'
52
52
  FileUtils.chmod_R 0755, app
53
-
53
+
54
54
  if switches[:git]
55
55
  puts LABELS[:run] + 'git'
56
56
  system "cd #{app} && git init && git add . && git commit -m 'First!'"
57
57
  end
58
-
58
+
59
59
  if switches[:heroku]
60
60
  puts LABELS[:run] + 'heroku'
61
61
  system "cd #{app} && heroku create && git push heroku master"
62
62
  end
63
-
63
+
64
64
  puts "\n Next steps:\n cd #{app}\n ruby app.rb\n\n"
65
65
  exit
66
66
  end
@@ -1,19 +1,19 @@
1
1
  require 'sinatra/base'
2
2
 
3
3
  module Sinatra
4
-
4
+
5
5
  # Public: Helpers used in the Chassis module.
6
6
  # Can be overriden from an app.
7
7
  module ChassisHelpers
8
-
8
+
9
9
  # Public: Compares the request user agent against
10
10
  # the mobile_user_agents setting Array items (should contain regexes).
11
- #
11
+ #
12
12
  # Example
13
- #
13
+ #
14
14
  # mobile_request?
15
15
  # # => true
16
- #
16
+ #
17
17
  # Returns true/false.
18
18
  def mobile_request?
19
19
  settings.mobile_user_agents.any? { |agent| request.env['HTTP_USER_AGENT'] =~ agent }
@@ -21,14 +21,14 @@ module Sinatra
21
21
 
22
22
  # Public: Checks to see if a view template exists.
23
23
  # It will check through all registered view directories.
24
- #
24
+ #
25
25
  # template - String of view template filename to look for
26
- #
26
+ #
27
27
  # Example
28
- #
28
+ #
29
29
  # view_template('show.haml')
30
30
  # # => true
31
- #
31
+ #
32
32
  # Returns true/false.
33
33
  def view_exists? template
34
34
  Array(settings.views).each { |v| return true if File.exists?("#{v}/#{template}") }
@@ -38,13 +38,14 @@ module Sinatra
38
38
  # Public: Prepends the Sinatra find_template method to
39
39
  # find .mobile templates if the mobile_views setting is true
40
40
  # the request is from a mobile device.
41
- #
41
+ #
42
42
  # Example
43
- #
43
+ #
44
44
  # erb :my_view
45
- #
45
+ #
46
46
  # Renders the my_view.mobile.erb instead of my_view.erb.
47
47
  def find_template views, name, engine, &block
48
+ enable :reload_templates if settings.mobile_views
48
49
  name = "#{name}.mobile" if
49
50
  (settings.mobile_views) &&
50
51
  (mobile_request?) &&
@@ -53,17 +54,17 @@ module Sinatra
53
54
  end
54
55
 
55
56
  end
56
-
57
+
57
58
  module Chassis
58
59
 
59
60
  # Public: Requires all .rb files in a given directory or directories.
60
- #
61
+ #
61
62
  # *args - String(s) or Array of String paths to require
62
- #
63
+ #
63
64
  # Exmaple
64
- #
65
+ #
65
66
  # require_directory('routes', 'models')
66
- #
67
+ #
67
68
  # Returns nothing.
68
69
  def require_directory *args
69
70
  args = args.first if args.first.kind_of? Array
@@ -74,37 +75,30 @@ module Sinatra
74
75
 
75
76
  # Public: Additions to the Sinatra app.
76
77
  def self.registered(app)
77
-
78
- # Public: Defines the default load path to be used with require_directory.
79
- #
80
- # Example
81
- #
82
- # require_directory(settings.load_path)
83
- app.set :load_path, ['config', 'settings', 'helpers', 'libraries', 'models', 'controllers', 'routes']
84
-
78
+
85
79
  # Public: Defines the default mobile user agents.
86
80
  app.set :mobile_user_agents, [/iPhone/, /Android.*AppleWebKit/]
87
81
 
88
82
  # Public: Turns on .mobile view templates.
89
- app.enable :mobile_views
83
+ app.disable :mobile_views
90
84
 
91
85
  # Public: Determines where to load assets from.
92
86
  app.set :assets_path, ['public']
93
87
 
94
88
  # Public: Compiles .scss file to .css on request.
95
- #
89
+ #
96
90
  # Example
97
- #
91
+ #
98
92
  # <link rel="stylesheet" type="text/css" href="theme.css">
99
- #
93
+ #
100
94
  # Returns the compiled theme.scss, if it exists.
101
95
  # Note that requests to public files bypass this handler.
102
96
  app.get '*.css/?' do
103
97
  file = params[:splat].first
104
-
98
+
105
99
  found = false
106
100
  type = nil
107
-
101
+
108
102
  settings.assets_path.each do |path|
109
103
  file.sub!("#{path}/", '') unless path == 'public'
110
104
  if File.exists?("./#{path}#{file}.css")
@@ -128,23 +122,23 @@ module Sinatra
128
122
  end
129
123
  else
130
124
  pass
131
- end
125
+ end
132
126
  end
133
-
127
+
134
128
  # Public: Compiles .coffee file to .js on request.
135
- #
129
+ #
136
130
  # Example
137
- #
131
+ #
138
132
  # <script type="text/javascript" src"script.js"></script>
139
- #
133
+ #
140
134
  # Returns the compiled script.coffee, if it exists.
141
135
  # Note that requests to public files bypass this handler.
142
136
  app.get '*.js/?' do
143
137
  file = params[:splat].first
144
-
138
+
145
139
  found = false
146
140
  type = nil
147
-
141
+
148
142
  settings.assets_path.each do |path|
149
143
  file.sub!("#{path}/", '') unless path == 'public'
150
144
  if File.exists?("./#{path}#{file}.js")
@@ -168,22 +162,22 @@ module Sinatra
168
162
  end
169
163
  else
170
164
  pass
171
- end
165
+ end
172
166
  end
173
-
167
+
174
168
  # Public: Adds the internal Chassis views directory to the app.
175
169
  # Used for finding the built in error template.
176
170
  app.set :views, ['views', File.dirname(__FILE__) + '/views']
177
-
171
+
178
172
  # Public: Turns on the catch all route in a not_found request.
179
173
  app.enable :catch_all_route
180
-
174
+
181
175
  # Public: Handles 404s.
182
- #
176
+ #
183
177
  # If there is no matching route handler, this will return a view template
184
178
  # by matching the request path to a /views directory path and file. If
185
179
  # no template is found, a 404 is called.
186
- #
180
+ #
187
181
  # In production, the 404 will render the production error template.
188
182
  not_found do
189
183
  if settings.catch_all_route?
@@ -16,13 +16,13 @@ LABELS = {
16
16
  TEMPLATES = "#{File.dirname(__FILE__)}/../templates"
17
17
 
18
18
  # Public: Asks the user if a file should be overwritten.
19
- #
19
+ #
20
20
  # file - Sting path of file in question
21
- #
21
+ #
22
22
  # Example
23
- #
23
+ #
24
24
  # overwritable? 'path/to/my/file.rb'
25
- #
25
+ #
26
26
  # Returns true or false based on user selection.
27
27
  def overwritable? path
28
28
  puts "#{path} already exists. Replace? (yes or no)"
@@ -32,18 +32,18 @@ def overwritable? path
32
32
  end
33
33
 
34
34
  # Public: Adds to the end of a file.
35
- #
35
+ #
36
36
  # file - String path of file to add to
37
37
  # text - text to add
38
- #
38
+ #
39
39
  # Example
40
- #
40
+ #
41
41
  # appent_to_file 'path/to/file.rb', 'Hello, world!'
42
- #
42
+ #
43
43
  # Returns nothing.
44
- #
44
+ #
45
45
  # Todo
46
- #
46
+ #
47
47
  # - Return true/false based on success.
48
48
  def append_to_file file, text
49
49
  File.open(file, 'a') {|f| f.write(text) }
@@ -51,14 +51,14 @@ end
51
51
 
52
52
  # Public: Copies a file from one location to another.
53
53
  # Asks the user of existing files should be overwritten.
54
- #
54
+ #
55
55
  # orignal_file - String path of the file to be copied
56
56
  # new_file - Destination of the copied file
57
- #
57
+ #
58
58
  # Example
59
- #
59
+ #
60
60
  # copy_file 'path/to/original_file.rb', 'path/to/new/location.rb'
61
- #
61
+ #
62
62
  # Returns true if the file was copied, false if not.
63
63
  def copy_file original_file, new_file
64
64
  unless File.exists? new_file
@@ -78,17 +78,17 @@ def copy_file original_file, new_file
78
78
  end
79
79
 
80
80
  # Public: Copies a file using ERB to insert variables.
81
- #
81
+ #
82
82
  # template_file - String path of the template to be copied
83
83
  # new_file - String path of the file to create from the template_file
84
84
  # locals - Hash of variables to pass to the temlate_file
85
- #
85
+ #
86
86
  # Example
87
- #
87
+ #
88
88
  # copy_template "#{TEMPLATES}/path/to/template.rb",
89
89
  # 'path/to/new/file.rb',
90
90
  # { foo: 'bar' }
91
- #
91
+ #
92
92
  # Returns true if the template was copied, false if not.
93
93
  def copy_template template_file, new_file, locals = {}
94
94
  unless File.exists? new_file
@@ -108,19 +108,19 @@ def copy_template template_file, new_file, locals = {}
108
108
  end
109
109
 
110
110
  # Public: Creates a directory if it doesn't already exist.
111
- #
111
+ #
112
112
  # *args - path(s) as a String, multiple Strings, or an Array of Strings
113
- #
113
+ #
114
114
  # Examples
115
- #
115
+ #
116
116
  # create_directory 'path/to/directory'
117
117
  # create_directory 'path/to/directory', 'path/to/other/directory
118
118
  # create_directory ['path/to/directory', 'path/to/other/directory']
119
- #
119
+ #
120
120
  # Returns nothing.
121
- #
121
+ #
122
122
  # Todo
123
- #
123
+ #
124
124
  # - Return true/false based on success.
125
125
  def create_directory *args
126
126
  args = args.first if args.first.kind_of? Array
@@ -129,18 +129,18 @@ end
129
129
 
130
130
  # Public: Copies a directory (with contents) to another directory.
131
131
  # If the new directory doesn't exist, it will be created.
132
- #
132
+ #
133
133
  # original_dir - String path of the directory to be copied from
134
134
  # new_dir - String path of directory to be copied to
135
- #
135
+ #
136
136
  # Example
137
- #
137
+ #
138
138
  # copy_directory 'path/to/original/directory', 'path/to/new/directory'
139
- #
139
+ #
140
140
  # Returns nothing.
141
- #
141
+ #
142
142
  # Todo
143
- #
143
+ #
144
144
  # - Return true/false based on success.
145
145
  def copy_directory original_dir, new_dir
146
146
  create_directory new_dir
@@ -3,25 +3,27 @@ require 'rack-flash'
3
3
 
4
4
  # Public: Adds helpers
5
5
  module Sinatra
6
-
6
+
7
7
  module ChassisExtraHelpers
8
8
  # Public: Checks if the argument can be evaluated numerically.
9
- #
9
+ #
10
10
  # Example
11
- #
12
- # is_numeric?('1')
11
+ #
12
+ # numeric?('1')
13
13
  # # => true
14
- #
15
- # is_numeric?('hello')
14
+ #
15
+ # numeric?('hello')
16
16
  # # => false
17
- #
17
+ #
18
18
  # Returns true/false.
19
19
  def numeric? x
20
20
  true if Float(x) rescue false
21
21
  end
22
+
23
+ # define_method(:numeric?) { true if Float(x) rescue false }
22
24
 
23
25
  # Public: Truncates a String or Number.
24
- #
26
+ #
25
27
  # x - String or Number to truncate
26
28
  # word_count - Integer number of words to return if x is a String (default: 100)
27
29
  # end_string - String appended to the end of the returned String if
@@ -29,19 +31,19 @@ module Sinatra
29
31
  # decimal - Integer number of maximum places after decimal if x is a Number (default: 1)
30
32
  # trailing_zeros - Boolean to decide if a returned Number should keep the
31
33
  # trailing 0's as a String (default: false)
32
- #
34
+ #
33
35
  # Examples
34
- #
36
+ #
35
37
  # truncate('Lorem ipsum dolor sit amet.', word_count: 3, end_string: '...')
36
38
  # # => 'Lorem ipsum dolor...'
37
- #
39
+ #
38
40
  # truncate(1.234000, decimal: 1)
39
41
  # # => 1.2
40
42
  # truncate(1.234000, decimal: 5)
41
43
  # # => 1.234
42
44
  # truncate(1.234000, decimal: 5, trailing_zeros: true)
43
45
  # # => '1.23400'
44
- #
46
+ #
45
47
  # Returns a String or Float.
46
48
  def truncate x, options = {}
47
49
  options[:word_count] ||= 100
@@ -59,33 +61,33 @@ module Sinatra
59
61
  return number
60
62
  end
61
63
  end
62
-
64
+
63
65
  # Public: Uppercases the first letter of each word.
64
- #
66
+ #
65
67
  # Example
66
- #
68
+ #
67
69
  # titleize('hello world')
68
70
  # # => 'Hello World'
69
- #
71
+ #
70
72
  # Returns a String.
71
73
  def titleize x
72
74
  title = ''
73
75
  x.to_s.split(' ').each { |s| title << s.capitalize + ' ' }
74
76
  title
75
77
  end
76
-
78
+
77
79
  # Public: Compares a string to the request path.
78
- #
80
+ #
79
81
  # path - String to compare against the request path
80
- #
82
+ #
81
83
  # Exmaple
82
- #
84
+ #
83
85
  # Requested URL: http://localhost:4567/hello/world
84
86
  # active('hello')
85
87
  # # => 'active'
86
88
  # active('goodbye')
87
89
  # # => ''
88
- #
90
+ #
89
91
  # Returns a Sting: 'active' if there's a match, '' if not.
90
92
  def active path
91
93
  path = Array[path] unless path.kind_of? Array
@@ -97,10 +99,10 @@ module Sinatra
97
99
  # Public: Displays an alert unless flash[:alert] if nil.
98
100
  # flash[:alert] empties itself after the first request after it's set.
99
101
  # To use, set flash[:alert] to a String.
100
- #
102
+ #
101
103
  # Example
102
104
  # <%= alert %>
103
- #
105
+ #
104
106
  # Returns a div with an id of 'alert' and containing the contents
105
107
  # of flash[:alert], or if flash[:alert] if nil, returns nothing.
106
108
  def alert
@@ -109,20 +111,20 @@ module Sinatra
109
111
 
110
112
  # Public: Hides an HTML element.
111
113
  # Useful in combination with inline true/false comparators.
112
- #
114
+ #
113
115
  # Example
114
- #
116
+ #
115
117
  # <div style="<%= hidden unless session[:user] %>">Hello, world!</div>
116
- #
118
+ #
117
119
  # Returns a String of CSS.
118
120
  def hidden
119
121
  'display: none;'
120
122
  end
121
-
123
+
122
124
  # Public: Converts a Date to select form fields.
123
125
  # All generated fields have classes of month_select, day_select, or year_select.
124
126
  # None of the options are required, but they are all recommended.
125
- #
127
+ #
126
128
  # select_name - name attr for fields, appended with '_day', '_month', or '_year'
127
129
  # select_id - id attr for fields, appended with '_day', '_month', or '_year'
128
130
  # select_class - class attr for fields, appended with '_day', '_month', or '_year'
@@ -130,9 +132,9 @@ module Sinatra
130
132
  # end_year - last year to use in year select (default: 3 years from now)
131
133
  # day_first - Boolean to show the day before the month (default: false)
132
134
  # month_name - Boolean to display month names (default: false)
133
- #
135
+ #
134
136
  # Example
135
- #
137
+ #
136
138
  # date_select(
137
139
  # DateTime.now
138
140
  # select_class: 'your_class',
@@ -143,13 +145,13 @@ module Sinatra
143
145
  # day_first: true,
144
146
  # month_name: false
145
147
  # )
146
- #
148
+ #
147
149
  # Returns select fields as a String.
148
150
  def date_select date, options = {}
149
151
  options[:select_name] ||= ''
150
152
  options[:select_id] ||= ''
151
153
  options[:select_class] ||= ''
152
-
154
+
153
155
  unless options[:select_id] == ''
154
156
  day_id = " id='#{options[:select_id]}_day'"
155
157
  month_id = " id='#{options[:select_id]}_month'"
@@ -159,7 +161,7 @@ module Sinatra
159
161
  month_id = ''
160
162
  year_id = ''
161
163
  end
162
-
164
+
163
165
  unless options[:select_name] == ''
164
166
  day_name = " name='#{options[:select_name]}_day'"
165
167
  month_name = " name='#{options[:select_name]}_month'"
@@ -169,15 +171,15 @@ module Sinatra
169
171
  month_name = ''
170
172
  year_name = ''
171
173
  end
172
-
174
+
173
175
  options[:day_first] ||= false
174
176
  options[:start_year] ||= Time.now.strftime('%Y').to_i - 3
175
177
  options[:end_year] ||= Time.now.strftime('%Y').to_i + 3
176
178
  options[:month_name] ||= false
177
-
179
+
178
180
  options[:start_year] = date.strftime('%Y').to_i if date.strftime('%Y').to_i < options[:start_year]
179
181
  options[:end_year] = date.strftime('%Y').to_i if date.strftime('%Y').to_i > options[:end_year]
180
-
182
+
181
183
  months = [
182
184
  { num: '01', name: 'January' },
183
185
  { num: '02', name: 'February' },
@@ -192,37 +194,37 @@ module Sinatra
192
194
  { num: '11', name: 'November' },
193
195
  { num: '12', name: 'December' }
194
196
  ]
195
-
197
+
196
198
  day = "<select class='day_select #{options[:select_class]}'#{day_id}#{day_name}'>"
197
199
  (1..31).each do |d|
198
200
  day << "<option value='#{d}' #{'selected' if d == date.strftime('%d').to_i}>#{d}</option>"
199
201
  end
200
202
  day << "</select>"
201
-
203
+
202
204
  month = "<select class='month_select #{options[:select_class]}'#{month_id}#{month_name}>"
203
205
  months.each do |m|
204
206
  options[:month_name] ? d = m[:name] : d = m[:num]
205
207
  month << "<option value='#{m[:num]}' #{'selected' if m[:num] == date.strftime('%m').to_i}>#{d}</option>"
206
208
  end
207
209
  month << "</select>"
208
-
210
+
209
211
  year = "<select class='year_select #{options[:select_class]}'#{year_id}#{year_name}>"
210
212
  (options[:start_year]..options[:end_year]).each do |y|
211
213
  year << "<option value='#{y}' #{'selected' if y == date.strftime('%Y').to_i}>#{y}</option>"
212
214
  end
213
215
  year << "</select>"
214
-
216
+
215
217
  if options[:day_first]
216
218
  return "#{day} #{month} #{year}"
217
219
  else
218
220
  return "#{month} #{day} #{year}"
219
221
  end
220
222
  end
221
-
223
+
222
224
  end
223
-
225
+
224
226
  module ChassisExtras
225
-
227
+
226
228
  # Adds Rack::Flash to the app (requires sessions)
227
229
  def self.registered(app)
228
230
  app.enable :sessions
@@ -231,7 +233,7 @@ module Sinatra
231
233
  end
232
234
 
233
235
  end
234
-
236
+
235
237
  helpers ChassisExtraHelpers
236
238
  register ChassisExtras
237
239
  end
@@ -23,7 +23,7 @@ namespace :assets do
23
23
  end
24
24
  end
25
25
  end
26
-
26
+
27
27
  desc 'Remove compiled assets'
28
28
  task :decompile do
29
29
  settings.assets_path.each do |path|
@@ -36,5 +36,5 @@ namespace :assets do
36
36
  File.delete(asset.gsub('.scss', '.css')) if File.exists?(asset.gsub('.scss', '.css'))
37
37
  end
38
38
  end
39
-
39
+
40
40
  end
@@ -1,14 +1,14 @@
1
1
  namespace :chassis do
2
-
2
+
3
3
  desc 'Run app in an IRB session'
4
4
  task :irb do
5
- require 'irb'
6
- ARGV.clear
7
- IRB.start
5
+ require 'irb'
6
+ ARGV.clear
7
+ IRB.start
8
8
  end
9
9
 
10
10
  namespace :run do
11
-
11
+
12
12
  desc 'Run one or all /tests scripts'
13
13
  task :test, :file do |t, args|
14
14
  if args.file == nil
@@ -17,7 +17,7 @@ namespace :chassis do
17
17
  require "./tests/#{args.file}"
18
18
  end
19
19
  end
20
-
20
+
21
21
  end
22
-
22
+
23
23
  end
@@ -1,5 +1,5 @@
1
1
  namespace :setup do
2
-
2
+
3
3
  desc 'Set up DataMapper'
4
4
  task :datamapper do
5
5
  create_directory './settings'
@@ -15,7 +15,7 @@ namespace :setup do
15
15
  end
16
16
 
17
17
  namespace :dm do
18
-
18
+
19
19
  def create_dm_path
20
20
  if DataMapper.repository.adapter.options[:path].include? 'sqlite'
21
21
  db = DataMapper.repository.adapter.options[:path].split('/').last
@@ -24,7 +24,7 @@ namespace :dm do
24
24
  end
25
25
 
26
26
  namespace :add do
27
-
27
+
28
28
  desc 'Add a data migration' if defined? DataMapper
29
29
  task :migration, :name do |t, args|
30
30
  if args.name == nil
@@ -68,21 +68,21 @@ namespace :dm do
68
68
  end
69
69
 
70
70
  end
71
-
71
+
72
72
  desc 'Auto upgrade one or all models' if defined? DataMapper
73
- task :upgrade, :model do |t, args|
73
+ task :upgrade, :model do |t, args|
74
74
  create_dm_path
75
75
  args.model == nil ? DataMapper.auto_upgrade! : args.model.constantize.auto_upgrade!
76
- end
76
+ end
77
77
 
78
- desc 'Auto migrate one or all models' if defined? DataMapper
79
- task :migrate, :model do |t, args|
78
+ desc 'Auto migrate one or all models' if defined? DataMapper
79
+ task :migrate, :model do |t, args|
80
80
  create_dm_path
81
81
  args.model == nil ? DataMapper.auto_migrate! : args.model.constantize.auto_migrate!
82
- end
83
-
82
+ end
83
+
84
84
  namespace :migrate do
85
-
85
+
86
86
  desc 'Migrate up to a specific migration number' if defined? DataMapper
87
87
  task :up, :number do |t, args|
88
88
  create_dm_path
@@ -90,7 +90,7 @@ namespace :dm do
90
90
  Dir['./data/migrations/*.rb'].each { |m| require m }
91
91
  args.number == nil ? migrate_up! : migrate_up!(args.number)
92
92
  end
93
-
93
+
94
94
  desc 'Migrate down to a specific migration number' if defined? DataMapper
95
95
  task :down, :number do |t, args|
96
96
  create_dm_path
@@ -98,11 +98,11 @@ namespace :dm do
98
98
  Dir['./data/migrations/*.rb'].each { |m| require m }
99
99
  args.number == nil ? migrate_down! : migrate_down!(args.number)
100
100
  end
101
-
101
+
102
102
  end
103
103
 
104
104
  namespace :run do
105
-
105
+
106
106
  desc 'Run one or all /data/seeds scripts' if defined? DataMapper
107
107
  task :seed, :file do |t, args|
108
108
  if args.file == nil
@@ -111,7 +111,7 @@ namespace :dm do
111
111
  require "./data/seeds/#{args.file}"
112
112
  end
113
113
  end
114
-
114
+
115
115
  end
116
116
 
117
117
  end
@@ -1,5 +1,5 @@
1
1
  namespace :setup do
2
-
2
+
3
3
  desc 'Set up Pony'
4
4
  task :pony do
5
5
  create_directory './settings'
@@ -7,5 +7,5 @@ namespace :setup do
7
7
  copy_file "#{TEMPLATES}/pony/settings/pony.rb",
8
8
  "./settings/pony.rb"
9
9
  end
10
-
10
+
11
11
  end
@@ -1,7 +1,7 @@
1
1
  namespace :sinatra do
2
-
3
- namespace :add do
4
2
 
3
+ namespace :add do
4
+
5
5
  desc 'Add a namespaced /routes file'
6
6
  task :routes, :namespace do |t, args|
7
7
  if args.namespace == nil
@@ -17,7 +17,7 @@ namespace :sinatra do
17
17
  "./tests/routes/#{args.namespace}_tests.rb",
18
18
  { namespace: args.namespace }
19
19
  end
20
-
20
+
21
21
  end
22
-
22
+
23
23
  end
@@ -5,16 +5,24 @@ require 'sinatra/chassis/helpers'
5
5
 
6
6
  require 'sinatra/reloader' if development?
7
7
 
8
- require_directory(settings.load_path)
9
-
10
8
  enable :sessions
11
9
  set :session_secret, 'secret123'
12
10
 
11
+ require_directory([
12
+ 'config',
13
+ 'settings',
14
+ 'helpers',
15
+ 'libraries',
16
+ 'models',
17
+ 'controllers',
18
+ 'routes'
19
+ ])
20
+
13
21
  get '/?' do
14
22
  @readme = ''
15
23
  File.open('./README.md') do |file|
16
24
  file.each_line { |line| @readme << line }
17
25
  end
18
26
 
19
- erb :readme, layout: false
27
+ erb :readme, layout: false
20
28
  end
@@ -1,18 +1,18 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
6
- <meta name="description" content="" />
7
- <meta name="author" content="" />
8
- <title>Your Name Here</title>
9
- <link rel="shortcut icon" href="favicon.ico" />
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
6
+ <meta name="description" content="" />
7
+ <meta name="author" content="" />
8
+ <title>Your Name Here</title>
9
+ <link rel="shortcut icon" href="favicon.ico" />
10
10
  </head>
11
11
 
12
12
  <body>
13
-
14
- <%= alert %>
15
- <%= yield %>
16
-
13
+
14
+ <%= alert %>
15
+ <%= yield %>
16
+
17
17
  </body>
18
18
  </html>
@@ -1,23 +1,23 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta charset="utf-8" />
5
- <title>Chassis</title>
6
- <style>
7
- body {
8
- font-family: 'Helvetica Neue', Helvetica, sans-serif;
9
- margin: 10% auto;
10
- text-align: center;
11
- }
12
- a, a:visited {
13
- color: #27b1f5;
14
- }
15
- </style>
4
+ <meta charset="utf-8" />
5
+ <title>Chassis</title>
6
+ <style>
7
+ body {
8
+ font-family: 'Helvetica Neue', Helvetica, sans-serif;
9
+ margin: 10% auto;
10
+ text-align: center;
11
+ }
12
+ a, a:visited {
13
+ color: #27b1f5;
14
+ }
15
+ </style>
16
16
  </head>
17
17
 
18
18
  <body>
19
-
19
+
20
20
  <%= Kramdown::Document.new(@readme).to_html %>
21
-
21
+
22
22
  </body>
23
23
  </html>
@@ -1,5 +1,5 @@
1
1
  migration <%= locals[:t] %>, :<%= locals[:migration] %> do
2
-
2
+
3
3
  up do
4
4
  # create_table :widgets do
5
5
  # column :id, Integer, serial: true
@@ -9,5 +9,5 @@ migration <%= locals[:t] %>, :<%= locals[:migration] %> do
9
9
  down do
10
10
  # drop_table :widgets
11
11
  end
12
-
12
+
13
13
  end
@@ -1,8 +1,8 @@
1
1
  class <%= locals[:model].capitalize %>
2
- include DataMapper::Resource
3
-
4
- timestamps :at, :on
5
- property :deleted_at, ParanoidDateTime
6
- property :id, Serial
7
-
2
+ include DataMapper::Resource
3
+
4
+ timestamps :at, :on
5
+ property :deleted_at, ParanoidDateTime
6
+ property :id, Serial
7
+
8
8
  end
@@ -1,16 +1,16 @@
1
1
  configure :development do
2
- DataMapper::Logger.new $stdout, :debug
3
- # DataMapper.setup :default, 'sqlite::memory:'
4
- DataMapper.setup :default, "sqlite://#{Dir.pwd}/data/development.sqlite3"
5
- # DataMapper.setup :default, 'mysql://username:password@host_url:3306/database_name'
6
- # DataMapper.setup :default, 'postgres://username:password@host_url:5432/database_name'
2
+ DataMapper::Logger.new $stdout, :debug
3
+ # DataMapper.setup :default, 'sqlite::memory:'
4
+ DataMapper.setup :default, "sqlite://#{Dir.pwd}/data/development.sqlite3"
5
+ # DataMapper.setup :default, 'mysql://username:password@host_url:3306/database_name'
6
+ # DataMapper.setup :default, 'postgres://username:password@host_url:5432/database_name'
7
7
  end
8
8
 
9
9
  configure :production do
10
- # DataMapper::Logger.new $stdout, :debug
11
- # DataMapper.setup :default, 'sqlite::memory:'
12
- # DataMapper.setup :default, "sqlite://#{Dir.pwd}/data/production.sqlite3"
13
- # DataMapper.setup :default, 'mysql://username:password@host_url:3306/database_name'
14
- # DataMapper.setup :default, 'postgres://username:password@host_url:5432/database_name'
15
- # DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://localhost/mydb')
10
+ # DataMapper::Logger.new $stdout, :debug
11
+ # DataMapper.setup :default, 'sqlite::memory:'
12
+ # DataMapper.setup :default, "sqlite://#{Dir.pwd}/data/production.sqlite3"
13
+ # DataMapper.setup :default, 'mysql://username:password@host_url:3306/database_name'
14
+ # DataMapper.setup :default, 'postgres://username:password@host_url:5432/database_name'
15
+ # DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://localhost/mydb')
16
16
  end
@@ -8,9 +8,9 @@ class <%= locals[:model].capitalize %>Tests < MiniTest::Unit::TestCase
8
8
  def app
9
9
  Sinatra::Application
10
10
  end
11
-
12
- # def test_made_by
13
- # <%= locals[:model] %> = <%= locals[:model].capitalize %>.new
14
- # assert_equal <%= locals[:model] %>.made_by, 'Acme Corp.'
15
- # end
11
+
12
+ # def test_made_by
13
+ # <%= locals[:model] %> = <%= locals[:model].capitalize %>.new
14
+ # assert_equal <%= locals[:model] %>.made_by, 'Acme Corp.'
15
+ # end
16
16
  end
@@ -1,27 +1,27 @@
1
1
  Pony.options = {
2
- via: :smtp,
3
- via_options: {
4
- address: '',
5
- port: '',
6
- domain: '',
7
- user_name: '',
8
- password: '',
9
- authentication: :plain,
10
- enable_starttls_auto: true
11
- }
2
+ via: :smtp,
3
+ via_options: {
4
+ address: '',
5
+ port: '',
6
+ domain: '',
7
+ user_name: '',
8
+ password: '',
9
+ authentication: :plain,
10
+ enable_starttls_auto: true
11
+ }
12
12
  }
13
13
 
14
14
  # Heroku example:
15
15
 
16
16
  # Pony.options = {
17
- # via: :smtp,
18
- # via_options: {
19
- # address: 'smtp.sendgrid.net',
20
- # port: '587',
21
- # domain: 'heroku.com',
22
- # user_name: ENV['SENDGRID_USERNAME'],
23
- # password: ENV['SENDGRID_PASSWORD'],
24
- # authentication: :plain,
25
- # enable_starttls_auto: true
26
- # }
17
+ # via: :smtp,
18
+ # via_options: {
19
+ # address: 'smtp.sendgrid.net',
20
+ # port: '587',
21
+ # domain: 'heroku.com',
22
+ # user_name: ENV['SENDGRID_USERNAME'],
23
+ # password: ENV['SENDGRID_PASSWORD'],
24
+ # authentication: :plain,
25
+ # enable_starttls_auto: true
26
+ # }
27
27
  # }
@@ -1,36 +1,36 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Error</title>
7
- <style type="text/css">
8
- body {
9
- font-family: sans-serif;
10
- font-size: 16px;
11
- padding: 11% 0 0 0;
12
- text-align: center;
13
- }
14
- hr {
15
- border: none;
16
- border-top: 1px solid silver;
17
- width: 50%;
18
- }
19
- h2 {
20
- color: silver;
21
- font-style: italic;
22
- font-weight: normal;
23
- }
24
- </style>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Error</title>
7
+ <style type="text/css">
8
+ body {
9
+ font-family: sans-serif;
10
+ font-size: 16px;
11
+ padding: 11% 0 0 0;
12
+ text-align: center;
13
+ }
14
+ hr {
15
+ border: none;
16
+ border-top: 1px solid silver;
17
+ width: 50%;
18
+ }
19
+ h2 {
20
+ color: silver;
21
+ font-style: italic;
22
+ font-weight: normal;
23
+ }
24
+ </style>
25
25
  </head>
26
26
 
27
27
  <body>
28
-
29
- <h1>Error <%= code %></h1>
28
+
29
+ <h1>Error <%= code %></h1>
30
30
 
31
31
  <hr />
32
32
 
33
33
  <h2><%= message %></h2>
34
-
34
+
35
35
  </body>
36
36
  </html>
@@ -2,9 +2,9 @@
2
2
  $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
-
5
+
6
6
  s.name = 'sinatra-chassis'
7
- s.version = '1.0.1'
7
+ s.version = '1.0.2'
8
8
  s.author = 'Jarrod Taylor'
9
9
  s.email = 'jarrodtaylor@icloud.com'
10
10
  s.homepage = 'http://jarrodtaylor.github.com/sinatra-chassis'
@@ -17,12 +17,12 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.required_ruby_version = ">= 1.9.2"
20
-
20
+
21
21
  s.add_dependency 'coffee-script', '>= 2.2.0'
22
22
  s.add_dependency 'paint', '>= 0.8.5'
23
23
  s.add_dependency 'rack-flash3', '>= 1.0.3'
24
24
  s.add_dependency 'rack-test', '>= 0.6.2'
25
25
  s.add_dependency 'sass', '>= 3.2.5'
26
26
  s.add_dependency 'sinatra', '~> 1.3.4'
27
-
27
+
28
28
  end
metadata CHANGED
@@ -1,100 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-chassis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jarrod Taylor
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
11
+ date: 2013-04-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: coffee-script
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.2.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.2.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: paint
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.8.5
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.8.5
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rack-flash3
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.0.3
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.3
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rack-test
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: 0.6.2
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: 0.6.2
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: sass
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: 3.2.5
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: 3.2.5
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: sinatra
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -154,26 +141,25 @@ files:
154
141
  homepage: http://jarrodtaylor.github.com/sinatra-chassis
155
142
  licenses:
156
143
  - MIT
144
+ metadata: {}
157
145
  post_install_message:
158
146
  rdoc_options: []
159
147
  require_paths:
160
148
  - lib
161
149
  required_ruby_version: !ruby/object:Gem::Requirement
162
- none: false
163
150
  requirements:
164
- - - ! '>='
151
+ - - '>='
165
152
  - !ruby/object:Gem::Version
166
153
  version: 1.9.2
167
154
  required_rubygems_version: !ruby/object:Gem::Requirement
168
- none: false
169
155
  requirements:
170
- - - ! '>='
156
+ - - '>='
171
157
  - !ruby/object:Gem::Version
172
158
  version: '0'
173
159
  requirements: []
174
160
  rubyforge_project:
175
- rubygems_version: 1.8.25
161
+ rubygems_version: 2.0.0
176
162
  signing_key:
177
- specification_version: 3
163
+ specification_version: 4
178
164
  summary: Chassis is a mutable framework extension for Sinatra.
179
165
  test_files: []