Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made more tests pass. Each plugin now is responsible for loading its …

…own dependencies.
  • Loading branch information...
commit 9bd1581712603f7c917bc070cb83beaee00574c5 1 parent d929bf9
Michael Edgar authored
View
1  amp-core/lib/amp-core.rb
@@ -1,5 +1,6 @@
puts "Loading amp-core..."
+require 'amp-front'
require 'amp-core/command_ext/repository_loading'
require 'amp-core/repository/repository.rb'
require 'amp-core/repository/generic_repo_picker.rb'
View
9 amp-front/lib/amp-front/dispatch/runner.rb
@@ -23,8 +23,10 @@ def initialize(args, opts={})
end
def run!
+ p @args
global_opts, arguments = collect_options(@args)
- load_ampfile!
+ p global_opts
+ load_ampfile!(global_opts[:ampfile]) unless global_opts[:"no-ampfile"]
load_plugins!
command_class = Amp::Command.for_name(arguments.join(' '))
@@ -40,8 +42,7 @@ def run!
# Loads the ampfile (or whatever it's specified as) from the
# current directory or a parent directory.
- def load_ampfile!(in_dir = Dir.pwd)
- file = @opts[:ampfile] || 'ampfile'
+ def load_ampfile!(file, in_dir = Dir.pwd)
variations = [file, file[0,1].upcase + file[1..-1]] # include titlecase
to_load = variations.find {|x| File.exist?(File.join(in_dir, x))}
if to_load
@@ -77,6 +78,8 @@ def collect_options(arguments)
_, hash = Trollop::options(argv) do
banner "Amp - some more crystal, sir?"
version "Amp version #{Amp::VERSION} (#{Amp::VERSION_TITLE})"
+ opt :"no-ampfile", "Disables ampfiles.", :type => :flag
+ opt :ampfile, "Which file to load as an ampfile", :type => :string, :default => "ampfile"
stop_on_unknown
end
[hash, argv]
View
15 amp-front/spec/dispatch_specs/runner_spec.rb
@@ -16,7 +16,7 @@
describe Amp::Dispatch::Runner do
before do
- @runner = Amp::Dispatch::Runner.new(['--version'], :ampfile => "NO SUCH FILE@@@@@@@@@@@@@@@@@@")
+ @runner = Amp::Dispatch::Runner.new(['--version', '--no-ampfile'])
end
describe '#run!' do
@@ -34,9 +34,10 @@
mock_command_class.should_receive(:new).and_return(mock_command)
mock_command.should_receive(:collect_options).and_return([{:verbose => true}, ['--verbose']])
mock_command.should_receive(:call).with(
- {:verbose => true, :help => false, :version => false}, ['--verbose'])
+ {:verbose => true, :help => false, :version => false, :ampfile => 'ampfile',
+ :"no-ampfile_given" => true, :"no-ampfile" => true}, ['--verbose'])
- runner = Amp::Dispatch::Runner.new(['tester', '--verbose'])
+ runner = Amp::Dispatch::Runner.new(['--no-ampfile', 'tester', '--verbose'])
runner.run!
end
@@ -51,9 +52,10 @@
mock_command_class.should_receive(:new).and_return(mock_command)
mock_command.should_receive(:collect_options).and_return([{}, []])
mock_command.should_receive(:call).with(
- {:help => false, :version => false}, [])
+ {:help => false, :version => false, :"no-ampfile_given" => true,
+ :"no-ampfile" => true, :ampfile => 'ampfile'}, [])
- runner = Amp::Dispatch::Runner.new([''])
+ runner = Amp::Dispatch::Runner.new(['--no-ampfile'])
runner.run!
end
end
@@ -105,7 +107,8 @@
it 'returns the parsed options' do
options, arguments = @runner.collect_options(['help', 'please'])
- options.should == {:version => false, :help => false}
+ options.should == {:version => false, :help => false,
+ :ampfile => 'ampfile', :"no-ampfile" => false}
end
it 'returns the unparsed arguments' do
View
2  amp-git/lib/amp-git.rb
@@ -4,6 +4,8 @@
require 'stringio'
# Must require the GitPicker or it won't be found.
+require 'amp-front'
+require 'amp-core'
require 'amp-git/repository'
module Amp
View
5 amp-hg/lib/amp-hg.rb
@@ -3,8 +3,6 @@
require 'zlib'
require 'stringio'
-# Must require the HgPicker or it won't be found.
-
module Amp
module Mercurial
module Diffs
@@ -57,5 +55,8 @@ module RevlogSupport
end
end
+# Must require the HgPicker or it won't be found.
+require 'amp-front'
+require 'amp-core'
require 'amp-hg/repository'
require 'amp-hg/version'
Please sign in to comment.
Something went wrong with that request. Please try again.