hemlock 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -4
- data/bin/hemlock +5 -33
- data/hemlock.gemspec +2 -6
- data/lib/hemlock/csv_to_flashcards.rb +2 -3
- data/lib/hemlock/turn.rb +38 -0
- data/lib/hemlock/version.rb +1 -1
- data/lib/hemlock.rb +1 -0
- data/spec/hemlock/turn_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f6d9f919d34b2f1fb39c71e7f006c2593d56445
|
4
|
+
data.tar.gz: 7ebe69e1fb5733f85cac5172cdb7a072d347cf9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e22ef8a5856e35337959221c73e1ace8fa74e9d564f1f630f0312ed5294eed15dcbeed001f6bed1608265a8b82468a7bcdda1f18521ff410ccd7fa27ab71e009
|
7
|
+
data.tar.gz: e964c17030b9cdbf7f2d077b060d0cde76d8efdc45ca46d06e96e959f862a077f8157340f416f1a55c0be05958665cdf9908e893e40aced414f0451313726220
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hemlock (0.0.
|
4
|
+
hemlock (0.0.9)
|
5
5
|
gli (= 2.9.0)
|
6
6
|
rainbow (= 1.99.1)
|
7
7
|
|
@@ -10,26 +10,31 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
celluloid (0.15.2)
|
12
12
|
timers (~> 1.1.0)
|
13
|
+
celluloid-io (0.15.0)
|
14
|
+
celluloid (>= 0.15.0)
|
15
|
+
nio4r (>= 0.5.0)
|
13
16
|
coderay (1.1.0)
|
14
17
|
diff-lcs (1.2.5)
|
15
18
|
ffi (1.9.3)
|
16
19
|
formatador (0.2.4)
|
17
20
|
gli (2.9.0)
|
18
|
-
guard (2.
|
21
|
+
guard (2.4.0)
|
19
22
|
formatador (>= 0.2.4)
|
20
23
|
listen (~> 2.1)
|
21
24
|
lumberjack (~> 1.0)
|
22
25
|
pry (>= 0.9.12)
|
23
26
|
thor (>= 0.18.1)
|
24
|
-
guard-rspec (4.2.
|
27
|
+
guard-rspec (4.2.6)
|
25
28
|
guard (~> 2.1)
|
26
29
|
rspec (>= 2.14, < 4.0)
|
27
|
-
listen (2.
|
30
|
+
listen (2.5.0)
|
28
31
|
celluloid (>= 0.15.2)
|
32
|
+
celluloid-io (>= 0.15.0)
|
29
33
|
rb-fsevent (>= 0.9.3)
|
30
34
|
rb-inotify (>= 0.9)
|
31
35
|
lumberjack (1.0.4)
|
32
36
|
method_source (0.8.2)
|
37
|
+
nio4r (1.0.0)
|
33
38
|
pry (0.9.12.6)
|
34
39
|
coderay (~> 1.0)
|
35
40
|
method_source (~> 0.8)
|
data/bin/hemlock
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'gli'
|
3
3
|
require 'hemlock'
|
4
|
-
require 'readline'
|
5
4
|
require 'rainbow'
|
6
5
|
|
7
6
|
include GLI::App
|
@@ -10,42 +9,15 @@ program_desc 'Memorization through repetitive writing - Socrates is not amused'
|
|
10
9
|
|
11
10
|
version Hemlock::VERSION
|
12
11
|
|
13
|
-
pre do |global,command,options,args|
|
14
|
-
true
|
15
|
-
end
|
16
|
-
|
17
12
|
command :drink do |c|
|
18
13
|
c.desc "Crito, we owe a rooster to Asclepius. Please, don't forget to pay the debt."
|
19
14
|
|
20
15
|
c.action do |global_options, options, args|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
exit_now!('There are no flashcards in this folder') if flashcards.empty?
|
27
|
-
5.times do
|
28
|
-
seed = rand(0..(flashcards.length - 1))
|
29
|
-
flashcard = flashcards[seed]
|
30
|
-
puts flashcard.question
|
31
|
-
answer = Readline.readline('>> ', false)
|
32
|
-
if flashcard.correct?(answer)
|
33
|
-
puts printf Rainbow('Correct').green
|
34
|
-
else
|
35
|
-
puts printf Rainbow('You must submit to the quarries').red
|
36
|
-
i = 1
|
37
|
-
while i < 3 do
|
38
|
-
puts flashcard.question
|
39
|
-
puts flashcard.answer
|
40
|
-
answer = Readline.readline('>> ', true)
|
41
|
-
if flashcard.correct?(answer)
|
42
|
-
i += 1
|
43
|
-
else
|
44
|
-
puts printf Rainbow('Who are you? Sisyphus?!').red
|
45
|
-
redo
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
16
|
+
number_of_turns = args.empty? ? 5 : args.first.to_i
|
17
|
+
flashcards = Hemlock::CSVtoFlashcards.create_flashcards
|
18
|
+
number_of_turns.times do
|
19
|
+
flashcard = flashcards.sample
|
20
|
+
Hemlock::Turn.new(flashcard).take_turn
|
49
21
|
end
|
50
22
|
end
|
51
23
|
end
|
data/hemlock.gemspec
CHANGED
@@ -8,12 +8,8 @@ spec = Gem::Specification.new do |s|
|
|
8
8
|
s.homepage = 'https://github.com/shicholas/hemlock'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.summary = 'Memorization through written repetition - Socrates is not amused'
|
11
|
-
s.files = `git ls-files`.split("
|
12
|
-
|
13
|
-
s.require_paths << 'lib'
|
14
|
-
s.require_paths << 'flashcards'
|
15
|
-
s.has_rdoc = true
|
16
|
-
s.rdoc_options << '--title' << 'hemlock' << '--main' << '-ri'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.require_paths << 'lib' << 'flashcards'
|
17
13
|
s.bindir = 'bin'
|
18
14
|
s.executables << 'hemlock'
|
19
15
|
s.add_development_dependency('guard-rspec')
|
@@ -4,9 +4,8 @@ require 'csv'
|
|
4
4
|
module Hemlock
|
5
5
|
class CSVtoFlashcards
|
6
6
|
|
7
|
-
def self.create_flashcards
|
8
|
-
folder_name = default_flashcard_directory
|
9
|
-
folder_name = self.replace_tildes(folder_name)
|
7
|
+
def self.create_flashcards
|
8
|
+
folder_name = self.replace_tildes(default_flashcard_directory)
|
10
9
|
flashcards = []
|
11
10
|
Dir["#{folder_name}/*.csv"].each do |file|
|
12
11
|
flashcards << self.from_file(file)
|
data/lib/hemlock/turn.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'readline'
|
2
|
+
|
3
|
+
module Hemlock
|
4
|
+
class Turn
|
5
|
+
|
6
|
+
def initialize(flashcard)
|
7
|
+
@flashcard = flashcard
|
8
|
+
end
|
9
|
+
|
10
|
+
def take_turn
|
11
|
+
puts @flashcard.question
|
12
|
+
guess = Readline.readline('>> ', false)
|
13
|
+
if @flashcard.correct?(guess)
|
14
|
+
puts printf Rainbow('Correct').green
|
15
|
+
else
|
16
|
+
puts printf Rainbow('You must submit to the quarries').red
|
17
|
+
punishment
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def punishment
|
24
|
+
i = 1
|
25
|
+
while i < 3 do
|
26
|
+
puts @flashcard.question
|
27
|
+
puts @flashcard.answer
|
28
|
+
guess = Readline.readline('>> ', true)
|
29
|
+
if @flashcard.correct?(guess)
|
30
|
+
i += 1
|
31
|
+
else
|
32
|
+
puts printf Rainbow('Who are you? Sisyphus?!').red
|
33
|
+
redo
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/hemlock/version.rb
CHANGED
data/lib/hemlock.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hemlock::Turn do
|
4
|
+
|
5
|
+
subject { described_class }
|
6
|
+
let(:flashcard) { Hemlock::Flashcard.new('blue', 'a great color') }
|
7
|
+
let(:flashcards) { [flashcard] }
|
8
|
+
let(:turn) { Hemlock::Turn.new(flashcard) }
|
9
|
+
|
10
|
+
context '#take_turn' do
|
11
|
+
it 'should print correct on a correct guess' do
|
12
|
+
# pending
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hemlock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Shook
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard-rspec
|
@@ -88,20 +88,18 @@ files:
|
|
88
88
|
- lib/hemlock.rb
|
89
89
|
- lib/hemlock/csv_to_flashcards.rb
|
90
90
|
- lib/hemlock/flashcard.rb
|
91
|
+
- lib/hemlock/turn.rb
|
91
92
|
- lib/hemlock/version.rb
|
92
93
|
- spec/hemlock/csv_to_flashcards_spec.rb
|
93
94
|
- spec/hemlock/flashcard_spec.rb
|
95
|
+
- spec/hemlock/turn_spec.rb
|
94
96
|
- spec/spec_helper.rb
|
95
97
|
- spec/stub.csv
|
96
98
|
homepage: https://github.com/shicholas/hemlock
|
97
99
|
licenses: []
|
98
100
|
metadata: {}
|
99
101
|
post_install_message:
|
100
|
-
rdoc_options:
|
101
|
-
- "--title"
|
102
|
-
- hemlock
|
103
|
-
- "--main"
|
104
|
-
- "-ri"
|
102
|
+
rdoc_options: []
|
105
103
|
require_paths:
|
106
104
|
- lib
|
107
105
|
- lib
|