Permalink
Browse files

Fixed #12.#12.#12.#12.#12.

  • Loading branch information...
omo committed Mar 18, 2012
1 parent d9c6273 commit 284ee22121c44f06927654d8922439bdadbcfcd4
Showing with 18 additions and 7 deletions.
  1. +8 −6 lib/ankit/add_command.rb
  2. +10 −1 test/command_test.rb
View
@@ -14,12 +14,14 @@ class AddCommand < TextReadingCommand
def execute()
validate_options
each_text do |text|
- card = Card.parse(text)
- # TODO: gaurd ovewrite
- # TODO: guard out-of-path write
- filename = to_card_path(dest_dir, card.name)
- File.open(filename, "w") { |f| f.write(text) }
- runtime.stdout.write("#{filename}\n")
+ text.split(/\n\n+/).each do |chunk|
+ card = Card.parse(chunk)
+ # TODO: gaurd ovewrite
+ # TODO: guard out-of-path write
+ filename = to_card_path(dest_dir, card.name)
+ File.open(filename, "w") { |f| f.write(text) }
+ runtime.stdout.write("#{filename}\n")
+ end
end
end
View
@@ -149,14 +149,23 @@ def test_hello_stdin_dir
end
end
- def test_hello_two_file
+ def test_hello_two_files
with_runtime_on_temp_repo do |target|
dst_dir = target.config.card_search_paths[1]
assert_written(target.dispatch_then(["add", test_data_at("hope.card"), test_data_at("luck.card")]),
[File.join(target.config.card_paths[0], "hope-is-the-thing-with-feathers.card"),
File.join(target.config.card_paths[0], "luck-is-not-chance.card")])
end
end
+
+ def test_hello_two_chunks
+ with_runtime_on_temp_repo do |target|
+ dst_dir = target.config.card_search_paths[1]
+ assert_written(target.dispatch_then(["add", test_data_at("hope-and-luck.txt")]),
+ [File.join(target.config.card_paths[0], "hope-is-the-thing-with-feathers.card"),
+ File.join(target.config.card_paths[0], "luck-is-not-chance.card")])
+ end
+ end
end
class ComingTest < Test::Unit::TestCase

0 comments on commit 284ee22

Please sign in to comment.