forked from remarkable-rb/remarkable
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AM/ARCH] Simplified loading scheme for Remarkable::ActiveModel
- Loading branch information
Showing
3 changed files
with
22 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# encoding: utf-8 | ||
|
||
def load_project_path(project) | ||
project = project.to_s | ||
project_path = File.join(File.dirname(__FILE__), project, 'lib') | ||
return nil if $LOAD_PATH.include?(File.expand_path(project_path)) | ||
$LOAD_PATH.unshift(File.expand_path(project_path)) | ||
def load_project_path(*projects) | ||
projects.each do |project| | ||
project = project.to_s | ||
project_path = File.join(File.dirname(__FILE__), project, 'lib') | ||
return nil if $LOAD_PATH.include?(File.expand_path(project_path)) | ||
$LOAD_PATH.unshift(File.expand_path(project_path)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
# Load Remarkable | ||
unless Object.const_defined?('Remarkable') | ||
begin | ||
require 'remarkable' | ||
rescue LoadError | ||
require 'rubygems' | ||
gem 'remarkable' | ||
require 'remarkable' | ||
end | ||
end | ||
require 'remarkable' | ||
require 'remarkable/active_model/base' | ||
|
||
# Load Remarkable ActiveModel files | ||
# Add default locale | ||
dir = File.dirname(__FILE__) | ||
require File.join(dir, 'active_model', 'base') | ||
|
||
# Add locale | ||
Remarkable.add_locale File.join(dir, '..', '..', 'locale', 'en.yml') | ||
Dir["#{dir}/../../locale/*yml"].each {|f| Remarkable.add_locale(f) } | ||
|
||
# Add matchers | ||
Dir[File.join(dir, 'active_model', 'matchers', '*.rb')].each do |file| | ||
require file | ||
end | ||
|
||
# By default, ActiveModel matchers are not included in any example group. | ||
# The responsibility for this is RemarkableRails. If you are using ActiveModel | ||
# without Rails, put the line below in your spec_helper to include ActiveModel | ||
# matchers into rspec globally. | ||
# Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Example::ExampleGroup) | ||
Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
# encoding: utf-8 | ||
require 'rubygems' | ||
$TESTING=true | ||
|
||
require 'rubygems' | ||
require 'rspec' | ||
|
||
RAILS_VERSION = ENV['RAILS_VERSION'] || '3.0.0.beta3' | ||
|
||
gem 'activesupport', RAILS_VERSION | ||
require 'active_support/all' | ||
|
||
gem 'activemodel', RAILS_VERSION | ||
require 'active_model' | ||
|
||
# Requires supporting files with custom matchers and macros, etc, | ||
# in ./support/ and its subdirectories. | ||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} | ||
require File.expand_path('path_helpers', File.join(File.dirname(__FILE__), '/../../')) | ||
load_project_path :remarkable, :remarkable_activemodel | ||
|
||
# Load Remarkable core on place to avoid gem to be loaded | ||
dir = File.dirname(__FILE__) | ||
require File.join(dir, '..', '..', 'remarkable', 'lib', 'remarkable') | ||
require 'remarkable/active_model' | ||
|
||
# Load Remarkable ActiveModel | ||
require File.join(dir, '..', 'lib', 'remarkable_activemodel') | ||
# Requires supporting files with custom matchers and macros, etc, | ||
# # in ./support/ and its subdirectories. | ||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} | ||
|
||
# Include matchers | ||
Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup) | ||
# Load custom matchers | ||
#Remarkable.include_matchers!(Remarkable::Rspec, Rspec::Core::ExampleGroup) |