-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.rb
executable file
·48 lines (44 loc) · 920 Bytes
/
common.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'rubygems'
require 'dm-core'
require 'dm-validations'
require 'dm-migrations'
def nil.blank?
true
end
class String
def blank?
self == ''
end
end
# fix required for bug with DataMapper 1.1.0 and Ruby 1.8.6
module Enumerable
unless instance_methods.include?("first")
def first(num = nil)
if num == nil
holder = nil
catch(:got_element) do
each do |e|
holder = e
throw(:got_element)
end
end
holder
else
holder = []
catch(:got_elements) do
each do |e|
holder << e
throw(:got_element) if num == 0
num -= 1
end
end
holder
end
end
end
end
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/db_celtxstamp.sqlite3")
require './models/stamp'
require './models/user'
require './models/thumbsample'
DataMapper.auto_upgrade!