Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace require and autoload calls with calls to the using gem

  • Loading branch information...
commit 998a72a3885078c4dc506d5357bcb4db249226ab 1 parent 92bb8a7
@smtlaissezfaire authored
View
2  config/hoe.rb
@@ -37,7 +37,7 @@ def rubyforge_username
REV = nil
# UNCOMMENT IF REQUIRED:
# REV = YAML.load(`svn info`)['Revision']
-VERS = Guillotine::VERSION::STRING + (REV ? ".#{REV}" : "")
+VERS = Guillotine::Version::STRING + (REV ? ".#{REV}" : "")
RDOC_OPTS = ['--quiet', '--title', 'guillotine documentation',
"--opname", "index.html",
"--line-numbers",
View
42 lib/guillotine.rb
@@ -1,27 +1,31 @@
require "rubygems"
+require "using"
-project = File.dirname(__FILE__) + "/guillotine"
+Using.default_load_scheme = :autoload
-require "#{project}/extensions"
-
-module Guillotine; end
+module Guillotine
+ extend Using
+
+ with_load_scheme :require do
+ using :extensions
+ end
-Guillotine.module_eval do
- autoload :Assertions, "#{project}/assertions"
- autoload :DataStore, "#{project}/data_store"
- autoload :PreParser, "#{project}/pre_parser"
- autoload :Parser, "#{project}/parser"
- autoload :Conditions, "#{project}/conditions"
- autoload :Keywords, "#{project}/keywords"
- autoload :Expressions, "#{project}/expressions"
- autoload :RSpec, "#{project}/test_support"
- autoload :RakeTasks, "#{project}/rake"
- autoload :Shell, "#{project}/shell"
- autoload :StatementExecutors, "#{project}/statement_executors"
- autoload :Transactions, "#{project}/transactions"
- autoload :TestSupport, "#{project}/test_support"
- autoload :VERSION, "#{project}/version"
+ using :Assertions
+ using :DataStore
+ using :PreParser
+ using :Parser
+ using :Conditions
+ using :Keywords
+ using :Expressions
+ using :TestSupport
+ using :RSpec
+ using :RakeTasks
+ using :Shell
+ using :StatementExecutors
+ using :Transactions
+ using :TestSupport
+ using :Version
class << self
def execute(string)
View
8 lib/guillotine/conditions.rb
@@ -1,9 +1,9 @@
module Guillotine
module Conditions
- dir = File.dirname(__FILE__) + "/conditions"
+ extend Using
- autoload :Base, "#{dir}/base"
- autoload :AndCondition, "#{dir}/and_condition"
- autoload :OrCondition, "#{dir}/or_condition"
+ using :Base
+ using :AndCondition
+ using :OrCondition
end
end
View
14 lib/guillotine/data_store.rb
@@ -1,10 +1,14 @@
module Guillotine
module DataStore
- dir = File.dirname(__FILE__) + "/data_store"
- autoload :Schema, "#{dir}/schema"
- autoload :Table, "#{dir}/table"
-
- require "#{dir}/database"
+ extend Using
+
+ using :Schema
+ using :Table
+
+ with_load_scheme :require do
+ using :Database
+ end
+
extend DataStore::Database
class UnknownTable < StandardError; end
View
48 lib/guillotine/expressions.rb
@@ -40,29 +40,29 @@ def classes
end
end
- dir = File.dirname(__FILE__) + "/expressions"
- autoload :BacktickString, "#{dir}/backtick_string"
- autoload :Base, "#{dir}/base"
- autoload :TopLevelExpression, "#{dir}/top_level_expression"
- autoload :Column, "#{dir}/column"
- autoload :Equal, "#{dir}/equal"
- autoload :LessThan, "#{dir}/less_than"
- autoload :GreaterThan, "#{dir}/greater_than"
- autoload :GreaterThanOrEqualTo, "#{dir}/greater_than_or_equal_to"
- autoload :LessThanOrEqualTo, "#{dir}/less_than_or_equal_to"
- autoload :NotEqual, "#{dir}/not_equal"
- autoload :IsNull, "#{dir}/is_null"
- autoload :IsNotNull, "#{dir}/is_not_null"
- autoload :Select, "#{dir}/select"
- autoload :From, "#{dir}/from"
- autoload :OrderBy, "#{dir}/order_by"
- autoload :GroupBy, "#{dir}/group_by"
- autoload :Limit, "#{dir}/limit"
- autoload :Truncate, "#{dir}/truncate"
- autoload :DeleteStatement, "#{dir}/delete"
- autoload :SelectExpression, "#{dir}/select_expression"
- autoload :Insert, "#{dir}/insert"
- autoload :CreateTable, "#{dir}/create_table"
- autoload :TableDisplayer, "#{dir}/table_displayer"
+ extend Using
+ using :BacktickString
+ using :Base
+ using :TopLevelExpression
+ using :Column
+ using :Equal
+ using :LessThan
+ using :GreaterThan
+ using :GreaterThanOrEqualTo
+ using :LessThanOrEqualTo
+ using :NotEqual
+ using :IsNull
+ using :IsNotNull
+ using :Select
+ using :From
+ using :OrderBy
+ using :GroupBy
+ using :Limit
+ using :Truncate
+ using :DeleteStatement
+ using :SelectExpression
+ using :Insert
+ using :CreateTable
+ using :TableDisplayer
end
end
View
0  lib/guillotine/expressions/delete.rb → lib/guillotine/expressions/delete_statement.rb
File renamed without changes
View
48 lib/guillotine/parser.rb
@@ -25,28 +25,30 @@ class SQLParseError < StandardError; end
end
require File.dirname(__FILE__) + "/../../ext/quotes_parser/quotes_parser.so"
+ extend Using
- parser = File.dirname(__FILE__) + "/parser"
- require "#{parser}/sql_tokens"
- require "#{parser}/sql_primitives"
- require "#{parser}/sql_helpers"
- require "#{parser}/sql_chars"
- require "#{parser}/sql_row_support"
- require "#{parser}/sql_key_value_pair"
- require "#{parser}/sql_where_condition"
- require "#{parser}/sql_limit"
- require "#{parser}/sql_order_by_clause"
- require "#{parser}/sql_group_by_clause"
- require "#{parser}/sql_from_clause"
- require "#{parser}/sql_select_clause"
- require "#{parser}/sql_select"
- require "#{parser}/sql_truncate"
- require "#{parser}/sql_delete"
- require "#{parser}/sql_drop_table"
- require "#{parser}/sql_show_tables"
- require "#{parser}/sql_transaction"
- require "#{parser}/sql_insert"
- require "#{parser}/sql_datatypes"
- require "#{parser}/sql_create_table"
- require "#{parser}/sql"
+ with_load_scheme :require do
+ using :SqlTokens
+ using :SqlPrimitives
+ using :SqlHelpers
+ using :SqlChars
+ using :SqlRowSupport
+ using :SqlKeyValuePair
+ using :SqlWhereCondition
+ using :SqlLimit
+ using :SqlOrderByClause
+ using :SqlGroupByClause
+ using :SqlFromClause
+ using :SqlSelectClause
+ using :SqlSelect
+ using :SqlTruncate
+ using :SqlDelete
+ using :SqlDropTable
+ using :SqlShowTables
+ using :SqlTransaction
+ using :SqlInsert
+ using :SqlDatatypes
+ using :SqlCreateTable
+ using :Sql
+ end
end
View
3  lib/guillotine/r_spec.rb
@@ -0,0 +1,3 @@
+module Guillotine
+ RSpec = TestSupport::RSpec
+end
View
0  lib/guillotine/rake.rb → lib/guillotine/rake_tasks.rb
File renamed without changes
View
11 lib/guillotine/test_support.rb
@@ -1,10 +1,9 @@
module Guillotine
module TestSupport
- dir = File.dirname(__FILE__) + "/test_support"
- autoload :MysqlOverrider, "#{dir}/mysql_overrider"
- autoload :Connection, "#{dir}/connection"
- autoload :RSpec, "#{dir}/rspec"
+ extend Using
+
+ using :MysqlOverrider
+ using :Connection
+ using :RSpec
end
-
- RSpec = TestSupport::RSpec
end
View
0  lib/guillotine/test_support/rspec.rb → lib/guillotine/test_support/r_spec.rb
File renamed without changes
View
2  lib/guillotine/version.rb
@@ -1,5 +1,5 @@
module Guillotine
- module VERSION #:nodoc:
+ module Version #:nodoc:
MAJOR = 0
MINOR = 0
TINY = 1
View
4 spec/guillotine/version_spec.rb
@@ -1,9 +1,9 @@
require File.dirname(__FILE__) + "/../spec_helper"
module Guillotine
- describe VERSION do
+ describe Version do
it "should be at 0.0.1" do
- Guillotine::VERSION::STRING.should == "0.0.1"
+ Guillotine::Version::STRING.should == "0.0.1"
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.