Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: omo/ankit
base: 33b914b101
...
head fork: omo/ankit
compare: fc776f068d
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
2  Rakefile
View
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.summary = "A CLI Flashcard."
s.name = 'ankit'
- s.version = "0.0.3"
+ s.version = "0.0.5"
s.require_path = 'lib'
s.files = FileList["{bin,docs,lib,test}/**/*"].exclude("rdoc").to_a
s.executables << 'ankit'
6 lib/ankit/add_command.rb
View
@@ -14,12 +14,14 @@ class AddCommand < TextReadingCommand
def execute()
validate_options
each_text do |text|
- text.split(/\n\n+/).each do |chunk|
+ text.split(/\n\n+/).map(&:strip).each do |chunk|
+ next if chunk.empty?
card = Card.parse(chunk)
+ next unless card
# 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) }
+ File.open(filename, "w") { |f| f.write(chunk) }
runtime.stdout.write("#{filename}\n")
end
end
4 lib/ankit/challenge.rb
View
@@ -81,8 +81,10 @@ def mixed_hilight_for_flash(wrong)
case ch.action
when "="
StylableText.styled_text(ch.old_element, :fyi)
- when "!", "-"
+ when "!"
StylableText.styled_text(ch.old_element, :wrong) + StylableText.styled_text(ch.new_element, :correct)
+ when "-"
+ StylableText.styled_text(ch.old_element, :wrong)
when "+"
StylableText.styled_text(ch.new_element, :correct)
else
1  test/card_test.rb
View
@@ -98,5 +98,6 @@ def test_diff
Card.new(o:"hello").hilight_against_original("helo") {}
Card.new(o:"helo").hilight_against_original("hello") {}
Card.new(o:"helxo").hilight_against_original("hello") {}
+ Card.new(o:"A BC B").mixed_hilight_for_flash("A B CB")
end
end
10 test/command_test.rb
View
@@ -161,9 +161,13 @@ def test_hello_two_files
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")])
+ p = target.config.card_paths[0]
+ expected = [File.join(p,"hope-is-the-thing-with-feathers.card"),
+ File.join(p, "luck-is-not-chance.card")]
+ assert_written(target.dispatch_then(["add", test_data_at("hope-and-luck.txt")]), expected)
+ expected.each do |name|
+ assert_equal(1, open(name).readlines.size)
+ end
end
end
end
3  test/data/hope-and-luck.txt
View
@@ -1,4 +1,7 @@
+
+
O: Hope is the thing with feathers
O: Luck is not chance
+

No commit comments for this range

Something went wrong with that request. Please try again.