mayl 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/mayl +1 -1
- data/lib/mayl/loader.rb +5 -1
- data/lib/mayl/repl.rb +2 -2
- data/lib/mayl/version.rb +1 -1
- data/test/mayl/repl_test.rb +2 -2
- metadata +1 -1
data/bin/mayl
CHANGED
data/lib/mayl/loader.rb
CHANGED
@@ -17,9 +17,13 @@ module Mayl
|
|
17
17
|
#
|
18
18
|
# Returns an Array of Locale objects.
|
19
19
|
def self.load(path)
|
20
|
-
Dir[File.expand_path(path) << "/*.yml"].map { |filename|
|
20
|
+
locales = Dir[File.expand_path(path) << "/*.yml"].map { |filename|
|
21
21
|
Locale.new filename, YAML.load(File.read(filename))
|
22
22
|
}
|
23
|
+
|
24
|
+
abort "Error: No locales found under ./#{path}" if locales.empty?
|
25
|
+
|
26
|
+
locales
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/mayl/repl.rb
CHANGED
@@ -8,7 +8,7 @@ module Mayl
|
|
8
8
|
#
|
9
9
|
# path - The path to get the locales from (defaults to 'config/locales').
|
10
10
|
def initialize(path)
|
11
|
-
path
|
11
|
+
path ||= 'config/locales'
|
12
12
|
@env = Env.new(path)
|
13
13
|
@parser = Parser.new(@env)
|
14
14
|
end
|
@@ -20,7 +20,7 @@ module Mayl
|
|
20
20
|
locales = @env.locales.map(&:name)
|
21
21
|
prompt = "> "
|
22
22
|
puts "Detected locales: #{locales.join(', ')}"
|
23
|
-
while (print prompt; input = gets)
|
23
|
+
while (print prompt; input = $stdin.gets)
|
24
24
|
begin
|
25
25
|
value = @parser.parse(input.chomp).execute
|
26
26
|
@env.last_value = value
|
data/lib/mayl/version.rb
CHANGED
data/test/mayl/repl_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
module Mayl
|
4
4
|
describe Repl do
|
5
5
|
before do
|
6
|
-
@repl = Mayl::Repl.new('
|
6
|
+
@repl = Mayl::Repl.new('test/support')
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'parses and executes commands' do
|
@@ -12,7 +12,7 @@ module Mayl
|
|
12
12
|
@baz = stub
|
13
13
|
@baz.expects(:execute)
|
14
14
|
|
15
|
-
|
15
|
+
$stdin.expects(:gets).times(3).returns("foo bar\n", "baz lol\n", nil)
|
16
16
|
|
17
17
|
@repl.parser.expects(:parse).with('foo bar').returns @foo
|
18
18
|
@repl.parser.expects(:parse).with('baz lol').returns @baz
|