padrino-core 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -3
- data/VERSION +1 -1
- data/bin/padrino +4 -4
- data/lib/padrino-core/application.rb +8 -8
- data/lib/padrino-core/cli/base.rb +61 -45
- data/lib/padrino-core/cli/rake.rb +14 -9
- data/lib/padrino-core/logger.rb +1 -1
- data/lib/padrino-core/mounter.rb +1 -1
- data/padrino-core.gemspec +2 -3
- data/test/fixtures/apps/complex.rb +1 -1
- data/test/fixtures/apps/simple.rb +1 -1
- data/test/helper.rb +1 -1
- data/test/test_core.rb +1 -3
- metadata +2 -3
- data/lib/padrino-core/cli/test.rb +0 -20
data/README.rdoc
CHANGED
@@ -430,15 +430,21 @@ The following commands are available:
|
|
430
430
|
# Stops a daemonized app server
|
431
431
|
$ padrino stop
|
432
432
|
|
433
|
-
# Run all the unit tests
|
434
|
-
$ padrino test
|
435
|
-
|
436
433
|
# Bootup the Padrino console (irb)
|
437
434
|
$ padrino console
|
438
435
|
|
439
436
|
# Run/List tasks
|
440
437
|
$ padrino rake
|
441
438
|
|
439
|
+
The last command "padrino rake" look for rake files in:
|
440
|
+
|
441
|
+
lib/tasks/**/*.rake
|
442
|
+
tasks/**/*.rake
|
443
|
+
test/test.rake
|
444
|
+
spec/spec.rake
|
445
|
+
|
446
|
+
In this way you can customize project tasks.
|
447
|
+
|
442
448
|
Using these commands can simplify common tasks making development that much smoother.
|
443
449
|
|
444
450
|
=== Special Folders
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.2
|
data/bin/padrino
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require 'rubygems'
|
3
3
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
4
4
|
|
5
|
-
require
|
6
|
-
|
7
|
-
Padrino::Cli::Base.start(
|
5
|
+
require 'padrino-core/cli/base'
|
6
|
+
|
7
|
+
Padrino::Cli::Base.start(ARGV)
|
@@ -14,7 +14,7 @@ module Padrino
|
|
14
14
|
Padrino.set_load_paths File.join(subclass.root, "/models")
|
15
15
|
Padrino.require_dependencies File.join(subclass.root, "/models.rb")
|
16
16
|
Padrino.require_dependencies File.join(subclass.root, "/models/**/*.rb")
|
17
|
-
super # Loading the subclass
|
17
|
+
super(subclass) # Loading the subclass
|
18
18
|
subclass.default_filters!
|
19
19
|
subclass.default_routes!
|
20
20
|
subclass.default_errors!
|
@@ -28,7 +28,7 @@ module Padrino
|
|
28
28
|
#
|
29
29
|
def new(*args, &bk)
|
30
30
|
setup_application!
|
31
|
-
super
|
31
|
+
super(*args, &bk)
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
@@ -115,7 +115,7 @@ module Padrino
|
|
115
115
|
# Padrino look for your/app/views/layouts/custom.(haml|erb|etc)
|
116
116
|
#
|
117
117
|
def layout(name=:layout, &block)
|
118
|
-
return super if block_given?
|
118
|
+
return super(name, &block) if block_given?
|
119
119
|
@_layout = name
|
120
120
|
end
|
121
121
|
|
@@ -169,7 +169,7 @@ module Padrino
|
|
169
169
|
def default_configuration!
|
170
170
|
# Overwriting Sinatra defaults
|
171
171
|
set :app_file, caller_files.first || $0 # Assume app file is first caller
|
172
|
-
set :environment,
|
172
|
+
set :environment, Padrino.env
|
173
173
|
set :raise_errors, true if development?
|
174
174
|
set :logging, false # !test?
|
175
175
|
set :sessions, true
|
@@ -381,9 +381,9 @@ module Padrino
|
|
381
381
|
unbound_method = instance_method("#{verb} #{path}")
|
382
382
|
block =
|
383
383
|
if block.arity != 0
|
384
|
-
|
384
|
+
proc { unbound_method.bind(self).call(*@block_params) }
|
385
385
|
else
|
386
|
-
|
386
|
+
proc { unbound_method.bind(self).call }
|
387
387
|
end
|
388
388
|
|
389
389
|
invoke_hook(:route_added, verb, path, block)
|
@@ -499,7 +499,7 @@ module Padrino
|
|
499
499
|
I18n.locale = params[:locale].to_sym rescue options.locale
|
500
500
|
end
|
501
501
|
end
|
502
|
-
super
|
502
|
+
super(&block)
|
503
503
|
end
|
504
504
|
|
505
505
|
##
|
@@ -528,7 +528,7 @@ module Padrino
|
|
528
528
|
logger.debug "Rendering layout #{options[:layout]}"
|
529
529
|
end
|
530
530
|
end
|
531
|
-
super
|
531
|
+
super(engine, data, options, locals, &block)
|
532
532
|
end
|
533
533
|
|
534
534
|
##
|
@@ -1,26 +1,25 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'thor/rake_compat'
|
3
2
|
|
4
3
|
module Padrino
|
5
4
|
module Cli
|
5
|
+
|
6
6
|
class Base < Thor
|
7
7
|
include Thor::Actions
|
8
8
|
include Thor::RakeCompat
|
9
9
|
|
10
|
-
class_option :chdir, :type => :string, :aliases => "-c"
|
10
|
+
class_option :chdir, :type => :string, :aliases => "-c", :desc => "Change to dir before starting"
|
11
|
+
class_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development, :desc => "Padrino Environment"
|
12
|
+
class_option :help, :type => :boolean, :desc => "Show help usage"
|
11
13
|
|
12
14
|
desc "start", "Starts the Padrino application"
|
13
|
-
method_option :
|
14
|
-
method_option :
|
15
|
-
method_option :
|
16
|
-
method_option :
|
17
|
-
method_option :boot, :type => :string, :aliases => "-b", :required => true, :default => "config/boot.rb"
|
18
|
-
method_option :daemonize, :type => :boolean, :aliases => "-d"
|
15
|
+
method_option :adapter, :type => :string, :aliases => "-a", :desc => "Rack Handler (default: autodetect)"
|
16
|
+
method_option :host, :type => :string, :aliases => "-h", :required => true, :default => "localhost", :desc => "Bind to HOST address"
|
17
|
+
method_option :port, :type => :numeric, :aliases => "-p", :required => true, :default => 3000, :desc => "Use PORT"
|
18
|
+
method_option :daemonize, :type => :boolean, :aliases => "-d", :desc => "Run daemonized in the background"
|
19
19
|
def start
|
20
|
+
prepare :start
|
20
21
|
require File.dirname(__FILE__) + "/adapter"
|
21
|
-
boot
|
22
|
-
return unless boot
|
23
|
-
require boot
|
22
|
+
require 'config/boot'
|
24
23
|
Padrino::Cli::Adapter.start(options)
|
25
24
|
end
|
26
25
|
|
@@ -30,58 +29,63 @@ module Padrino
|
|
30
29
|
Padrino::Cli::Adapter.stop
|
31
30
|
end
|
32
31
|
|
33
|
-
desc "
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
desc "rake", "Execute rake tasks"
|
33
|
+
method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
|
34
|
+
method_option :list, :type => :string, :aliases => "-T", :desc => "Display the tasks (matching optional PATTERN) with descriptions, then exit."
|
35
|
+
method_option :trace, :type => :boolean, :aliases => "-t", :desc => "Turn on invoke/execute tracing, enable full backtrace."
|
36
|
+
method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Log message to standard output."
|
37
|
+
def rake(*args)
|
38
|
+
prepare :rake
|
39
|
+
args << "-T" if options[:list]
|
40
|
+
args << options[:list] unless options[:list].nil? || options[:list].to_s == "list"
|
41
|
+
args << "--trace" if options[:trace]
|
42
|
+
args << "--verbose" if options[:verbose]
|
43
|
+
ARGV.clear
|
44
|
+
ARGV.concat(args)
|
45
|
+
puts "=> Executing Rake #{ARGV.join(' ')} ..."
|
44
46
|
ENV['PADRINO_LOG_LEVEL'] ||= "test"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
require boot
|
49
|
-
puts "=> Executing Rake..."
|
50
|
-
Rake.application.init
|
51
|
-
load(File.dirname(__FILE__) + "/rake.rb")
|
52
|
-
Rake.application.top_level
|
47
|
+
require File.dirname(__FILE__) + '/rake'
|
48
|
+
silence(:stdout) { require 'config/boot' }
|
49
|
+
PadrinoTasks.init
|
53
50
|
end
|
54
51
|
|
55
52
|
desc "console", "Boots up the Padrino application irb console"
|
56
|
-
method_option :boot, :type => :string, :aliases => "-b", :required => true, :default => "config/boot.rb"
|
57
|
-
method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
|
58
53
|
def console
|
54
|
+
prepare :console
|
59
55
|
require File.dirname(__FILE__) + "/../version"
|
60
|
-
boot = check_boot
|
61
|
-
return unless boot
|
62
56
|
ARGV.clear
|
63
57
|
puts "=> Loading #{options.environment} console (Padrino v.#{Padrino.version})"
|
64
58
|
require 'irb'
|
65
59
|
require "irb/completion"
|
66
|
-
require boot
|
60
|
+
require 'config/boot'
|
67
61
|
require File.dirname(__FILE__) + '/console'
|
68
62
|
IRB.start
|
69
63
|
end
|
70
64
|
|
65
|
+
desc "version", "Show current Padrino Version"
|
66
|
+
map "-v" => :version, "--version" => :version
|
67
|
+
def version
|
68
|
+
require 'padrino-core/version'
|
69
|
+
puts "Padrino v. #{Padrino.version}"
|
70
|
+
end
|
71
|
+
|
71
72
|
private
|
72
|
-
def
|
73
|
+
def prepare(task)
|
74
|
+
if options.help?
|
75
|
+
help(task.to_s)
|
76
|
+
raise SystemExit
|
77
|
+
end
|
73
78
|
ENV["PADRINO_ENV"] ||= options.environment.to_s
|
74
79
|
chdir(options.chdir)
|
75
|
-
unless File.exist?(
|
76
|
-
puts "=> Could not find boot file: #{options.boot.
|
77
|
-
|
80
|
+
unless File.exist?('config/boot.rb')
|
81
|
+
puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
|
82
|
+
raise SystemExit
|
78
83
|
end
|
79
|
-
options.boot
|
80
84
|
end
|
81
85
|
|
82
86
|
protected
|
83
87
|
def self.banner(task)
|
84
|
-
"padrino
|
88
|
+
"padrino #{task.name}"
|
85
89
|
end
|
86
90
|
|
87
91
|
def chdir(dir)
|
@@ -89,13 +93,25 @@ module Padrino
|
|
89
93
|
begin
|
90
94
|
Dir.chdir(dir.to_s)
|
91
95
|
rescue Errno::ENOENT
|
92
|
-
puts "=> Specified Padrino root '#{dir}' "
|
93
|
-
"does not appear to exist!"
|
96
|
+
puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
|
94
97
|
rescue Errno::EACCES
|
95
|
-
puts "=> Specified Padrino root '#{dir}' "
|
96
|
-
"cannot be accessed by the current user!"
|
98
|
+
puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
|
97
99
|
end
|
98
100
|
end
|
101
|
+
|
102
|
+
def capture(stream)
|
103
|
+
begin
|
104
|
+
stream = stream.to_s
|
105
|
+
eval "$#{stream} = StringIO.new"
|
106
|
+
yield
|
107
|
+
result = eval("$#{stream}").string
|
108
|
+
ensure
|
109
|
+
eval("$#{stream} = #{stream.upcase}")
|
110
|
+
end
|
111
|
+
|
112
|
+
result
|
113
|
+
end
|
114
|
+
alias :silence :capture
|
99
115
|
end # Base
|
100
116
|
end # Cli
|
101
117
|
end # Padrino
|
@@ -1,22 +1,27 @@
|
|
1
|
-
require 'rake'
|
2
1
|
require File.dirname(__FILE__) + '/../tasks'
|
2
|
+
require 'rake'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
Rake.application.instance_variable_set(:@rakefile, __FILE__)
|
5
|
+
|
6
|
+
module PadrinoTasks
|
7
|
+
def self.init
|
8
|
+
Padrino::Tasks.files.flatten.uniq.each { |ext| load(ext) }
|
9
|
+
Rake.application.init
|
10
|
+
Rake.application.top_level
|
11
|
+
end
|
12
|
+
end
|
6
13
|
|
7
14
|
def shell
|
8
15
|
@_shell ||= Thor::Shell::Basic.new
|
9
16
|
end
|
10
17
|
|
18
|
+
Dir["lib/tasks/**/*.rake"].
|
19
|
+
concat(Dir["tasks/**/*.rake"]).
|
20
|
+
concat(Dir["{test,spec}/*.rake"]).each { |ext| load(ext) }
|
21
|
+
|
11
22
|
task :environment do
|
12
23
|
Padrino.mounted_apps.each do |app|
|
13
24
|
Padrino.require_dependency(app.app_file)
|
14
25
|
app.app_object.setup_application!
|
15
26
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'Load the seed data from db/seeds.rb'
|
19
|
-
task :seed => :environment do
|
20
|
-
seed_file = Padrino.root('db', 'seeds.rb')
|
21
|
-
load(seed_file) if File.exist?(seed_file)
|
22
27
|
end
|
data/lib/padrino-core/logger.rb
CHANGED
@@ -82,7 +82,7 @@ module Padrino
|
|
82
82
|
:production => { :log_level => :warn, :stream => :to_file },
|
83
83
|
:development => { :log_level => :debug, :stream => :stdout },
|
84
84
|
:test => { :log_level => :debug, :stream => :null }
|
85
|
-
}
|
85
|
+
}
|
86
86
|
|
87
87
|
##
|
88
88
|
# Setup a new logger
|
data/lib/padrino-core/mounter.rb
CHANGED
@@ -43,7 +43,7 @@ module Padrino
|
|
43
43
|
builder.map self.uri_root do
|
44
44
|
app_obj.set :uri_root, app_data.uri_root
|
45
45
|
app_obj.set :app_name, app_data.name
|
46
|
-
app_obj.set :app_file, app_data.app_file unless File.exist?(app_obj.app_file)
|
46
|
+
app_obj.set :app_file, app_data.app_file unless ::File.exist?(app_obj.app_file)
|
47
47
|
app_obj.set :root, app_data.app_root unless app_data.app_root.blank?
|
48
48
|
# We need to initialize here the app.
|
49
49
|
app_obj.setup_application!
|
data/padrino-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{padrino-core}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-17}
|
13
13
|
s.default_executable = %q{padrino}
|
14
14
|
s.description = %q{The Padrino core gem required for use of this framework}
|
15
15
|
s.email = %q{padrinorb@gmail.com}
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/padrino-core/cli/base.rb",
|
33
33
|
"lib/padrino-core/cli/console.rb",
|
34
34
|
"lib/padrino-core/cli/rake.rb",
|
35
|
-
"lib/padrino-core/cli/test.rb",
|
36
35
|
"lib/padrino-core/images/404.png",
|
37
36
|
"lib/padrino-core/images/500.png",
|
38
37
|
"lib/padrino-core/loader.rb",
|
data/test/helper.rb
CHANGED
data/test/test_core.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2010-02-
|
15
|
+
date: 2010-02-17 00:00:00 +01:00
|
16
16
|
default_executable: padrino
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -138,7 +138,6 @@ files:
|
|
138
138
|
- lib/padrino-core/cli/base.rb
|
139
139
|
- lib/padrino-core/cli/console.rb
|
140
140
|
- lib/padrino-core/cli/rake.rb
|
141
|
-
- lib/padrino-core/cli/test.rb
|
142
141
|
- lib/padrino-core/images/404.png
|
143
142
|
- lib/padrino-core/images/500.png
|
144
143
|
- lib/padrino-core/loader.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Padrino
|
2
|
-
module Cli
|
3
|
-
module Test
|
4
|
-
class << self
|
5
|
-
|
6
|
-
# This method executes tests found for the given app.
|
7
|
-
# It look for any spec/*_spec.rb and test/test_*.rb files in your app root.
|
8
|
-
def start
|
9
|
-
puts "=> Executing Tests..."
|
10
|
-
tests = Dir['test/**/test_*.rb'] - ['test/test_helper.rb'] # TestUnit
|
11
|
-
tests << Dir['test/**/*_test.rb'] - ['test/test_config.rb'] # Bacon
|
12
|
-
tests << Dir['spec/**/*_spec.rb'] - Dir['spec/**/spec_helper.rb'] # Rspec
|
13
|
-
cmd = "ruby -rubygems -I.:lib -e'%w( #{tests.join(' ')} ).each { |file| require file }'"
|
14
|
-
system cmd
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|