Skip to content
This repository
  • 3 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
2  Rakefile
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17 17 s.platform = Gem::Platform::RUBY
18 18 s.summary = "A CLI Flashcard."
19 19 s.name = 'ankit'
20   - s.version = "0.0.3"
  20 + s.version = "0.0.5"
21 21 s.require_path = 'lib'
22 22 s.files = FileList["{bin,docs,lib,test}/**/*"].exclude("rdoc").to_a
23 23 s.executables << 'ankit'
6 lib/ankit/add_command.rb
@@ -14,12 +14,14 @@ class AddCommand < TextReadingCommand
14 14 def execute()
15 15 validate_options
16 16 each_text do |text|
17   - text.split(/\n\n+/).each do |chunk|
  17 + text.split(/\n\n+/).map(&:strip).each do |chunk|
  18 + next if chunk.empty?
18 19 card = Card.parse(chunk)
  20 + next unless card
19 21 # TODO: gaurd ovewrite
20 22 # TODO: guard out-of-path write
21 23 filename = to_card_path(dest_dir, card.name)
22   - File.open(filename, "w") { |f| f.write(text) }
  24 + File.open(filename, "w") { |f| f.write(chunk) }
23 25 runtime.stdout.write("#{filename}\n")
24 26 end
25 27 end
4 lib/ankit/challenge.rb
@@ -81,8 +81,10 @@ def mixed_hilight_for_flash(wrong)
81 81 case ch.action
82 82 when "="
83 83 StylableText.styled_text(ch.old_element, :fyi)
84   - when "!", "-"
  84 + when "!"
85 85 StylableText.styled_text(ch.old_element, :wrong) + StylableText.styled_text(ch.new_element, :correct)
  86 + when "-"
  87 + StylableText.styled_text(ch.old_element, :wrong)
86 88 when "+"
87 89 StylableText.styled_text(ch.new_element, :correct)
88 90 else
1  test/card_test.rb
@@ -98,5 +98,6 @@ def test_diff
98 98 Card.new(o:"hello").hilight_against_original("helo") {}
99 99 Card.new(o:"helo").hilight_against_original("hello") {}
100 100 Card.new(o:"helxo").hilight_against_original("hello") {}
  101 + Card.new(o:"A BC B").mixed_hilight_for_flash("A B CB")
101 102 end
102 103 end
10 test/command_test.rb
@@ -161,9 +161,13 @@ def test_hello_two_files
161 161 def test_hello_two_chunks
162 162 with_runtime_on_temp_repo do |target|
163 163 dst_dir = target.config.card_search_paths[1]
164   - assert_written(target.dispatch_then(["add", test_data_at("hope-and-luck.txt")]),
165   - [File.join(target.config.card_paths[0], "hope-is-the-thing-with-feathers.card"),
166   - File.join(target.config.card_paths[0], "luck-is-not-chance.card")])
  164 + p = target.config.card_paths[0]
  165 + expected = [File.join(p,"hope-is-the-thing-with-feathers.card"),
  166 + File.join(p, "luck-is-not-chance.card")]
  167 + assert_written(target.dispatch_then(["add", test_data_at("hope-and-luck.txt")]), expected)
  168 + expected.each do |name|
  169 + assert_equal(1, open(name).readlines.size)
  170 + end
167 171 end
168 172 end
169 173 end
3  test/data/hope-and-luck.txt
... ... @@ -1,4 +1,7 @@
  1 +
  2 +
1 3 O: Hope is the thing with feathers
2 4
3 5
4 6 O: Luck is not chance
  7 +

No commit comments for this range

Something went wrong with that request. Please try again.