Permalink
Browse files

commit after each command

  • Loading branch information...
txus committed Apr 17, 2012
1 parent d944e84 commit 42f8334467553aa52d1dfcc865ab5f2fcbe61239
Showing with 23 additions and 4 deletions.
  1. +7 −1 lib/mayl/env.rb
  2. +1 −0 lib/mayl/repl.rb
  3. +15 −3 test/mayl/env_test.rb
View
@@ -1,11 +1,17 @@
module Mayl
- # Public: Represents the global state with the loaded locales.
+ # Public: Represents the global state with the loaded locales, and has the
+ # ability to save locales to disk.
class Env
attr_reader :locales
# Public: Initializes a new Env loading the locales from a path.
def initialize(path)
@locales = Loader.load(path)
end
+
+ # Public: Saves any changes to disk.
+ def commit
+ @locales.each(&:commit)
+ end
end
end
View
@@ -20,6 +20,7 @@ def start
puts "Detected locales: #{locales.join(', ')}"
while (print "> "; input = gets)
@parser.parse(input.chomp).execute
+ @env.commit
print "\n"
end
end
View
@@ -2,10 +2,22 @@
module Mayl
describe Env do
- it 'is a container for locales' do
- Loader.expects(:load).with('my/path').returns [1,2]
+ before do
+ @locales = [stub, stub]
+ Loader.expects(:load).with('my/path').returns @locales
@env = Mayl::Env.new('my/path')
- @env.locales.must_equal [1,2]
+ end
+
+ it 'is a container for locales' do
+ @env.locales.must_equal @locales
+ end
+
+ it 'commits changes to disk' do
+ @locales.each do |locale|
+ locale.expects(:commit)
+ end
+
+ @env.commit
end
end
end

0 comments on commit 42f8334

Please sign in to comment.