studi-budi 0.2.1 → 0.3.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
data/lib/studi-budi.rb CHANGED
@@ -33,7 +33,6 @@ class StudiBudi
33
33
  @collection_name = gets.chomp
34
34
  puts "Enter the file path of your new collection (leave off the last \"/\"):"
35
35
  @collection_path = gets.chomp
36
- # something about setting up the collection hash & file here
37
36
  @file = File.open("#{@collection_path}/#{@collection_name}.txt", "w+")
38
37
  adding_cards
39
38
  end
@@ -44,6 +43,7 @@ class StudiBudi
44
43
  puts "Enter the file path of your existing collection (leave off the last \"/\"):"
45
44
  @collection_path = gets.chomp
46
45
  @file = File.open("#{@collection_path}/#{@collection_name}.txt", "a+")
46
+ @readlines_set = @file.readlines
47
47
  menu
48
48
  end
49
49
 
@@ -56,13 +56,10 @@ class StudiBudi
56
56
  if pref == "1"
57
57
  adding_cards
58
58
  elsif pref == "2"
59
- reviewing_cards # need to do same kind of thing as in initialize
59
+ reviewing_cards
60
60
  end
61
61
  end
62
62
 
63
-
64
- # so they're going to need to read the first line
65
-
66
63
  def adding_cards
67
64
  puts "Type the term you'd like to practice and its answer separated by a comma, then hit [enter]. This adds that 'card' to your collection. This will continue until BLAHBLAH To review your cards BLAHBLAHBLAH"
68
65
  answer = gets.chomp
@@ -87,57 +84,33 @@ class StudiBudi
87
84
  prompt = "Back: "
88
85
  cards_correct = 0
89
86
  cards_wrong = 0
90
- puts "Let's review some of your cards. To exit, simply hit [enter]."
91
- # so need to count total lines (line count? google)
92
- # need to set up a variable that will be a random number between 0 and max line number - 1
93
- # then make sure to always have it be an odd number, then can have current_card be a random key
94
- # then do that number + 1 to get the value
95
- readlines_set = @file.readlines
96
- total_lines = readlines_set.size
97
- # total_lines = @file.readlines.size
98
- puts random_line = rand(0..total_lines)
99
- puts answer_line = random_line + 1
100
- until random_line % 2 == 0
101
- random_line = rand(0..total_lines)
102
- end
103
- puts "card front: #{current_card = File.readlines(@file)[random_line]}"
104
- user_answer = gets.chomp
105
- if user_answer == readlines_set[answer_line] # @file.readlines[answer_line] # "#{random_line + 1}".to_i]
106
- puts "CORRECT"
107
- cards_correct += 1
108
- else
109
- puts "WRONG"
110
- cards_wrong += 1
111
- end
87
+ puts "Let's review some of your cards. How many incorrect answers to you want to enter before quitting because you failed?"
88
+ stop_at = gets.chomp.to_i
89
+ puts "Okay, we'll stop after #{stop_at} wrong answers."
112
90
 
113
- # if random_line % 2 == 0
114
- # puts "it's even"
115
- # else
116
- # puts "it's odd"
117
- # end
91
+ total_lines = (@readlines_set.size - 1)
92
+ random_line = rand(0..total_lines)
93
+ answer_line = random_line + 1
118
94
 
119
- # total_lines = %x{wc -l '#{filename}'}.to_i
120
-
121
- # until gets.chomp == nil
122
- # cards_correct = 0
123
- # cards_wrong = 0
124
-
125
- # line_number =
126
-
127
- # puts current_card = File.readlines(@file)[rand]
128
- # user_answer = gets.chomp
129
- # if user_answer == HASHHH[current_card]
130
- # puts "CORRECT"
131
- # cards_correct += 1
132
- # else
133
- # puts "WRONG"
134
- # cards_wrong += 1
135
- # end
136
- # end
95
+ while cards_wrong < stop_at
96
+ random_line = rand(0..total_lines)
97
+ until random_line % 2 == 0
98
+ random_line = rand(0..total_lines)
99
+ end
100
+ answer_line = random_line + 1
101
+ puts "What's on the back of this card?"
102
+ puts @readlines_set[random_line]
103
+ user_answer = gets.chomp
104
+ if user_answer == @readlines_set[answer_line].chomp
105
+ puts "CORRECT\n"
106
+ cards_correct += 1
107
+ else
108
+ puts "WRONG"
109
+ cards_wrong += 1
110
+ end
111
+ end
137
112
 
138
113
  puts "You got #{cards_correct} flash cards correct. Good job!
139
114
  Pst! You also got #{cards_wrong} flash cards wrong."
140
115
  end
141
- end
142
-
143
- start = StudiBudi.new
116
+ end
@@ -9,20 +9,19 @@ describe "StudiBudi" do
9
9
  end
10
10
 
11
11
  it "should get the user's input" do
12
- @study_helper.stub!(:gets) {"phrase"} # @study_helper.action.should eq
12
+ @study_helper.stub!(:gets) {"1"} # @study_helper.action.should eq
13
+ @study_helper.should_receive(:create)
13
14
  end
14
15
 
16
+ it "should begin adding cards after creating a collection" do
17
+ @study_helper.create.should_receive(:adding_cards)
18
+ end
15
19
 
16
20
  # "if I make a card collection called 'Potatos'" do
17
21
  # adfld.@collection_name should_eq "Potatos"
18
22
  # end
19
23
 
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
24
+ # I "should say I'm sorry I didn't finish this. I spent all my time on the .rb and that first test" do
25
+ # @sol.apology.should eq "Please forgive me"
26
+ # end
28
27
  end
data/studi-budi.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "studi-budi"
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sol W"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: studi-budi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  segments:
97
97
  - 0
98
- hash: -3205410569868199299
98
+ hash: 2489389209653597560
99
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements: