ruby_drills 0.1.1 → 0.1.2
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 +7 -0
- data/.ruby-version +1 -1
- data/README.md +9 -7
- data/lib/ruby_drills/hash/group_by_drill.rb +28 -0
- data/lib/ruby_drills/hash/hash_drills.rb +0 -2
- data/lib/ruby_drills/hash/merge_drill.rb +31 -0
- data/lib/ruby_drills/hash/reject_drill.rb +29 -0
- data/lib/ruby_drills/version.rb +1 -1
- metadata +16 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91f76c86ec8041e57f52a23f20165a9582da601e
|
4
|
+
data.tar.gz: 2bacf608137271ce002a38cc6756843ba6150f11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fcf05241660654907cfd6220c9e8bde6c22ffc5b8a815cbfde1c7aa91a243ddd05d395191ed02061fed7f78266d9fcb586c88969420e1ab216440d58f982d9ea
|
7
|
+
data.tar.gz: fe99b5f260d3b21a6daebe98dd10660f46c8d9063fed34b9714d8826ce3c71e160fcc3462c11da2153bd8f0b70e420b9d36f477ecce6b066fe3122780b34f6c5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.1.2
|
data/README.md
CHANGED
@@ -12,10 +12,10 @@ Challenges in Ruby Drills focus on a specific method. Answers typically consist
|
|
12
12
|
$ gem install ruby_drills
|
13
13
|
$ ruby_drills
|
14
14
|
|
15
|
-
Drills run in the command line. You answer questions in drills using a REPL. This practice has the benefit of preparing you for developing at the REPL, a useful technique for trying out
|
15
|
+
Drills run in the command line. You answer questions in drills using a REPL. This practice has the benefit of preparing you for developing at the REPL, a useful technique for trying out language features or algorithms and a great complement to TDD.
|
16
16
|
|
17
|
-
Start by choosing an available drill from the menu. The
|
18
|
-
content, so start
|
17
|
+
Start by choosing an available drill from the menu. The Array and String
|
18
|
+
drills currently have the most content, so start with one of those!
|
19
19
|
|
20
20
|
## Example
|
21
21
|
|
@@ -75,14 +75,12 @@ Ultimately, we'd like to find out if drill and practice in Ruby and other progra
|
|
75
75
|
|
76
76
|
## Under the Hood: The Drill API
|
77
77
|
|
78
|
-
Each drill consists of
|
78
|
+
Each drill consists of four methods:
|
79
79
|
|
80
|
-
`setup`: initialize instance variables used in the drill.
|
80
|
+
`setup`: initialize instance variables used in the drill, including `@hints`, an array of hints that can guide the user towards the answer.
|
81
81
|
|
82
82
|
`show`: puts a string that describes the drill.
|
83
83
|
|
84
|
-
`hints`: return an array of hints that will be randomly shown.
|
85
|
-
|
86
84
|
`reference`: provide a reference solution as valid ruby code in string form. This will be eval'ed to determine if the user's input should be validated.
|
87
85
|
|
88
86
|
`valid?(input)`: a validation function that returns true or false. Used to see if a user's input that matches the reference solution meets other constraints.
|
@@ -105,9 +103,13 @@ If you're new to Github:
|
|
105
103
|
* [Bobby Norton](https://twitter.com/bobbynorton)
|
106
104
|
* [David Chelimsky](https://twitter.com/dchelimsky)
|
107
105
|
* [Joe Shidel](https://github.com/shidel-dev)
|
106
|
+
* [Katrina Owen](https://github.com/kytrinyx)
|
107
|
+
* [Lorena Nicole](https://github.com/lorenanicole)
|
108
108
|
|
109
109
|
## Acknowledgments
|
110
110
|
|
111
|
+
Thanks go to the contributors and to these outstanding individuals for making Ruby Drills possible:
|
112
|
+
|
111
113
|
* Sarah Aslanifar at [Tested Minds](http://literate.ly) for early review and feedback.
|
112
114
|
* The inaugural Chicago [Dev Bootcamp](http://devbootcamp.com) class of June 2013 for inspiring the project in the first place.
|
113
115
|
* [Erik Allar](https://twitter.com/allareri) for endless encouragement and enthusiasm.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class GroupByDrill < Drill
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@mario_bros = { "Mario"=>"good", "Luigi"=>"good", "Bowser"=>"evil", "Peach"=>"good", "Toad"=>"good", "Yoshi" => "superb" }
|
5
|
+
@hints = ["http://ruby-doc.org/core-2.1.0/Enumerable.html#method-i-group_by"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
puts %{We have one hash:
|
10
|
+
@mario_bros: #{@mario_bros.inspect}
|
11
|
+
|
12
|
+
Organize the Mario Bros by their personality:
|
13
|
+
#{expected.inspect}
|
14
|
+
|
15
|
+
Use the Enumerable method that will return a hash of key/value pairs where the keys values and the
|
16
|
+
values are an array of key/value pairs.
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def reference
|
21
|
+
"@mario_bros.group_by { |character, personality| personality } "
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid?(input)
|
25
|
+
input.include?('group_by')
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -8,8 +8,6 @@ A Hash is a dictionary-like collection of unique keys and their values.
|
|
8
8
|
Also called associative arrays, they are similar to Arrays, but where an
|
9
9
|
Array uses integers as its index, a Hash allows you to use any object type.
|
10
10
|
|
11
|
-
COMING SOON
|
12
|
-
|
13
11
|
------------------------------------------------------------------
|
14
12
|
}
|
15
13
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class MergeDrill < Drill
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@mismatched_animals = {"cat" => "woof", "dog" => "meow", "pig" => "oink" }
|
5
|
+
@matched_animals = { "cat" => "meow", "dog" => "woof", "frog" => "ribbit"}
|
6
|
+
@hints = ["http://www.ruby-doc.org/core-2.1.0/Hash.html#method-i-merge"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
puts %{We have two hashes:
|
11
|
+
@mismatched_animals: #{@mismatched_animals.inspect}
|
12
|
+
@matched_animals: #{@matched_animals.inspect}
|
13
|
+
|
14
|
+
Create a hash with properly matched key/pair values of animals and sounds:
|
15
|
+
#{expected.inspect}
|
16
|
+
|
17
|
+
Use the Hash method that will return a new hash with non-duplicate keys of
|
18
|
+
the first and second collectively. If the method uses a block it will
|
19
|
+
specify how to handle duplicate keys:
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def reference
|
24
|
+
"@matched_animals.merge(@mismatched_animals) { |key, v1, v2| v1 } "
|
25
|
+
end
|
26
|
+
|
27
|
+
def valid?(input)
|
28
|
+
input.include?('merge')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class RejectDrill < Drill
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@dog_breeds = { "black lab" => "medium", "chihuahua" => "small", "pitbull" => "medium",
|
5
|
+
"poodle" => "small", "great dane" => "large"}
|
6
|
+
@hints = ["http://www.ruby-doc.org/core-2.1.0/Hash.html#method-i-reject"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
puts %{
|
11
|
+
We have a hash:
|
12
|
+
@dog_breeds: #{@dog_breeds.inspect}
|
13
|
+
|
14
|
+
Filter this hash to return only small and medium dog breeds:
|
15
|
+
#{expected.inspect}
|
16
|
+
|
17
|
+
Use the Hash method that "returns a new hash consisting of entries for which the block returns false":
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def reference
|
22
|
+
"@dog_breeds.reject {|dog, size| size == 'large' }"
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid?(input)
|
26
|
+
input.include?('reject')
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/ruby_drills/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_drills
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bobby Norton
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pry
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: colorize
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: httparty
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - '='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - '='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - '='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - '='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,23 +69,20 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 2.14.0.rc1
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: 2.14.0.rc1
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: wrong
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - '='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - '='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -115,10 +102,10 @@ executables:
|
|
115
102
|
extensions: []
|
116
103
|
extra_rdoc_files: []
|
117
104
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
120
|
-
- .ruby-gemset
|
121
|
-
- .ruby-version
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".ruby-gemset"
|
108
|
+
- ".ruby-version"
|
122
109
|
- CHANGELOG.md
|
123
110
|
- CREDITS.txt
|
124
111
|
- Gemfile
|
@@ -144,7 +131,10 @@ files:
|
|
144
131
|
- lib/ruby_drills/data/gambler.ascii
|
145
132
|
- lib/ruby_drills/drill.rb
|
146
133
|
- lib/ruby_drills/drills.rb
|
134
|
+
- lib/ruby_drills/hash/group_by_drill.rb
|
147
135
|
- lib/ruby_drills/hash/hash_drills.rb
|
136
|
+
- lib/ruby_drills/hash/merge_drill.rb
|
137
|
+
- lib/ruby_drills/hash/reject_drill.rb
|
148
138
|
- lib/ruby_drills/sessions/collector_client.rb
|
149
139
|
- lib/ruby_drills/sessions/local.rb
|
150
140
|
- lib/ruby_drills/sessions/timestamp.rb
|
@@ -168,33 +158,26 @@ files:
|
|
168
158
|
homepage: http://rubydrills.com
|
169
159
|
licenses:
|
170
160
|
- Apache 2.0
|
161
|
+
metadata: {}
|
171
162
|
post_install_message:
|
172
163
|
rdoc_options: []
|
173
164
|
require_paths:
|
174
165
|
- lib
|
175
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
167
|
requirements:
|
178
|
-
- -
|
168
|
+
- - ">="
|
179
169
|
- !ruby/object:Gem::Version
|
180
170
|
version: '0'
|
181
|
-
segments:
|
182
|
-
- 0
|
183
|
-
hash: 2727376454008014728
|
184
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
172
|
requirements:
|
187
|
-
- -
|
173
|
+
- - ">="
|
188
174
|
- !ruby/object:Gem::Version
|
189
175
|
version: '0'
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
hash: 2727376454008014728
|
193
176
|
requirements: []
|
194
177
|
rubyforge_project:
|
195
|
-
rubygems_version:
|
178
|
+
rubygems_version: 2.3.0
|
196
179
|
signing_key:
|
197
|
-
specification_version:
|
180
|
+
specification_version: 4
|
198
181
|
summary: A deliberate practice tool for the core Ruby API's.
|
199
182
|
test_files:
|
200
183
|
- spec/commands_spec.rb
|