padrino-core 0.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/padrino-core.rb +30 -0
- data/lib/padrino-core/application.rb +108 -0
- data/lib/padrino-core/loader.rb +39 -0
- data/lib/padrino-core/mounter.rb +37 -0
- data/lib/padrino-core/support_lite.rb +8 -0
- data/padrino-core.gemspec +84 -0
- data/test/active_support_helpers.rb +7 -0
- data/test/fixtures/extended_app/app.rb +10 -0
- data/test/fixtures/simple_app/app.rb +10 -0
- data/test/helper.rb +74 -0
- data/test/test_padrino_core.rb +17 -0
- data/test/test_padrino_mounting.rb +8 -0
- metadata +150 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Padrino
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "padrino-core"
|
8
|
+
gem.summary = "The required Padrino core gem"
|
9
|
+
gem.description = "The Padrino core gem required for use of this framework"
|
10
|
+
gem.email = "nesquena@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/padrino/padrino-core"
|
12
|
+
gem.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
13
|
+
gem.add_runtime_dependency "sinatra", ">= 0.9.2"
|
14
|
+
gem.add_runtime_dependency "thor", ">= 0.11.8"
|
15
|
+
gem.add_development_dependency "haml", ">= 2.2.1"
|
16
|
+
gem.add_development_dependency "shoulda", ">= 0"
|
17
|
+
gem.add_development_dependency "mocha", ">= 0.9.7"
|
18
|
+
gem.add_development_dependency "rack-test", ">= 0.5.0"
|
19
|
+
gem.add_development_dependency "webrat", ">= 0.5.1"
|
20
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
+
end
|
22
|
+
Jeweler::GemcutterTasks.new
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
task :rcov do
|
43
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
task :test => :check_dependencies
|
48
|
+
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rake/rdoctask'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "padrino-core #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/padrino-core.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
Dir[File.dirname(__FILE__) + '/padrino-core/**/*.rb'].each {|file| require file }
|
3
|
+
|
4
|
+
# Defines our PADRINO_ENV
|
5
|
+
PADRINO_ENV = ENV["PADRINO_ENV"] ||= ENV["RACK_ENV"] ||= "development" unless defined?(PADRINO_ENV)
|
6
|
+
|
7
|
+
module Padrino
|
8
|
+
# Helper method for file references.
|
9
|
+
#
|
10
|
+
# @param args [Array] Path components relative to ROOT_DIR.
|
11
|
+
# @example Referencing a file in config called settings.yml:
|
12
|
+
# Padrino.root("config", "settings.yml")
|
13
|
+
def self.root(*args)
|
14
|
+
File.join(PADRINO_ROOT, *args)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the prepared rack application mapping each 'mounted' application
|
18
|
+
def self.application
|
19
|
+
Rack::Builder.new do
|
20
|
+
Padrino.mounted_apps.each do |app|
|
21
|
+
map app.uri_root do
|
22
|
+
require app.app_file
|
23
|
+
app.klass.constantize.set :uri_root, app.uri_root
|
24
|
+
run app.klass.constantize
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Padrino
|
2
|
+
# Subclasses of this become independent Padrino applications (stemming from Sinatra::Application)
|
3
|
+
# These subclassed applications can be easily mounted into other Padrino applications as well.
|
4
|
+
class Application < Sinatra::Application
|
5
|
+
|
6
|
+
def logger
|
7
|
+
@log_stream ||= self.class.log_to_file? ? Padrino.root("log/#{PADRINO_ENV.downcase}.log") : $stdout
|
8
|
+
@logger ||= Logger.new(@log_stream)
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def inherited(subclass)
|
13
|
+
subclass.default_configuration!
|
14
|
+
super # Loading the subclass
|
15
|
+
end
|
16
|
+
|
17
|
+
# Hooks into when a new instance of the application is created
|
18
|
+
# This is used because putting the configuration into inherited doesn't
|
19
|
+
# take into account overwritten app settings inside subclassed definitions
|
20
|
+
# Only performs the setup first time application is initialized
|
21
|
+
def new(*args, &bk)
|
22
|
+
setup_application!
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
# Makes the routes defined in the block and in the Modules given
|
27
|
+
# in `extensions` available to the application
|
28
|
+
def controllers(*extensions, &block)
|
29
|
+
instance_eval(&block) if block_given?
|
30
|
+
include(*extensions) if extensions.any?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Makes the urls defined in the block and in the Modules given
|
34
|
+
# in `extensions` available to the application
|
35
|
+
def urls(*extensions, &block)
|
36
|
+
instance_eval(&block) if block_given?
|
37
|
+
include(*extensions) if extensions.any?
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
# Setup the application by registering initializers, load paths and logger
|
43
|
+
# Invoked automatically when an application instance is created
|
44
|
+
def setup_application!
|
45
|
+
return if @configured
|
46
|
+
self.register_initializers
|
47
|
+
self.register_framework_extensions
|
48
|
+
self.require_load_paths
|
49
|
+
self.setup_logger
|
50
|
+
@configured = true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Defines default settings for Padrino application
|
54
|
+
def default_configuration!
|
55
|
+
# Overwriting Sinatra defaults
|
56
|
+
set :raise_errors, true if development?
|
57
|
+
set :logging, true
|
58
|
+
set :sessions, true
|
59
|
+
set :log_to_file, !development?
|
60
|
+
# Padrino specific
|
61
|
+
set :app_name, self.to_s.underscore.to_sym
|
62
|
+
set :app_file, Padrino.mounted_root(self.app_name.to_s, "/app.rb")
|
63
|
+
set :environment, PADRINO_ENV.to_sym
|
64
|
+
set :images_path, self.public + "/images"
|
65
|
+
set :default_builder, 'StandardFormBuilder'
|
66
|
+
enable :flash
|
67
|
+
# Plugin specific
|
68
|
+
enable :padrino_helpers
|
69
|
+
end
|
70
|
+
|
71
|
+
# Requires the middleware and initializer modules to configure components
|
72
|
+
def register_initializers
|
73
|
+
use Rack::Session::Cookie
|
74
|
+
use Rack::Flash if flash?
|
75
|
+
Dir[Padrino.root + '/config/initializers/*.rb'].each do |file|
|
76
|
+
Padrino.load_dependencies(file)
|
77
|
+
file_class = File.basename(file, '.rb').classify
|
78
|
+
register "#{file_class}Initializer".constantize
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Registers all desired padrino extension helpers/routing
|
83
|
+
def register_framework_extensions
|
84
|
+
register Padrino::Helpers if padrino_helpers?
|
85
|
+
register Padrino::Routing
|
86
|
+
end
|
87
|
+
|
88
|
+
# Require all files within the application's load paths
|
89
|
+
def require_load_paths
|
90
|
+
load_paths.each { |path| Padrino.load_dependencies(File.join(self.root, path)) }
|
91
|
+
end
|
92
|
+
|
93
|
+
# Creates the log directory and redirects output to file if needed
|
94
|
+
def setup_logger
|
95
|
+
return unless self.log_to_file?
|
96
|
+
FileUtils.mkdir_p 'log' unless File.exists?('log')
|
97
|
+
log = File.new("log/#{PADRINO_ENV.downcase}.log", "a+")
|
98
|
+
$stdout.reopen(log)
|
99
|
+
$stderr.reopen(log)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns the load_paths for the application relative to the application root
|
103
|
+
def load_paths
|
104
|
+
@load_paths ||= ["models/*.rb", "urls.rb", "controllers/*.rb", "helpers/*.rb"]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Padrino
|
2
|
+
class << self
|
3
|
+
# Requires necessary dependencies as well as application files from root lib and models
|
4
|
+
def load!
|
5
|
+
load_required_gems # load bundler gems
|
6
|
+
load_dependencies("#{root}/lib/**/*.rb", "#{root}/models/*.rb") # load root app dependencies
|
7
|
+
end
|
8
|
+
|
9
|
+
# Attempts to load/require all dependency libs that we need.
|
10
|
+
#
|
11
|
+
# @param paths [Array] Path where is necessary require or load a dependency
|
12
|
+
# @example For load all our app libs we need to do:
|
13
|
+
# load_dependencies("#{Padrino.root}/lib/**/*.rb")
|
14
|
+
def load_dependencies(*paths)
|
15
|
+
paths.each do |path|
|
16
|
+
Dir[path].each { |file| require(file) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Attempts to require all dependencies with bundler; if fails, we try to use system wide gems
|
21
|
+
def load_required_gems
|
22
|
+
begin
|
23
|
+
require 'bundler'
|
24
|
+
gemfile_path = root("Gemfile")
|
25
|
+
puts ">> Loading GemFile #{gemfile_path}"
|
26
|
+
Bundler::Environment.load(gemfile_path).require_env(PADRINO_ENV)
|
27
|
+
rescue Bundler::DefaultManifestNotFound => e
|
28
|
+
puts ">> You didn't create Bundler Gemfile manifest or you are not in a Sinatra application."
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require root('/../vendor', 'gems', PADRINO_ENV)
|
33
|
+
puts ">> Using bundled gems"
|
34
|
+
rescue LoadError => e
|
35
|
+
puts ">> Using system wide gems (No bundled gems)"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Padrino
|
2
|
+
# Represents a particular mounted padrino application
|
3
|
+
# Stores the name of the application (app folder name) and url mount path
|
4
|
+
# @example MountedApplication.new("blog_app").to("/blog")
|
5
|
+
class MountedApplication
|
6
|
+
attr_accessor :name, :uri_root, :app_file, :klass
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@klass = name.classify
|
10
|
+
end
|
11
|
+
|
12
|
+
# registers the mounted application to Padrino
|
13
|
+
def to(mount_url)
|
14
|
+
@app_file = Padrino.mounted_root(name, "app.rb")
|
15
|
+
@uri_root = mount_url
|
16
|
+
Padrino.mounted_apps << self
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
# Returns the root to the mounted apps base directory
|
22
|
+
def mounted_root(*args)
|
23
|
+
File.join(Padrino.root, "apps", *args)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the mounted padrino applications (MountedApp objects)
|
27
|
+
def mounted_apps
|
28
|
+
@mounted_apps ||= []
|
29
|
+
end
|
30
|
+
|
31
|
+
# Mounts a new sub-application onto Padrino
|
32
|
+
# @example Padrino.mount("blog_app").to("/blog")
|
33
|
+
def mount(name)
|
34
|
+
MountedApplication.new(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# This is for adding specific methods that are required by padrino if activesupport isn't required
|
2
|
+
unless String.method_defined?(:titleize) && Hash.method_defined?(:slice)
|
3
|
+
require 'active_support/inflector'
|
4
|
+
require 'active_support/core_ext/blank'
|
5
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
6
|
+
require 'active_support/core_ext/hash'
|
7
|
+
require 'active_support/core_ext/array'
|
8
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{padrino-core}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
+
s.date = %q{2009-11-16}
|
13
|
+
s.description = %q{The Padrino core gem required for use of this framework}
|
14
|
+
s.email = %q{nesquena@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/padrino-core.rb",
|
27
|
+
"lib/padrino-core/application.rb",
|
28
|
+
"lib/padrino-core/loader.rb",
|
29
|
+
"lib/padrino-core/mounter.rb",
|
30
|
+
"lib/padrino-core/support_lite.rb",
|
31
|
+
"padrino-core.gemspec",
|
32
|
+
"test/active_support_helpers.rb",
|
33
|
+
"test/fixtures/extended_app/app.rb",
|
34
|
+
"test/fixtures/simple_app/app.rb",
|
35
|
+
"test/helper.rb",
|
36
|
+
"test/test_padrino_core.rb",
|
37
|
+
"test/test_padrino_mounting.rb"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/padrino/padrino-core}
|
40
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = %q{1.3.5}
|
43
|
+
s.summary = %q{The required Padrino core gem}
|
44
|
+
s.test_files = [
|
45
|
+
"test/active_support_helpers.rb",
|
46
|
+
"test/fixtures/extended_app/app.rb",
|
47
|
+
"test/fixtures/simple_app/app.rb",
|
48
|
+
"test/helper.rb",
|
49
|
+
"test/test_padrino_core.rb",
|
50
|
+
"test/test_padrino_mounting.rb"
|
51
|
+
]
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
|
59
|
+
s.add_runtime_dependency(%q<thor>, [">= 0.11.8"])
|
60
|
+
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
61
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
|
63
|
+
s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
|
64
|
+
s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<sinatra>, [">= 0.9.2"])
|
67
|
+
s.add_dependency(%q<thor>, [">= 0.11.8"])
|
68
|
+
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
69
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
70
|
+
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
71
|
+
s.add_dependency(%q<rack-test>, [">= 0.5.0"])
|
72
|
+
s.add_dependency(%q<webrat>, [">= 0.5.1"])
|
73
|
+
end
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<sinatra>, [">= 0.9.2"])
|
76
|
+
s.add_dependency(%q<thor>, [">= 0.11.8"])
|
77
|
+
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
78
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
79
|
+
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
80
|
+
s.add_dependency(%q<rack-test>, [">= 0.5.0"])
|
81
|
+
s.add_dependency(%q<webrat>, [">= 0.5.1"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'webrat'
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
+
require 'active_support_helpers'
|
11
|
+
require File.dirname(__FILE__) + '/../../padrino-helpers/lib/padrino-helpers.rb'
|
12
|
+
require File.dirname(__FILE__) + '/../lib/padrino-core.rb'
|
13
|
+
|
14
|
+
class Test::Unit::TestCase
|
15
|
+
include Padrino::Helpers::OutputHelpers
|
16
|
+
include Padrino::Helpers::TagHelpers
|
17
|
+
include Padrino::Helpers::AssetTagHelpers
|
18
|
+
include Rack::Test::Methods
|
19
|
+
include Webrat::Methods
|
20
|
+
include Webrat::Matchers
|
21
|
+
|
22
|
+
Webrat.configure do |config|
|
23
|
+
config.mode = :rack
|
24
|
+
end
|
25
|
+
|
26
|
+
def stop_time_for_test
|
27
|
+
time = Time.now
|
28
|
+
Time.stubs(:now).returns(time)
|
29
|
+
return time
|
30
|
+
end
|
31
|
+
|
32
|
+
# assert_has_tag(:h1, :content => "yellow") { "<h1>yellow</h1>" }
|
33
|
+
# In this case, block is the html to evaluate
|
34
|
+
def assert_has_tag(name, attributes = {}, &block)
|
35
|
+
html = block && block.call
|
36
|
+
matcher = HaveSelector.new(name, attributes)
|
37
|
+
raise "Please specify a block!" if html.blank?
|
38
|
+
assert matcher.matches?(html), matcher.failure_message
|
39
|
+
end
|
40
|
+
|
41
|
+
# assert_has_no_tag, tag(:h1, :content => "yellow") { "<h1>green</h1>" }
|
42
|
+
# In this case, block is the html to evaluate
|
43
|
+
def assert_has_no_tag(name, attributes = {}, &block)
|
44
|
+
html = block && block.call
|
45
|
+
attributes.merge!(:count => 0)
|
46
|
+
matcher = HaveSelector.new(name, attributes)
|
47
|
+
raise "Please specify a block!" if html.blank?
|
48
|
+
assert matcher.matches?(html), matcher.failure_message
|
49
|
+
end
|
50
|
+
|
51
|
+
# Silences the output by redirecting to stringIO
|
52
|
+
# silence_logger { ...commands... } => "...output..."
|
53
|
+
def silence_logger(&block)
|
54
|
+
orig_stdout = $stdout
|
55
|
+
$stdout = log_buffer = StringIO.new
|
56
|
+
block.call
|
57
|
+
$stdout = orig_stdout
|
58
|
+
log_buffer.rewind && log_buffer.read
|
59
|
+
end
|
60
|
+
|
61
|
+
# Asserts that a file matches the pattern
|
62
|
+
def assert_match_in_file(pattern, file)
|
63
|
+
assert File.exist?(file), "File '#{file}' does not exist!"
|
64
|
+
assert_match pattern, File.read(file)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module Webrat
|
69
|
+
module Logging
|
70
|
+
def logger # :nodoc:
|
71
|
+
@logger = nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
require File.dirname(__FILE__) + '/fixtures/simple_app/app'
|
3
|
+
|
4
|
+
class TestPadrinoCore < Test::Unit::TestCase
|
5
|
+
context 'for core functionality' do
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'for loader functionality' do
|
10
|
+
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'for application functionality' do
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: padrino-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Padrino Team
|
8
|
+
- Nathan Esquenazi
|
9
|
+
- Davide D'Agostino
|
10
|
+
- Arthur Chiu
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-11-16 00:00:00 -08:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: sinatra
|
20
|
+
type: :runtime
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.2
|
27
|
+
version:
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: thor
|
30
|
+
type: :runtime
|
31
|
+
version_requirement:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.11.8
|
37
|
+
version:
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: haml
|
40
|
+
type: :development
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.2.1
|
47
|
+
version:
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: shoulda
|
50
|
+
type: :development
|
51
|
+
version_requirement:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
type: :development
|
61
|
+
version_requirement:
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.9.7
|
67
|
+
version:
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rack-test
|
70
|
+
type: :development
|
71
|
+
version_requirement:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.5.0
|
77
|
+
version:
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webrat
|
80
|
+
type: :development
|
81
|
+
version_requirement:
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.5.1
|
87
|
+
version:
|
88
|
+
description: The Padrino core gem required for use of this framework
|
89
|
+
email: nesquena@gmail.com
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- LICENSE
|
96
|
+
- README.rdoc
|
97
|
+
files:
|
98
|
+
- .document
|
99
|
+
- .gitignore
|
100
|
+
- LICENSE
|
101
|
+
- README.rdoc
|
102
|
+
- Rakefile
|
103
|
+
- VERSION
|
104
|
+
- lib/padrino-core.rb
|
105
|
+
- lib/padrino-core/application.rb
|
106
|
+
- lib/padrino-core/loader.rb
|
107
|
+
- lib/padrino-core/mounter.rb
|
108
|
+
- lib/padrino-core/support_lite.rb
|
109
|
+
- padrino-core.gemspec
|
110
|
+
- test/active_support_helpers.rb
|
111
|
+
- test/fixtures/extended_app/app.rb
|
112
|
+
- test/fixtures/simple_app/app.rb
|
113
|
+
- test/helper.rb
|
114
|
+
- test/test_padrino_core.rb
|
115
|
+
- test/test_padrino_mounting.rb
|
116
|
+
has_rdoc: true
|
117
|
+
homepage: http://github.com/padrino/padrino-core
|
118
|
+
licenses: []
|
119
|
+
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options:
|
122
|
+
- --charset=UTF-8
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
130
|
+
version:
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
version:
|
137
|
+
requirements: []
|
138
|
+
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.3.5
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: The required Padrino core gem
|
144
|
+
test_files:
|
145
|
+
- test/active_support_helpers.rb
|
146
|
+
- test/fixtures/extended_app/app.rb
|
147
|
+
- test/fixtures/simple_app/app.rb
|
148
|
+
- test/helper.rb
|
149
|
+
- test/test_padrino_core.rb
|
150
|
+
- test/test_padrino_mounting.rb
|