vesper 0.4.1 → 0.5.0
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/lib/vesper/template/Gemfile +4 -13
- data/lib/vesper/template/Gemfile.lock +0 -17
- data/lib/vesper/template/Rakefile +4 -1
- data/lib/vesper/template/{lib → application}/hello_world.rb +0 -0
- data/lib/vesper/template/config.ru +1 -1
- data/lib/vesper/template/loader.rb +15 -0
- data/lib/vesper/template/plugins/addendums/Readme.md +85 -0
- data/lib/vesper/template/plugins/addendums/application/helpers.rb +19 -0
- data/lib/vesper/template/plugins/addendums/application/number.rb +26 -0
- data/lib/vesper/template/plugins/addendums/application/string.rb +15 -0
- data/lib/vesper/template/plugins/log/Readme.md +40 -0
- data/lib/vesper/template/plugins/log/application/log.rb +31 -0
- data/lib/vesper/template/plugins/log/tasks/log.rb +12 -0
- data/lib/vesper/template/plugins/markdown/Gemfile +1 -0
- data/lib/vesper/template/plugins/markdown/Readme.md +11 -0
- data/lib/vesper/template/plugins/markdown/application/markdown.rb +5 -0
- data/lib/vesper/template/{config → plugins/markdown/config}/markdown.rb +2 -0
- data/lib/vesper/template/plugins/timepiece/Gemfile +1 -0
- data/lib/vesper/template/plugins/timepiece/Readme.md +46 -0
- data/lib/vesper/template/{vendor/plugins/date_time.rb → plugins/timepiece/application/timepiece.rb} +3 -34
- data/lib/vesper/version.rb +1 -1
- data/vesper.gemspec +0 -2
- metadata +34 -51
- data/lib/vesper/template/app.rb +0 -14
- data/lib/vesper/template/config/email.rb +0 -15
- data/lib/vesper/template/config/sms.rb +0 -15
- data/lib/vesper/template/vendor/bundle/.gitkeep +0 -0
- data/lib/vesper/template/vendor/plugins/helpers.rb +0 -43
- data/lib/vesper/template/vendor/plugins/log.rb +0 -60
- data/lib/vesper/template/vendor/plugins/number.rb +0 -60
- data/lib/vesper/template/vendor/plugins/string.rb +0 -40
data/lib/vesper/template/Gemfile
CHANGED
@@ -2,26 +2,17 @@
|
|
2
2
|
source 'http://rubygems.org'
|
3
3
|
|
4
4
|
|
5
|
-
# For date and time parsing
|
6
|
-
gem 'chronic', '~> 0.6.5'
|
7
|
-
|
8
5
|
# For databases and model classes
|
9
6
|
gem 'data_mapper', '~> 1.2.0'
|
10
7
|
# gem 'dm-mysql-adapter'
|
11
8
|
# gem 'dm-postgres-adapter'
|
12
9
|
gem 'dm-sqlite-adapter', '~> 1.2.0'
|
13
10
|
|
14
|
-
# For sending email
|
15
|
-
gem 'pony', '~> 1.4'
|
16
|
-
|
17
|
-
# For Markdown conversions
|
18
|
-
gem 'redcarpet', '~> 2.0.0'
|
19
|
-
|
20
11
|
# For route handling
|
21
12
|
gem 'sinatra', '~> 1.3.1'
|
22
13
|
|
23
|
-
# For sending text messages
|
24
|
-
gem 'twiliolib', '~> 2.0.7'
|
25
|
-
|
26
14
|
# For writing cron jobs in Ruby
|
27
|
-
gem 'whenever', '~> 0.7.0', :require => false
|
15
|
+
gem 'whenever', '~> 0.7.0', :require => false
|
16
|
+
|
17
|
+
# Load gems from plugins
|
18
|
+
Dir["./plugins/**/Gemfile"].each {|gemfile| self.send(:eval, File.open(gemfile, 'r').read)}
|
@@ -5,7 +5,6 @@ GEM
|
|
5
5
|
multi_json (~> 1.0)
|
6
6
|
addressable (2.2.6)
|
7
7
|
bcrypt-ruby (3.0.1)
|
8
|
-
builder (3.0.0)
|
9
8
|
chronic (0.6.5)
|
10
9
|
data_mapper (1.2.0)
|
11
10
|
dm-aggregates (~> 1.2.0)
|
@@ -56,18 +55,9 @@ GEM
|
|
56
55
|
do_sqlite3 (0.10.7)
|
57
56
|
data_objects (= 0.10.7)
|
58
57
|
fastercsv (1.5.4)
|
59
|
-
i18n (0.6.0)
|
60
58
|
json (1.6.3)
|
61
59
|
json_pure (1.6.1)
|
62
|
-
mail (2.3.0)
|
63
|
-
i18n (>= 0.4.0)
|
64
|
-
mime-types (~> 1.16)
|
65
|
-
treetop (~> 1.4.8)
|
66
|
-
mime-types (1.17.2)
|
67
60
|
multi_json (1.0.4)
|
68
|
-
polyglot (0.3.3)
|
69
|
-
pony (1.4)
|
70
|
-
mail (> 2.0)
|
71
61
|
rack (1.3.5)
|
72
62
|
rack-protection (1.1.4)
|
73
63
|
rack
|
@@ -78,11 +68,6 @@ GEM
|
|
78
68
|
tilt (~> 1.3, >= 1.3.3)
|
79
69
|
stringex (1.3.0)
|
80
70
|
tilt (1.3.3)
|
81
|
-
treetop (1.4.10)
|
82
|
-
polyglot
|
83
|
-
polyglot (>= 0.3.1)
|
84
|
-
twiliolib (2.0.7)
|
85
|
-
builder (>= 2.1.2)
|
86
71
|
uuidtools (2.1.2)
|
87
72
|
whenever (0.7.0)
|
88
73
|
activesupport (>= 2.3.4)
|
@@ -95,8 +80,6 @@ DEPENDENCIES
|
|
95
80
|
chronic (~> 0.6.5)
|
96
81
|
data_mapper (~> 1.2.0)
|
97
82
|
dm-sqlite-adapter (~> 1.2.0)
|
98
|
-
pony (~> 1.4)
|
99
83
|
redcarpet (~> 2.0.0)
|
100
84
|
sinatra (~> 1.3.1)
|
101
|
-
twiliolib (~> 2.0.7)
|
102
85
|
whenever (~> 0.7.0)
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Use the gems in Gemfile
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
# Directories to load, in order
|
6
|
+
[
|
7
|
+
'config',
|
8
|
+
'ext',
|
9
|
+
'plugins/**/config',
|
10
|
+
'plugins/**/application',
|
11
|
+
'application'
|
12
|
+
].each {|dir| Dir["./#{dir}/**/*.rb"].each {|file| require file}}
|
13
|
+
|
14
|
+
# Tell DataMapper that all the models are ready
|
15
|
+
DataMapper.finalize
|
@@ -0,0 +1,85 @@
|
|
1
|
+
Addendums Vesper Plugin
|
2
|
+
=======================
|
3
|
+
> Adds useful extensions to Ruby and Sinatra
|
4
|
+
|
5
|
+
|
6
|
+
active(path)
|
7
|
+
------------
|
8
|
+
> Adds a class of 'active' to an element that matches the page url.
|
9
|
+
|
10
|
+
>> <a href="#" class="<%= active '/home' %>">Home</a>
|
11
|
+
=> <a href="#" class="active">Home</a>
|
12
|
+
|
13
|
+
|
14
|
+
alert
|
15
|
+
-----
|
16
|
+
> Displays an alert message div.
|
17
|
+
|
18
|
+
> Note: Will only display on the next page load.
|
19
|
+
|
20
|
+
>> session[:flash] = 'Your message here.' # Before page loads, usually in a route the redirects
|
21
|
+
>> <%= alert => # In your view or layout
|
22
|
+
=> "<div id='alert'>Your message here.</div>"
|
23
|
+
|
24
|
+
|
25
|
+
hidden
|
26
|
+
------
|
27
|
+
> Hides an element.
|
28
|
+
|
29
|
+
> Note: Works will with if/unless (hidden unless @var.empty?).
|
30
|
+
|
31
|
+
>> <div style="<%= hidden %>">Content to hide</div>
|
32
|
+
|
33
|
+
|
34
|
+
dollarize
|
35
|
+
---------
|
36
|
+
> Converts a number to a dollar
|
37
|
+
|
38
|
+
> Note: This isn't a currency conversion, it's only a string.
|
39
|
+
|
40
|
+
>> 1.dollarize
|
41
|
+
=> '$1.00'
|
42
|
+
|
43
|
+
|
44
|
+
even?
|
45
|
+
-----
|
46
|
+
> Returns true if a number is even.
|
47
|
+
|
48
|
+
>> 2.even?
|
49
|
+
=> true
|
50
|
+
|
51
|
+
|
52
|
+
odd?
|
53
|
+
----
|
54
|
+
> Returns true if a number is odd.
|
55
|
+
|
56
|
+
>> 2.even?
|
57
|
+
=> false
|
58
|
+
|
59
|
+
|
60
|
+
truncate_to_decimal(dec = 1)
|
61
|
+
----------------------------
|
62
|
+
> Truncates a number to a float (The standard truncate methods returns an integer).
|
63
|
+
|
64
|
+
> The dec argument determines how many digits to leave after the decimal; it defaults to 1.
|
65
|
+
|
66
|
+
> Note: Removes trailing 0s.
|
67
|
+
|
68
|
+
>> 1.234.truncate_to_decimal 2
|
69
|
+
=> 1.23
|
70
|
+
|
71
|
+
|
72
|
+
titleize
|
73
|
+
--------
|
74
|
+
> Capitalizes the first letter of each word in a string.
|
75
|
+
|
76
|
+
>> 'This is a title'.titleize
|
77
|
+
=> 'This Is A Title'
|
78
|
+
|
79
|
+
|
80
|
+
truncate(word_count = 100, end_string = '...')
|
81
|
+
----------------------------------------------
|
82
|
+
> Truncates by word count (not letter).
|
83
|
+
|
84
|
+
>> 'One Two Three Four Five'.truncate 3
|
85
|
+
=> 'One Two Three...'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
helpers do
|
2
|
+
|
3
|
+
def active path
|
4
|
+
'active' if request.path_info.include? "/#{path}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def alert
|
8
|
+
unless session[:alert].nil?
|
9
|
+
msg = session[:alert]
|
10
|
+
session[:alert] = nil
|
11
|
+
"<div id='alert'>#{msg}</div>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def hidden
|
16
|
+
'display: none;'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Number
|
2
|
+
|
3
|
+
def dollarize
|
4
|
+
num = self
|
5
|
+
"$%.2f" % num.to_f
|
6
|
+
end
|
7
|
+
|
8
|
+
def even?
|
9
|
+
self%2 == 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def odd?
|
13
|
+
self%2 != 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def truncate_to_decimal dec = 1
|
17
|
+
num = self
|
18
|
+
rounded = "%.#{dec}f" % num.to_f
|
19
|
+
rounded = rounded.to_s.split('.').first if rounded.to_s.end_with?('0')
|
20
|
+
rounded.to_f
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
Fixnum.class_eval { include Number }
|
26
|
+
Float.class_eval { include Number }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
String.class_eval do
|
2
|
+
|
3
|
+
def titleize
|
4
|
+
title = ''
|
5
|
+
self.split(' ').each {|s| title << s.capitalize + ' ' }
|
6
|
+
title
|
7
|
+
end
|
8
|
+
|
9
|
+
def truncate word_count = 100, end_string = '...'
|
10
|
+
return if self == nil
|
11
|
+
words = self.split()
|
12
|
+
words[0..(word_count-1)].join(' ') + (words.length > word_count ? end_string : '')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Log Vesper Plugin
|
2
|
+
=================
|
3
|
+
> Writes to and clears out log files.
|
4
|
+
|
5
|
+
|
6
|
+
message(msg)
|
7
|
+
------------
|
8
|
+
> Writes to log/messages.log.
|
9
|
+
|
10
|
+
>> Log.message('This is my message.')
|
11
|
+
=> This is my message
|
12
|
+
|
13
|
+
|
14
|
+
write_errors(request)
|
15
|
+
---------------------
|
16
|
+
> Writes errors to a log file.
|
17
|
+
|
18
|
+
>> before do
|
19
|
+
>> Log.write_errors request
|
20
|
+
>> end
|
21
|
+
|
22
|
+
|
23
|
+
write_requests_and_errors(request)
|
24
|
+
----------------------------------
|
25
|
+
> Writes errors and requests to a log file.
|
26
|
+
|
27
|
+
>> before do
|
28
|
+
>> Log.write_requests_and_errors request
|
29
|
+
>> end
|
30
|
+
|
31
|
+
|
32
|
+
clear(file)
|
33
|
+
-----------
|
34
|
+
> Clears out a log file.
|
35
|
+
|
36
|
+
>> Log.clear('messages')
|
37
|
+
|
38
|
+
> Also useful as a rake task.
|
39
|
+
|
40
|
+
>> rake log:clear file=messages
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Log
|
2
|
+
|
3
|
+
def self.message msg
|
4
|
+
File.open('log/messages.log', 'a+') { |f| f.write("\n#{msg}\n") }
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.write_errors request
|
8
|
+
if env['sinatra.error']
|
9
|
+
File.open("log/#{ENV['RACK_ENV']}.log", 'a+') do |f|
|
10
|
+
f.write("\n#{ENV['sinatra.error']}\n")
|
11
|
+
f.write(" #{Time.now} #{ENV['SERVER_PROTOCOL']} #{request.port} #{request.request_method} #{request.url}\n")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.write_requests_and_errors request
|
17
|
+
File.open("log/#{ENV['RACK_ENV']}.log", 'a+') do |f|
|
18
|
+
f.write("\n#{ENV['sinatra.error']}\n") if ENV['sinatra.error']
|
19
|
+
f.write(" #{Time.now} #{ENV['SERVER_PROTOCOL']} #{request.port} #{request.request_method} #{request.url}\n")
|
20
|
+
f.write("\n") if ENV['sinatra.error']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.clear file
|
25
|
+
if File.exists? "log/#{file}.log"
|
26
|
+
File.delete "log/#{file}.log"
|
27
|
+
File.open "log/#{file}.log", 'w+'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'redcarpet', '~> 2.0.0'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'chronic', '~> 0.6.5'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Timepiece Vesper Plugin
|
2
|
+
=======================
|
3
|
+
> Assists in converting db date and time fields to and from usable elements.
|
4
|
+
|
5
|
+
|
6
|
+
display
|
7
|
+
-------
|
8
|
+
> Converts a Date, Time or DateTime object into a human readable string.
|
9
|
+
|
10
|
+
>> d = DateTime.now
|
11
|
+
>> d.display
|
12
|
+
=> 'Thursday Dec 15, 2011'
|
13
|
+
|
14
|
+
>> d.display(:date)
|
15
|
+
=> 'Thursday Dec 15, 2011'
|
16
|
+
|
17
|
+
>> d.display(:day)
|
18
|
+
=> 'Dec 15, 2011'
|
19
|
+
|
20
|
+
>> d.display(:day_with_time)
|
21
|
+
=> 'Dec 15, 2011 at 11:51pm'
|
22
|
+
|
23
|
+
>> d.display(:american_day)
|
24
|
+
=> '12/15/11'
|
25
|
+
|
26
|
+
|
27
|
+
to_fields(select_field_name)
|
28
|
+
----------------------------
|
29
|
+
> Converts a Date, Time or DateTime object into form fields.
|
30
|
+
|
31
|
+
> Requires a select name argument. The generated select fields will end with _year, _month and _day.
|
32
|
+
|
33
|
+
# This will generate 'my_date_year', 'my_date_month' and 'my_date_day'
|
34
|
+
>> d = DateTime.now
|
35
|
+
>> d.to_fields('my_date')
|
36
|
+
=> "<select name='my_date_month' id='my_date_month'><option value='1' >1</option><option value='2' >2</option><option value='3' >3</option><option value='4' >4</option><option value='5' >5</option><option value='6' >6</option><option value='7' >7</option><option value='8' >8</option><option value='9' >9</option><option value='10' >10</option><option value='11' >11</option><option value='12' selected>12</option></select><select name='my_date_day' id='my_date_day'><option value='1' >1</option><option value='2' >2</option><option value='3' >3</option><option value='4' >4</option><option value='5' >5</option><option value='6' >6</option><option value='7' >7</option><option value='8' >8</option><option value='9' >9</option><option value='10' >10</option><option value='11' >11</option><option value='12' >12</option><option value='13' >13</option><option value='14' >14</option><option value='15' selected>15</option><option value='16' >16</option><option value='17' >17</option><option value='18' >18</option><option value='19' >19</option><option value='20' >20</option><option value='21' >21</option><option value='22' >22</option><option value='23' >23</option><option value='24' >24</option><option value='25' >25</option><option value='26' >26</option><option value='27' >27</option><option value='28' >28</option><option value='29' >29</option><option value='30' >30</option><option value='31' >31</option></select><select name='my_date_year' id='my_date_year'><option value='2007' >2007</option><option value='2008' >2008</option><option value='2009' >2009</option><option value='2010' >2010</option><option value='2011' selected>2011</option><option value='2012' >2012</option><option value='2013' >2013</option><option value='2014' >2014</option></select>"
|
37
|
+
|
38
|
+
|
39
|
+
from_fields(year, month, day)
|
40
|
+
-----------------------------
|
41
|
+
> Converts a year, month and day string into a database DateTime object.
|
42
|
+
|
43
|
+
> This example is based on the fields generated in the above 'to_fields' example, as if they were passed from a form.
|
44
|
+
|
45
|
+
>> Date.from_fields(params[:my_date_year], params[:my_date_month], params[:my_date_day])
|
46
|
+
=> 2011-12-15 12:00:00 -0500
|
data/lib/vesper/template/{vendor/plugins/date_time.rb → plugins/timepiece/application/timepiece.rb}
RENAMED
@@ -1,36 +1,15 @@
|
|
1
1
|
module Timepiece
|
2
2
|
|
3
|
-
# Adds the below ClassMethods module methods as class methods to the including class
|
4
3
|
def self.included base
|
5
4
|
base.extend ClassMethods
|
6
5
|
end
|
7
6
|
|
8
7
|
module ClassMethods
|
9
|
-
|
10
|
-
# Convert date form fields into a DB compatible date
|
11
|
-
#
|
12
|
-
# Example:
|
13
|
-
# >> Date.from_fields 2010, 6, 26
|
14
|
-
# => 2010-06-26 12:00:00 -0400
|
15
|
-
#
|
16
|
-
# Arguments:
|
17
|
-
# year, month, day
|
18
|
-
#
|
19
8
|
def from_fields year, month, day
|
20
9
|
Chronic.parse("#{year}-#{month}-#{day}")
|
21
10
|
end
|
22
|
-
|
23
11
|
end
|
24
12
|
|
25
|
-
# Convert date to human readable string
|
26
|
-
#
|
27
|
-
# Example:
|
28
|
-
# >> DateTime.now.display :date
|
29
|
-
# => "Friday Dec 09, 2011"
|
30
|
-
#
|
31
|
-
# Arguments:
|
32
|
-
# format (options: date, day, day_with_time, american_day)
|
33
|
-
#
|
34
13
|
def display format = :date
|
35
14
|
case format
|
36
15
|
when :date
|
@@ -47,15 +26,6 @@ module Timepiece
|
|
47
26
|
self.strftime string
|
48
27
|
end
|
49
28
|
|
50
|
-
# Convert date form fields
|
51
|
-
#
|
52
|
-
# Example:
|
53
|
-
# >> DateTime.now.to_fields
|
54
|
-
# => (Entirely to long to show)
|
55
|
-
#
|
56
|
-
# Arguments:
|
57
|
-
# field (to reference the fields by name later)
|
58
|
-
#
|
59
29
|
def to_fields field
|
60
30
|
date_field = ""
|
61
31
|
|
@@ -82,7 +52,6 @@ module Timepiece
|
|
82
52
|
|
83
53
|
end
|
84
54
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
Time.class_eval { include Timepiece }
|
55
|
+
Date.class_eval { include Timepiece }
|
56
|
+
DateTime.class_eval { include Timepiece }
|
57
|
+
Time.class_eval { include Timepiece }
|
data/lib/vesper/version.rb
CHANGED
data/vesper.gemspec
CHANGED
@@ -23,9 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency "chronic", "~> 0.6.5"
|
24
24
|
s.add_runtime_dependency "data_mapper", "~> 1.2.0"
|
25
25
|
s.add_runtime_dependency "dm-sqlite-adapter", "~> 1.2.0"
|
26
|
-
s.add_runtime_dependency "pony", "~> 1.4"
|
27
26
|
s.add_runtime_dependency "redcarpet", "~> 2.0.0"
|
28
27
|
s.add_runtime_dependency "sinatra", "~> 1.3.1"
|
29
|
-
s.add_runtime_dependency "twiliolib", "~> 2.0.7"
|
30
28
|
s.add_runtime_dependency "whenever", "~> 0.7.0"
|
31
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vesper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70097654583800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.21
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70097654583800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70097654582560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.21
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70097654582560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: chronic
|
38
|
-
requirement: &
|
38
|
+
requirement: &70097654580600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70097654580600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: data_mapper
|
49
|
-
requirement: &
|
49
|
+
requirement: &70097654595260 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.2.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70097654595260
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: dm-sqlite-adapter
|
60
|
-
requirement: &
|
60
|
+
requirement: &70097654591960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,21 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.2.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pony
|
71
|
-
requirement: &70192348851080 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '1.4'
|
77
|
-
type: :runtime
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *70192348851080
|
68
|
+
version_requirements: *70097654591960
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: redcarpet
|
82
|
-
requirement: &
|
71
|
+
requirement: &70097654589680 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ~>
|
@@ -87,10 +76,10 @@ dependencies:
|
|
87
76
|
version: 2.0.0
|
88
77
|
type: :runtime
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *70097654589680
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: sinatra
|
93
|
-
requirement: &
|
82
|
+
requirement: &70097654603820 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ~>
|
@@ -98,21 +87,10 @@ dependencies:
|
|
98
87
|
version: 1.3.1
|
99
88
|
type: :runtime
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: twiliolib
|
104
|
-
requirement: &70192348861540 !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 2.0.7
|
110
|
-
type: :runtime
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *70192348861540
|
90
|
+
version_requirements: *70097654603820
|
113
91
|
- !ruby/object:Gem::Dependency
|
114
92
|
name: whenever
|
115
|
-
requirement: &
|
93
|
+
requirement: &70097654603320 !ruby/object:Gem::Requirement
|
116
94
|
none: false
|
117
95
|
requirements:
|
118
96
|
- - ~>
|
@@ -120,7 +98,7 @@ dependencies:
|
|
120
98
|
version: 0.7.0
|
121
99
|
type: :runtime
|
122
100
|
prerelease: false
|
123
|
-
version_requirements: *
|
101
|
+
version_requirements: *70097654603320
|
124
102
|
description:
|
125
103
|
email: jarrodtaylor@me.com
|
126
104
|
executables:
|
@@ -139,19 +117,30 @@ files:
|
|
139
117
|
- lib/vesper/template/Gemfile.lock
|
140
118
|
- lib/vesper/template/README.md
|
141
119
|
- lib/vesper/template/Rakefile
|
142
|
-
- lib/vesper/template/
|
120
|
+
- lib/vesper/template/application/hello_world.rb
|
143
121
|
- lib/vesper/template/config.ru
|
144
122
|
- lib/vesper/template/config/databases.rb
|
145
|
-
- lib/vesper/template/config/email.rb
|
146
|
-
- lib/vesper/template/config/markdown.rb
|
147
123
|
- lib/vesper/template/config/mime_types.rb
|
148
124
|
- lib/vesper/template/config/schedule.rb
|
149
125
|
- lib/vesper/template/config/sessions.rb
|
150
|
-
- lib/vesper/template/config/sms.rb
|
151
126
|
- lib/vesper/template/data/seeds.rb
|
152
127
|
- lib/vesper/template/data/transmogrify.rb
|
153
|
-
- lib/vesper/template/
|
128
|
+
- lib/vesper/template/loader.rb
|
154
129
|
- lib/vesper/template/log/messages.log
|
130
|
+
- lib/vesper/template/plugins/addendums/Readme.md
|
131
|
+
- lib/vesper/template/plugins/addendums/application/helpers.rb
|
132
|
+
- lib/vesper/template/plugins/addendums/application/number.rb
|
133
|
+
- lib/vesper/template/plugins/addendums/application/string.rb
|
134
|
+
- lib/vesper/template/plugins/log/Readme.md
|
135
|
+
- lib/vesper/template/plugins/log/application/log.rb
|
136
|
+
- lib/vesper/template/plugins/log/tasks/log.rb
|
137
|
+
- lib/vesper/template/plugins/markdown/Gemfile
|
138
|
+
- lib/vesper/template/plugins/markdown/Readme.md
|
139
|
+
- lib/vesper/template/plugins/markdown/application/markdown.rb
|
140
|
+
- lib/vesper/template/plugins/markdown/config/markdown.rb
|
141
|
+
- lib/vesper/template/plugins/timepiece/Gemfile
|
142
|
+
- lib/vesper/template/plugins/timepiece/Readme.md
|
143
|
+
- lib/vesper/template/plugins/timepiece/application/timepiece.rb
|
155
144
|
- lib/vesper/template/public/css/design.css
|
156
145
|
- lib/vesper/template/public/img/fyeah.jpg
|
157
146
|
- lib/vesper/template/public/js/hide_addressbar.js
|
@@ -159,12 +148,6 @@ files:
|
|
159
148
|
- lib/vesper/template/tasks/databases.rb
|
160
149
|
- lib/vesper/template/tasks/irb.rb
|
161
150
|
- lib/vesper/template/tmp/restart.txt
|
162
|
-
- lib/vesper/template/vendor/bundle/.gitkeep
|
163
|
-
- lib/vesper/template/vendor/plugins/date_time.rb
|
164
|
-
- lib/vesper/template/vendor/plugins/helpers.rb
|
165
|
-
- lib/vesper/template/vendor/plugins/log.rb
|
166
|
-
- lib/vesper/template/vendor/plugins/number.rb
|
167
|
-
- lib/vesper/template/vendor/plugins/string.rb
|
168
151
|
- lib/vesper/template/views/hello_world.html
|
169
152
|
- lib/vesper/template/views/layout.html
|
170
153
|
- lib/vesper/version.rb
|
data/lib/vesper/template/app.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# Use the gems in Gemfile
|
2
|
-
require 'bundler'
|
3
|
-
Bundler.require
|
4
|
-
|
5
|
-
# Directories to load, in order
|
6
|
-
load_files = [
|
7
|
-
'config',
|
8
|
-
'vendor/plugins',
|
9
|
-
'lib'
|
10
|
-
]
|
11
|
-
load_files.each {|dir| Dir["./#{dir}/**/*.rb"].each {|file| require file}}
|
12
|
-
|
13
|
-
# Tell DataMapper that all the models are ready
|
14
|
-
DataMapper.finalize
|
@@ -1,15 +0,0 @@
|
|
1
|
-
set :mail_server, {
|
2
|
-
address: 'smtp.gmail.com',
|
3
|
-
port: '587',
|
4
|
-
enable_starttls_auto: true,
|
5
|
-
user_name: '',
|
6
|
-
password: '',
|
7
|
-
authentication: :plain
|
8
|
-
}
|
9
|
-
|
10
|
-
# To send email via GMail:
|
11
|
-
# Pony.mail(via: :smtp, via_options: settings.mail_server,
|
12
|
-
# to: 'you@example.com',
|
13
|
-
# subject:'This is a sample email',
|
14
|
-
# body: 'Can you read me now?'
|
15
|
-
# )
|
@@ -1,15 +0,0 @@
|
|
1
|
-
set :sms_server, {
|
2
|
-
account_number: '',
|
3
|
-
account_sid: '',
|
4
|
-
account_token: '',
|
5
|
-
api_version: ''
|
6
|
-
}
|
7
|
-
|
8
|
-
# To send an sms via Twilio:
|
9
|
-
# account = Twilio::RestAccount.new(settings.sms_server[:account_sid], settings.sms_server[:account_token])
|
10
|
-
# msg = {
|
11
|
-
# 'From' => settings.sms[:account_number],
|
12
|
-
# 'To' => 'xxxxxxxxxxx',
|
13
|
-
# 'Body' => 'Can you read me now?'
|
14
|
-
# }
|
15
|
-
# account.request("/#{settings.sms_server[:api_version]}/Accounts/#{settings.sms_server[:account_sid]}/SMS/Messages", 'POST', msg)
|
File without changes
|
@@ -1,43 +0,0 @@
|
|
1
|
-
helpers do
|
2
|
-
|
3
|
-
# Adds a class of 'active' to an element that matches the page url
|
4
|
-
#
|
5
|
-
# Example:
|
6
|
-
# <a href="#" class="<%= active '/home' %>">Home</a>
|
7
|
-
#
|
8
|
-
# Arguemnts:
|
9
|
-
# path (to match against the current url)
|
10
|
-
#
|
11
|
-
def active path
|
12
|
-
'active' if request.path_info.include? "/#{path}"
|
13
|
-
end
|
14
|
-
|
15
|
-
# Displays an alert message div
|
16
|
-
#
|
17
|
-
# Example:
|
18
|
-
# session[:flash] = 'Your message here.'
|
19
|
-
#
|
20
|
-
# Notes:
|
21
|
-
# Will only display on the next page load
|
22
|
-
#
|
23
|
-
def alert
|
24
|
-
unless session[:alert].nil?
|
25
|
-
msg = session[:alert]
|
26
|
-
session[:alert] = nil
|
27
|
-
"<div id='alert'>#{msg}</div>"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Hides an element
|
32
|
-
#
|
33
|
-
# Example:
|
34
|
-
# <div style="<%= hidden %>">Content to hide</div>
|
35
|
-
#
|
36
|
-
# Notes:
|
37
|
-
# Works will with if/unless (hidden unless @var.empty?)
|
38
|
-
#
|
39
|
-
def hidden
|
40
|
-
'display: none;'
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Log
|
2
|
-
|
3
|
-
# Writes a message to /log/messages.log
|
4
|
-
#
|
5
|
-
# Example:
|
6
|
-
# >> Log.message 'This is a message'
|
7
|
-
#
|
8
|
-
# Arguments:
|
9
|
-
# msg
|
10
|
-
#
|
11
|
-
def self.message msg
|
12
|
-
File.open('log/messages.log', 'a+') { |f| f.write("\n#{msg}\n") }
|
13
|
-
end
|
14
|
-
|
15
|
-
# Writes errors to a log file
|
16
|
-
#
|
17
|
-
# Example:
|
18
|
-
# >> Log.write_errors request.env, request
|
19
|
-
#
|
20
|
-
# Arguments:
|
21
|
-
# env (also the name of the log file, ex: development.log), request (used to parse errors)
|
22
|
-
#
|
23
|
-
def self.write_errors env, request
|
24
|
-
if env['sinatra.error']
|
25
|
-
File.open("log/#{settings.environment}.log", 'a+') do |f|
|
26
|
-
f.write("\n#{env['sinatra.error']}\n")
|
27
|
-
f.write(" #{Time.now} #{env['SERVER_PROTOCOL']} #{request.port} #{request.request_method} #{request.url}\n\n")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Writes errors and requests to a log file
|
33
|
-
#
|
34
|
-
# Example:
|
35
|
-
# >> Log.write_requests_and_errors request.env, request
|
36
|
-
#
|
37
|
-
# Arguments:
|
38
|
-
# env (also the name of the log file, ex: development.log), request (used to parse errors and requests)
|
39
|
-
#
|
40
|
-
def self.write_requests_and_errors env, request
|
41
|
-
File.open("log/#{settings.environment}.log", 'a+') do |f|
|
42
|
-
f.write("\n#{env['sinatra.error']}\n") if env['sinatra.error']
|
43
|
-
f.write(" #{Time.now} #{env['SERVER_PROTOCOL']} #{request.port} #{request.request_method} #{request.url}\n")
|
44
|
-
f.write("\n") if env['sinatra.error']
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Clears a log file
|
49
|
-
#
|
50
|
-
# Example:
|
51
|
-
# >> Log.clear 'messages'
|
52
|
-
#
|
53
|
-
# Arguments:
|
54
|
-
# file (name of log file to clear)
|
55
|
-
#
|
56
|
-
def self.clear file
|
57
|
-
File.open("log/#{file}.log", 'w+') if File::exists?("log/#{file}.log")
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Number
|
2
|
-
|
3
|
-
# Converts a number to a dollar
|
4
|
-
#
|
5
|
-
# Example:
|
6
|
-
# >> 1.dollarize
|
7
|
-
# => '$1.00'
|
8
|
-
#
|
9
|
-
# Note:
|
10
|
-
# This isn't a currency conversion, it's only a string
|
11
|
-
#
|
12
|
-
def dollarize
|
13
|
-
num = self
|
14
|
-
"$%.2f" % num.to_f
|
15
|
-
end
|
16
|
-
|
17
|
-
# Returns true if a number is even
|
18
|
-
#
|
19
|
-
# Example:
|
20
|
-
# >> 2.even?
|
21
|
-
# => true
|
22
|
-
#
|
23
|
-
def even?
|
24
|
-
self%2 == 0
|
25
|
-
end
|
26
|
-
|
27
|
-
# Returns true if a number is odd
|
28
|
-
#
|
29
|
-
# Example:
|
30
|
-
# >> 2.even?
|
31
|
-
# => false
|
32
|
-
#
|
33
|
-
def odd?
|
34
|
-
self%2 != 0
|
35
|
-
end
|
36
|
-
|
37
|
-
# Truncates a number to a float
|
38
|
-
#
|
39
|
-
# Example:
|
40
|
-
# >> 1.234.truncate_to_decimal 2
|
41
|
-
# => 1.23
|
42
|
-
#
|
43
|
-
# Arguments:
|
44
|
-
# dec (number of digits after the decimal, defaults to 1)
|
45
|
-
#
|
46
|
-
# Note:
|
47
|
-
# The standard truncate methods returns an integer
|
48
|
-
#
|
49
|
-
def truncate_to_decimal dec = 1
|
50
|
-
num = self
|
51
|
-
rounded = "%.#{dec}f" % num.to_f
|
52
|
-
rounded = rounded.to_s.split('.').first if rounded.to_s.end_with?('0')
|
53
|
-
rounded.to_f
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
# Include the above module in Fixnum and Float classes
|
59
|
-
Fixnum.class_eval { include Number }
|
60
|
-
Float.class_eval { include Number }
|
@@ -1,40 +0,0 @@
|
|
1
|
-
String.class_eval do
|
2
|
-
|
3
|
-
# Coverts markdown text to html
|
4
|
-
#
|
5
|
-
# Example:
|
6
|
-
# >> '# Header'.markdown
|
7
|
-
# => '<h1>Header</h1>'
|
8
|
-
#
|
9
|
-
def markdown
|
10
|
-
REDCARPET.render self
|
11
|
-
end
|
12
|
-
|
13
|
-
# Capitalizes the first letter of each word in a string
|
14
|
-
#
|
15
|
-
# Example:
|
16
|
-
# >> 'This is a title'.titleize
|
17
|
-
# => 'This Is A Title'
|
18
|
-
#
|
19
|
-
def titleize
|
20
|
-
title = ''
|
21
|
-
self.split(' ').each {|s| title << s.capitalize + ' ' }
|
22
|
-
title
|
23
|
-
end
|
24
|
-
|
25
|
-
# Truncates by word count, not letter
|
26
|
-
#
|
27
|
-
# Example:
|
28
|
-
# >> 'One Two Three Four Five'.truncate 3
|
29
|
-
# => 'One Two Three...'
|
30
|
-
#
|
31
|
-
# Arguments:
|
32
|
-
# length (word count), end_string (attached to the end of a truncated string)
|
33
|
-
#
|
34
|
-
def truncate length = 100, end_string = '...'
|
35
|
-
return if self == nil
|
36
|
-
words = self.split()
|
37
|
-
words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|