yodatra 0.1.0 → 0.1.1

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/yodatra/boot.rb CHANGED
@@ -19,14 +19,23 @@ module Yodatra
19
19
  if app.booting
20
20
  # ActiveRecord
21
21
  app.register Sinatra::ActiveRecordExtension
22
+ sinatra_ar_version = Gem.loaded_specs['sinatra-activerecord'].version.to_s
23
+ if sinatra_ar_version.gsub('\.', '') <= '123'
24
+ app.set :database_file, "#{Dir.pwd}/config/database.yml"
25
+ else
26
+ app.logger.warn("check out the new version (#{sinatra_ar_version}) of sinatra-activerecord, does it include PR#19 ?") if app.logger
27
+ end
28
+
22
29
  # Models
23
30
  Dir["#{app.models_directory}/**/*.rb"].sort.each do |file_path|
24
31
  require File.expand_path file_path
25
32
  end
33
+
26
34
  # Controllers
27
35
  Dir["#{app.controllers_directory}/**/*.rb"].sort.each do |file_path|
28
36
  require File.expand_path file_path
29
37
  end
38
+
30
39
  app.set :booting, false
31
40
  app.set :booted, true
32
41
  end
@@ -0,0 +1,20 @@
1
+ require 'sinatra/logger'
2
+
3
+ module Yodatra
4
+ module Logger
5
+ def self.registered(app)
6
+ filename = File.join(Dir.pwd, 'log', "#{app.environment}.log")
7
+ app.configure do
8
+ app.enable :logging
9
+ file = File.new(filename, 'a+')
10
+ file.sync = true
11
+ app.use Rack::CommonLogger, file
12
+ end
13
+ app.register Sinatra::Logger
14
+ app.set :logger_level, :debug unless app.environment == 'production'
15
+ # set the full path to the log file
16
+ app.set :logger_log_file, lambda { filename }
17
+
18
+ end #/ self.registered
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Yodatra
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/yodatra.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new 'yodatra', Yodatra::VERSION do |s|
16
16
  s.add_dependency 'rack', '~> 1.4'
17
17
  s.add_dependency 'sinatra', '~> 1.4.4', '>= 1.4.4'
18
18
  s.add_dependency 'sinatra-activerecord'
19
+ s.add_dependency 'sinatra-logger'
19
20
  s.add_dependency 'sinatra-contrib', '~> 1.4.2', '>= 1.4.2'
20
21
  s.add_dependency 'rack-protection', '~> 1.4'
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yodatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -65,6 +65,22 @@ dependencies:
65
65
  - - ! '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: sinatra-logger
70
+ requirement: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
68
84
  - !ruby/object:Gem::Dependency
69
85
  name: sinatra-contrib
70
86
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +134,7 @@ files:
118
134
  - lib/yodatra/base.rb
119
135
  - lib/yodatra/boot.rb
120
136
  - lib/yodatra/initializers.rb
137
+ - lib/yodatra/logger.rb
121
138
  - lib/yodatra/version.rb
122
139
  - yodatra.gemspec
123
140
  homepage: http://squareteam.github.io/yodatra