Module: Rango
- Defined in:
- lib/rango/utils.rb,
lib/rango.rb,
lib/rango/gv.rb,
lib/rango/cli.rb,
lib/rango/mini.rb,
lib/rango/mailer.rb,
lib/rango/router.rb,
lib/rango/version.rb,
lib/rango/gv/router.rb,
lib/rango/gv/static.rb,
lib/rango/controller.rb,
lib/rango/exceptions.rb,
lib/rango/mini_render.rb,
lib/rango/environments.rb,
lib/rango/rack/request.rb,
lib/rango/mixins/logger.rb,
lib/rango/mixins/render.rb,
lib/rango/gv/scaffolding.rb,
lib/rango/mixins/filters.rb,
lib/rango/mixins/message.rb,
lib/rango/rest_controller.rb,
lib/rango/mixins/rendering.rb,
lib/rango/mixins/rack-flash.rb,
lib/rango/stacks/controller.rb,
lib/rango/mixins/action_args.rb,
lib/rango/router/adapters/usher.rb,
lib/rango/rack/middlewares/basic.rb,
lib/rango/rack/middlewares/basic.rb,
lib/rango/rack/middlewares/static.rb,
lib/rango/router/adapters/crudtree.rb,
lib/rango/rack/middlewares/encoding.rb,
lib/rango/contrib/pagination/helpers.rb,
lib/rango/router/adapters/rack_mount.rb,
lib/rango/router/adapters/http_router.rb,
lib/rango/contrib/pagination/strategies.rb,
lib/rango/mixins/conventional_rendering.rb,
lib/rango/contrib/pagination/adapters/sequel.rb,
lib/rango/contrib/pagination/adapters/datamapper.rb
Overview
Use with explicit or implicit rendering mixin
Defined Under Namespace
Modules: ActionArgsMixin, ConventionalRendering, Exceptions, ExplicitRendering, FiltersMixin, FormatMixin, GV, Helpers, ImplicitRendering, LoggerMixin, Mailing, MessageMixin, Middlewares, Mini, MiniRender, Pagination, RackDebug, RackFlashMixin, RenderMixin, Session, UrlHelper, Utils
Classes: Controller, RESTController, Request, Router, StackController
Constant Summary
collapse
- VERSION =
"0.2.6"
- @@bootloaders =
Hash.new
Class Method Summary
collapse
Class Method Details
.after_boot(name, &block) ⇒ Object
106
107
108
|
# File 'lib/rango.rb', line 106
def self.after_boot(name, &block)
self.bootloaders[name] = block
end
|
.boot(options = Hash.new, &block) ⇒ Boolean
Returns true if boot succeed or false if not. If ARGV includes “-i”, IRB interactive session will start.
86
87
88
89
90
91
92
93
|
# File 'lib/rango.rb', line 86
def self.boot(options = Hash.new, &block)
self.environment = options[:environment] if options[:environment]
block.call if block_given?
self.bootloaders.each do |name, bootloader|
bootloader.call
end
end
|
.bootloaders ⇒ Object
100
101
102
|
# File 'lib/rango.rb', line 100
def self.bootloaders
@@bootloaders
end
|
.development? ⇒ Boolean
19
20
21
|
# File 'lib/rango/environments.rb', line 19
def self.development?
self.environments[:development].include?(Rango.environment)
end
|
.environment ⇒ String
Basic environment support. Use rango/environments.rb for more advanced behaviour.
38
39
40
41
42
|
# File 'lib/rango.rb', line 38
def self.environment
@@environment
rescue NameError
self.set_environment
end
|
.environment=(environment) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/rango.rb', line 48
def self.environment=(environment)
ENV["RACK_ENV"] = environment
@@environment = environment
verbose, $VERBOSE = $VERBOSE, nil
const_set(:RACK_ENV, environment)
$VERBOSE = verbose
end
|
.environment?(environment) ⇒ Boolean
56
57
58
|
# File 'lib/rango.rb', line 56
def self.environment?(environment)
self.environment.eql?(environment.to_s)
end
|
.environments ⇒ Object
clever environments support
7
8
9
10
11
12
13
|
# File 'lib/rango/environments.rb', line 7
def self.environments
@@environments ||= {
development: ["development"],
testing: ["test", "spec", "cucumber"],
production: ["stagging", "production"]
}
end
|
.interactive ⇒ Object
Start IRB interactive session
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/rango/cli.rb', line 14
def self.interactive
require "irb"
require "rango/utils"
begin
require "racksh/boot"
rescue LoadError
Rango.logger.info("For more goodies install racksh gem")
else
Rango::Utils.load_rackup end
begin
require "irb/completion"
rescue LoadError
end
ARGV.delete("-i") IRB.start
end
|
.loaded?(relative_path) ⇒ Boolean
Rango.loaded?(“environments.rb”)
111
112
113
114
|
# File 'lib/rango.rb', line 111
def self.loaded?(relative_path) full_path = File.expand_path(File.join(File.dirname(__FILE__), relative_path))
$LOADED_FEATURES.any? { |file| file == full_path }
end
|
.logger ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/rango.rb', line 61
def self.logger
@@logger ||= begin
require "simple-logger"
SimpleLogger::Logger.new(STDOUT).tap do |logger|
logger.auto_flush = true end
rescue LoadError
require "logger"
Logger.new(STDOUT).tap do |logger|
logger.warn("Using stdlib logger. If you want something more fancy with colors and #flush, install simple-logger.")
end
end
end
|
.logger=(logger) ⇒ Object
75
76
77
78
|
# File 'lib/rango.rb', line 75
def self.logger=(logger)
require "rango/mixins/logger"
@@logger = logger.extend(LoggerMixin)
end
|
30
31
32
|
# File 'lib/rango.rb', line 30
def self.media_root
@@media_root ||= self.root.join("media")
end
|
26
27
28
|
# File 'lib/rango.rb', line 26
def self.media_root=(media_root)
@@media_root = Pathname.new(media_root)
end
|
.parse(args = ARGV) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/rango/cli.rb', line 4
def self.parse(args = ARGV)
return if args.empty?
Rango.interactive if ARGV.delete("-i")
load ARGV.shift if ARGV.first && File.exist?(ARGV.first) && ARGV.first.end_with?(".rb")
end
|
.path ⇒ Path
16
17
18
|
# File 'lib/rango/path.rb', line 16
def Rango.path
@path ||= MediaPath.new(self.root)
end
|
.production? ⇒ Boolean
23
24
25
|
# File 'lib/rango/environments.rb', line 23
def self.production?
self.environments[:production].include?(Rango.environment)
end
|
.reboot(options = Hash.new) ⇒ Object
96
97
98
|
# File 'lib/rango.rb', line 96
def self.reboot(options = Hash.new)
self.boot(options.merge(force: true))
end
|
.root ⇒ Object
22
23
24
|
# File 'lib/rango.rb', line 22
def self.root
@@root ||= Pathname.new(Dir.pwd)
end
|
.root=(root) ⇒ Object
18
19
20
|
# File 'lib/rango.rb', line 18
def self.root=(root)
@@root = Pathname.new(root)
end
|
.set_environment ⇒ Object
44
45
46
|
# File 'lib/rango.rb', line 44
def self.set_environment
@@environment ||= ENV["RACK_ENV"] || (RACK_ENV if defined?(RACK_ENV)) || "development"
end
|
.testing? ⇒ Boolean
15
16
17
|
# File 'lib/rango/environments.rb', line 15
def self.testing?
self.environments[:testing].include?(Rango.environment)
end
|