oasis 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/oasis.rb +1 -1
- data/lib/oasis/app/loader.rb +1 -1
- data/lib/oasis/dependencies.rb +7 -7
- data/lib/oasis/logger.rb +40 -0
- data/lib/oasis/routes.rb +1 -1
- data/lib/oasis/version.rb +1 -1
- data/test/helper.rb +1 -1
- metadata +3 -3
- data/lib/oasis/debug.rb +0 -9
data/lib/oasis.rb
CHANGED
data/lib/oasis/app/loader.rb
CHANGED
@@ -7,7 +7,7 @@ module Oasis
|
|
7
7
|
def register_plugin_as_loaded_with_oasis(plugin)
|
8
8
|
register_plugin_as_loaded_without_oasis(plugin)
|
9
9
|
Oasis.apps << plugin if plugin.engine?
|
10
|
-
Oasis::
|
10
|
+
Oasis::Logger.trace "Loading Rails App: #{plugin.name}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.included(base)
|
data/lib/oasis/dependencies.rb
CHANGED
@@ -17,20 +17,20 @@ module Oasis
|
|
17
17
|
# if they are suffixed with helper or controller.
|
18
18
|
if file_name =~ /_(helper|controller)?$/
|
19
19
|
type = file_name.split("_").last
|
20
|
-
Oasis::
|
20
|
+
Oasis::Logger.trace "searching for #{type} named '#{file_name}'"
|
21
21
|
Oasis.apps.each do |app|
|
22
22
|
plugin_file_name = File.expand_path(File.join(app.directory, "app", "#{type}s", base_name))
|
23
|
-
Oasis::
|
23
|
+
Oasis::Logger.trace "checking engine '#{app.name}' for '#{file_name}' (#{plugin_file_name})"
|
24
24
|
break if File.file? "#{plugin_file_name}.rb"
|
25
25
|
end
|
26
26
|
|
27
27
|
else
|
28
28
|
|
29
29
|
# if we didn't find it in helpers or controllers, lets try looking in models.
|
30
|
-
Oasis::
|
30
|
+
Oasis::Logger.trace "searching for models named '#{file_name}'"
|
31
31
|
Oasis.apps.each do |app|
|
32
32
|
plugin_file_name = File.expand_path(File.join(app.directory, "app", "models", base_name))
|
33
|
-
Oasis::
|
33
|
+
Oasis::Logger.trace "checking engine '#{app.name}' for '#{file_name}' (#{plugin_file_name})"
|
34
34
|
break if File.file? "#{plugin_file_name}.rb"
|
35
35
|
end
|
36
36
|
|
@@ -38,16 +38,16 @@ module Oasis
|
|
38
38
|
|
39
39
|
# success! we've found code in the engine, lets load it.
|
40
40
|
if File.file?("#{plugin_file_name}.rb")
|
41
|
-
Oasis::
|
41
|
+
Oasis::Logger.debug "loading '#{file_name}' from an engine."
|
42
42
|
file_loaded = true if super(plugin_file_name, const_path)
|
43
43
|
end
|
44
44
|
|
45
45
|
app_file_name = File.join(RAILS_ROOT, "app", "#{type||"model"}s", base_name)
|
46
46
|
if File.file? "#{app_file_name}.rb"
|
47
|
-
Oasis::
|
47
|
+
Oasis::Logger.trace "loading from application: #{file_name}"
|
48
48
|
file_loaded = true if super(app_file_name, const_path)
|
49
49
|
else
|
50
|
-
Oasis::
|
50
|
+
Oasis::Logger.trace "file '#{file_name}' not found in application"
|
51
51
|
end
|
52
52
|
|
53
53
|
# if we managed to load a file, return true. If not, default to the original method.
|
data/lib/oasis/logger.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Oasis
|
2
|
+
class Logger
|
3
|
+
LOG_LEVELS = {
|
4
|
+
:trace => 1,
|
5
|
+
:debug => 2,
|
6
|
+
:warn => 3
|
7
|
+
}.freeze
|
8
|
+
RAILS_LOG_METHOD = {
|
9
|
+
:trace => :debug,
|
10
|
+
:debug => :debug,
|
11
|
+
:warn => :warn
|
12
|
+
}.freeze
|
13
|
+
class << self
|
14
|
+
def level
|
15
|
+
@level || :warn
|
16
|
+
end
|
17
|
+
def level=(v)
|
18
|
+
unless LOG_LEVELS.has_key?(v)
|
19
|
+
errmsg = "#{v.inspect} is not a log level. Please use one of #{LOG_LEVELS.keys.map(&:inspect).join(", ")}"
|
20
|
+
raise ArgumentError, errmsg
|
21
|
+
end
|
22
|
+
@level = v
|
23
|
+
end
|
24
|
+
def trace(msg); log(msg, :trace); end
|
25
|
+
def debug(msg); log(msg, :debug); end
|
26
|
+
def warn(msg); log(msg, :warn); end
|
27
|
+
def log(msg, level)
|
28
|
+
return unless LOG_LEVELS[level] >= LOG_LEVELS[self.level]
|
29
|
+
msg = "** [OASIS] : #{msg}"
|
30
|
+
if defined?(Rails)
|
31
|
+
Rails.logger.send(RAILS_LOG_METHOD[level], msg)
|
32
|
+
elsif defined?(RAILS_DEFAULT_LOGGER)
|
33
|
+
RAILS_DEFAULT_LOGGER.send(RAILS_LOG_METHOD[level], msg)
|
34
|
+
else
|
35
|
+
$stderr.puts msg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/oasis/routes.rb
CHANGED
data/lib/oasis/version.rb
CHANGED
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oasis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Perez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-02-08 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -42,11 +42,11 @@ files:
|
|
42
42
|
- lib/oasis/app/list.rb
|
43
43
|
- lib/oasis/app/loader.rb
|
44
44
|
- lib/oasis/configure.rb
|
45
|
-
- lib/oasis/debug.rb
|
46
45
|
- lib/oasis/dependencies.rb
|
47
46
|
- lib/oasis/development.rb
|
48
47
|
- lib/oasis/layout.rb
|
49
48
|
- lib/oasis/loader.rb
|
49
|
+
- lib/oasis/logger.rb
|
50
50
|
- lib/oasis/routes.rb
|
51
51
|
- lib/oasis/version.rb
|
52
52
|
- oasis.gemspec
|