Skip to content

Commit

Permalink
fix some loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Apr 17, 2012
1 parent a82294e commit e82f732
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/mayl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
$: << 'lib'
require 'mayl'

Mayl::Repl.new(ARGV[1]).start
Mayl::Repl.new(ARGV[0]).start
6 changes: 5 additions & 1 deletion lib/mayl/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ module Loader
#
# Returns an Array of Locale objects.
def self.load(path)
Dir[File.expand_path(path) << "/*.yml"].map { |filename|
locales = Dir[File.expand_path(path) << "/*.yml"].map { |filename|
Locale.new filename, YAML.load(File.read(filename))
}

abort "Error: No locales found under ./#{path}" if locales.empty?

locales
end
end
end
4 changes: 2 additions & 2 deletions lib/mayl/repl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Repl
#
# path - The path to get the locales from (defaults to 'config/locales').
def initialize(path)
path ||= 'config/locales'
path ||= 'config/locales'
@env = Env.new(path)
@parser = Parser.new(@env)
end
Expand All @@ -20,7 +20,7 @@ def start
locales = @env.locales.map(&:name)
prompt = "> "
puts "Detected locales: #{locales.join(', ')}"
while (print prompt; input = gets)
while (print prompt; input = $stdin.gets)
begin
value = @parser.parse(input.chomp).execute
@env.last_value = value
Expand Down
4 changes: 2 additions & 2 deletions test/mayl/repl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Mayl
describe Repl do
before do
@repl = Mayl::Repl.new('some/path.yml')
@repl = Mayl::Repl.new('test/support')
end

it 'parses and executes commands' do
Expand All @@ -12,7 +12,7 @@ module Mayl
@baz = stub
@baz.expects(:execute)

@repl.expects(:gets).times(3).returns("foo bar\n", "baz lol\n", nil)
$stdin.expects(:gets).times(3).returns("foo bar\n", "baz lol\n", nil)

@repl.parser.expects(:parse).with('foo bar').returns @foo
@repl.parser.expects(:parse).with('baz lol').returns @baz
Expand Down

0 comments on commit e82f732

Please sign in to comment.