ankit 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,14 @@ module Ankit
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
@@ -161,9 +161,13 @@ class AddTest < Test::Unit::TestCase
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
@@ -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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ankit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-18 00:00:00.000000000 Z
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
16
- requirement: &7184500 !ruby/object:Gem::Requirement
16
+ requirement: &7646340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.11
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7184500
24
+ version_requirements: *7646340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: diff-lcs
27
- requirement: &7183860 !ruby/object:Gem::Requirement
27
+ requirement: &7645740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *7183860
35
+ version_requirements: *7645740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &7183300 !ruby/object:Gem::Requirement
38
+ requirement: &7645220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.5
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *7183300
46
+ version_requirements: *7645220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &7182720 !ruby/object:Gem::Requirement
49
+ requirement: &7644500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.10.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *7182720
57
+ version_requirements: *7644500
58
58
  description: ! 'Ankit is a CLI and terminal based flashcard program to learn your
59
59
  new language.
60
60