rorr 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +155 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/rorr +5 -0
- data/bin/setup +8 -0
- data/lib/rorr.rb +22 -0
- data/lib/rorr/base.rb +15 -0
- data/lib/rorr/config.rb +14 -0
- data/lib/rorr/dont_ask_me.rb +60 -0
- data/lib/rorr/init.rb +24 -0
- data/lib/rorr/main.rb +28 -0
- data/lib/rorr/return_value.rb +68 -0
- data/lib/rorr/score.rb +76 -0
- data/lib/rorr/test_pass.rb +96 -0
- data/lib/rorr/ui.rb +86 -0
- data/lib/rorr/version.rb +3 -0
- data/lib/spec_helper.rb +4 -0
- data/rorr.gemspec +27 -0
- data/spec/check_answer/normal/001_spec.rb +14 -0
- data/spec/check_answer/normal/002_spec.rb +14 -0
- data/spec/check_answer/normal/003_spec.rb +14 -0
- data/spec/check_answer/normal/004_spec.rb +14 -0
- data/spec/check_answer/normal/005_spec.rb +11 -0
- data/spec/check_answer/normal/006_spec.rb +14 -0
- data/spec/check_answer/normal/007_spec.rb +14 -0
- data/spec/check_answer/normal/008_spec.rb +14 -0
- data/spec/check_answer/normal/009_spec.rb +11 -0
- data/spec/check_answer/normal/010_spec.rb +11 -0
- data/spec/rorr/config_spec.rb +15 -0
- data/spec/rorr/score_spec.rb +70 -0
- data/spec/rorr/ui_spec.rb +58 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/README.erb +2 -0
- data/templates/Report.erb +14 -0
- data/templates/play.erb +3 -0
- data/topic/methods/normal/001.rb +15 -0
- data/topic/methods/normal/002.rb +17 -0
- data/topic/methods/normal/003.rb +19 -0
- data/topic/methods/normal/004.rb +16 -0
- data/topic/methods/normal/005.rb +16 -0
- data/topic/methods/normal/006.rb +15 -0
- data/topic/methods/normal/007.rb +16 -0
- data/topic/methods/normal/008.rb +17 -0
- data/topic/methods/normal/009.rb +16 -0
- data/topic/methods/normal/010.rb +17 -0
- data/topic/questions/normal/001.rb +19 -0
- data/topic/questions/normal/002.rb +19 -0
- data/topic/questions/normal/003.rb +1 -0
- data/topic/questions/normal/004.rb +1 -0
- data/topic/questions/normal/005.rb +4 -0
- data/topic/questions/normal/006.rb +14 -0
- data/topic/questions/normal/007.rb +14 -0
- data/topic/questions/normal/008.rb +14 -0
- data/topic/questions/normal/009.rb +14 -0
- data/topic/questions/normal/010.rb +14 -0
- data/topic/questions/normal/011.rb +4 -0
- data/topic/questions/normal/012.rb +4 -0
- data/topic/questions/normal/013.rb +5 -0
- data/topic/questions/normal/014.rb +5 -0
- data/topic/questions/normal/015.rb +5 -0
- data/topic/questions/normal/016.rb +5 -0
- data/topic/questions/normal/017.rb +2 -0
- data/topic/questions/normal/018.rb +2 -0
- data/topic/questions/normal/019.rb +1 -0
- data/topic/questions/normal/020.rb +14 -0
- data/topic/rails/001.rb +6 -0
- data/topic/rails/002.rb +12 -0
- data/topic/rails/003.rb +7 -0
- data/topic/rails/004.rb +20 -0
- data/topic/rails/005.rb +19 -0
- data/topic/rails/006.rb +17 -0
- data/topic/rails/007.rb +4 -0
- data/topic/rails/008.rb +6 -0
- data/topic/rails/009.rb +11 -0
- data/topic/rails/010.rb +9 -0
- data/topic/ruby/001.rb +5 -0
- data/topic/ruby/002.rb +9 -0
- data/topic/ruby/003.rb +8 -0
- data/topic/ruby/004.rb +4 -0
- data/topic/ruby/005.rb +5 -0
- data/topic/ruby/006.rb +8 -0
- data/topic/ruby/007.rb +8 -0
- data/topic/ruby/008.rb +7 -0
- data/topic/ruby/009.rb +5 -0
- data/topic/ruby/010.rb +6 -0
- metadata +207 -0
@@ -0,0 +1 @@
|
|
1
|
+
-> (a){a}["Hello world"]
|
data/topic/rails/001.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
David Heinemeier Hansson (DHH)
|
2
|
+
|
3
|
+
# solution
|
4
|
+
David Heinemeier Hansson (born 15 October 1979;known to the Ruby and car racing communities as DHH) is a Danish programmer and the creator of the popular Ruby on Rails web development framework and the Instiki wiki.
|
5
|
+
|
6
|
+
He is also a partner at the web-based software development firm Basecamp (formerly 37signals).
|
data/topic/rails/002.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
aaa.instance_values
|
2
|
+
|
3
|
+
# solution
|
4
|
+
Returns a hash with string keys that maps instance variable names without “@” to their corresponding values.
|
5
|
+
|
6
|
+
class C
|
7
|
+
def initialize(x, y)
|
8
|
+
@x, @y = x, y
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
|
data/topic/rails/003.rb
ADDED
data/topic/rails/004.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
'hello'.at(4) # => 'o'
|
2
|
+
|
3
|
+
# solution
|
4
|
+
If you pass a single integer, returns a substring of one character at that position.
|
5
|
+
|
6
|
+
str = "hello"
|
7
|
+
str.at(0) # => "h"
|
8
|
+
str.at(1..3) # => "ell"
|
9
|
+
str.at(-2) # => "l"
|
10
|
+
str.at(-2..-1) # => "lo"
|
11
|
+
str.at(5) # => nil
|
12
|
+
str.at(5..-1) # => ""
|
13
|
+
|
14
|
+
If a Regexp is given, the matching portion of the string is returned. If a String is given, that given string is returned if it occurs in the string. In both cases, nil is returned if there is no match.
|
15
|
+
|
16
|
+
str = "hello"
|
17
|
+
str.at(/lo/) # => "lo"
|
18
|
+
str.at(/ol/) # => nil
|
19
|
+
str.at("lo") # => "lo"
|
20
|
+
str.at("ol") # => nil
|
data/topic/rails/005.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
alias_attribute
|
2
|
+
|
3
|
+
# solution
|
4
|
+
Allows you to make aliases for attributes, which includes getter, setter, and query methods.
|
5
|
+
|
6
|
+
class Content < ActiveRecord::Base
|
7
|
+
# has a title attribute
|
8
|
+
end
|
9
|
+
|
10
|
+
class Email < Content
|
11
|
+
alias_attribute :subject, :title
|
12
|
+
end
|
13
|
+
|
14
|
+
e = Email.find(1)
|
15
|
+
e.title # => "Superstars"
|
16
|
+
e.subject # => "Superstars"
|
17
|
+
e.subject? # => true
|
18
|
+
e.subject = "Megastars"
|
19
|
+
e.title # => "Megastars"
|
data/topic/rails/006.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class_attribute
|
2
|
+
|
3
|
+
# solution
|
4
|
+
Declare a class-level attribute whose value is inheritable by subclasses. Subclasses can change their own value and it will not impact parent class.
|
5
|
+
|
6
|
+
class Base
|
7
|
+
class_attribute :setting
|
8
|
+
end
|
9
|
+
|
10
|
+
class Subclass < Base
|
11
|
+
end
|
12
|
+
|
13
|
+
Base.setting = true
|
14
|
+
Subclass.setting # => true
|
15
|
+
Subclass.setting = false
|
16
|
+
Subclass.setting # => false
|
17
|
+
Base.setting # => true
|
data/topic/rails/007.rb
ADDED
data/topic/rails/008.rb
ADDED
data/topic/rails/009.rb
ADDED
data/topic/rails/010.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
(1..10).include?(3..7) # => true
|
2
|
+
(1..10).include?(0..7) # => false
|
3
|
+
|
4
|
+
# solution
|
5
|
+
(1..5).include?(2..3) # => false
|
6
|
+
require 'active_support/all'
|
7
|
+
(1..5).include?(2..3) # => true
|
8
|
+
|
9
|
+
Active Support extends these methods so that the argument may be another range in turn.
|
data/topic/ruby/001.rb
ADDED
data/topic/ruby/002.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
'[%s]' % 'same old drag' # => '[same old drag]'
|
2
|
+
|
3
|
+
# solution
|
4
|
+
str % arg → new_str
|
5
|
+
Format — Uses str as a format specification, and returns the result of applying it to arg.
|
6
|
+
|
7
|
+
"%05d" % 123 #=> "00123"
|
8
|
+
"%-5s: %08x" % [ "ID", "self.object_id" ] #=> "ID : 200e14d6"
|
9
|
+
"foo = %{foo}" % { :foo => 'bar' } #=> "foo = bar"
|
data/topic/ruby/003.rb
ADDED
data/topic/ruby/004.rb
ADDED
data/topic/ruby/005.rb
ADDED
data/topic/ruby/006.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
a.cycle { |x| puts x } # print, a, b, c, a, b, c,.. forever..
|
2
|
+
|
3
|
+
# solution
|
4
|
+
cycle(n=nil) { |obj| block } → nil
|
5
|
+
|
6
|
+
Calls block for each element of enum repeatedly n times or forever if none or nil is given.
|
7
|
+
If a non-positive number is given or the collection is empty, does nothing.
|
8
|
+
Returns nil if the loop has finished without getting interrupted.
|
data/topic/ruby/007.rb
ADDED
data/topic/ruby/008.rb
ADDED
data/topic/ruby/009.rb
ADDED
data/topic/ruby/010.rb
ADDED
metadata
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rorr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leon Ji
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coderay
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
description: This is a test designed to evaluate the Ruby or Rails proficiency and
|
84
|
+
artificial intelligence in a fun, interactive way.
|
85
|
+
email:
|
86
|
+
- mgleon08@gmail.com
|
87
|
+
executables:
|
88
|
+
- rorr
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/rorr
|
101
|
+
- bin/setup
|
102
|
+
- lib/rorr.rb
|
103
|
+
- lib/rorr/base.rb
|
104
|
+
- lib/rorr/config.rb
|
105
|
+
- lib/rorr/dont_ask_me.rb
|
106
|
+
- lib/rorr/init.rb
|
107
|
+
- lib/rorr/main.rb
|
108
|
+
- lib/rorr/return_value.rb
|
109
|
+
- lib/rorr/score.rb
|
110
|
+
- lib/rorr/test_pass.rb
|
111
|
+
- lib/rorr/ui.rb
|
112
|
+
- lib/rorr/version.rb
|
113
|
+
- lib/spec_helper.rb
|
114
|
+
- rorr.gemspec
|
115
|
+
- spec/check_answer/normal/001_spec.rb
|
116
|
+
- spec/check_answer/normal/002_spec.rb
|
117
|
+
- spec/check_answer/normal/003_spec.rb
|
118
|
+
- spec/check_answer/normal/004_spec.rb
|
119
|
+
- spec/check_answer/normal/005_spec.rb
|
120
|
+
- spec/check_answer/normal/006_spec.rb
|
121
|
+
- spec/check_answer/normal/007_spec.rb
|
122
|
+
- spec/check_answer/normal/008_spec.rb
|
123
|
+
- spec/check_answer/normal/009_spec.rb
|
124
|
+
- spec/check_answer/normal/010_spec.rb
|
125
|
+
- spec/rorr/config_spec.rb
|
126
|
+
- spec/rorr/score_spec.rb
|
127
|
+
- spec/rorr/ui_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- templates/README.erb
|
130
|
+
- templates/Report.erb
|
131
|
+
- templates/play.erb
|
132
|
+
- topic/methods/normal/001.rb
|
133
|
+
- topic/methods/normal/002.rb
|
134
|
+
- topic/methods/normal/003.rb
|
135
|
+
- topic/methods/normal/004.rb
|
136
|
+
- topic/methods/normal/005.rb
|
137
|
+
- topic/methods/normal/006.rb
|
138
|
+
- topic/methods/normal/007.rb
|
139
|
+
- topic/methods/normal/008.rb
|
140
|
+
- topic/methods/normal/009.rb
|
141
|
+
- topic/methods/normal/010.rb
|
142
|
+
- topic/questions/normal/001.rb
|
143
|
+
- topic/questions/normal/002.rb
|
144
|
+
- topic/questions/normal/003.rb
|
145
|
+
- topic/questions/normal/004.rb
|
146
|
+
- topic/questions/normal/005.rb
|
147
|
+
- topic/questions/normal/006.rb
|
148
|
+
- topic/questions/normal/007.rb
|
149
|
+
- topic/questions/normal/008.rb
|
150
|
+
- topic/questions/normal/009.rb
|
151
|
+
- topic/questions/normal/010.rb
|
152
|
+
- topic/questions/normal/011.rb
|
153
|
+
- topic/questions/normal/012.rb
|
154
|
+
- topic/questions/normal/013.rb
|
155
|
+
- topic/questions/normal/014.rb
|
156
|
+
- topic/questions/normal/015.rb
|
157
|
+
- topic/questions/normal/016.rb
|
158
|
+
- topic/questions/normal/017.rb
|
159
|
+
- topic/questions/normal/018.rb
|
160
|
+
- topic/questions/normal/019.rb
|
161
|
+
- topic/questions/normal/020.rb
|
162
|
+
- topic/rails/001.rb
|
163
|
+
- topic/rails/002.rb
|
164
|
+
- topic/rails/003.rb
|
165
|
+
- topic/rails/004.rb
|
166
|
+
- topic/rails/005.rb
|
167
|
+
- topic/rails/006.rb
|
168
|
+
- topic/rails/007.rb
|
169
|
+
- topic/rails/008.rb
|
170
|
+
- topic/rails/009.rb
|
171
|
+
- topic/rails/010.rb
|
172
|
+
- topic/ruby/001.rb
|
173
|
+
- topic/ruby/002.rb
|
174
|
+
- topic/ruby/003.rb
|
175
|
+
- topic/ruby/004.rb
|
176
|
+
- topic/ruby/005.rb
|
177
|
+
- topic/ruby/006.rb
|
178
|
+
- topic/ruby/007.rb
|
179
|
+
- topic/ruby/008.rb
|
180
|
+
- topic/ruby/009.rb
|
181
|
+
- topic/ruby/010.rb
|
182
|
+
homepage: https://github.com/mgleon08/rorr
|
183
|
+
licenses:
|
184
|
+
- MIT
|
185
|
+
metadata: {}
|
186
|
+
post_install_message:
|
187
|
+
rdoc_options: []
|
188
|
+
require_paths:
|
189
|
+
- lib
|
190
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
requirements: []
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 2.4.5.1
|
203
|
+
signing_key:
|
204
|
+
specification_version: 4
|
205
|
+
summary: The easiest way to evaluate the Ruby or Rails proficiency in a interactive
|
206
|
+
way.
|
207
|
+
test_files: []
|