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.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +155 -0
  8. data/Rakefile +9 -0
  9. data/bin/console +14 -0
  10. data/bin/rorr +5 -0
  11. data/bin/setup +8 -0
  12. data/lib/rorr.rb +22 -0
  13. data/lib/rorr/base.rb +15 -0
  14. data/lib/rorr/config.rb +14 -0
  15. data/lib/rorr/dont_ask_me.rb +60 -0
  16. data/lib/rorr/init.rb +24 -0
  17. data/lib/rorr/main.rb +28 -0
  18. data/lib/rorr/return_value.rb +68 -0
  19. data/lib/rorr/score.rb +76 -0
  20. data/lib/rorr/test_pass.rb +96 -0
  21. data/lib/rorr/ui.rb +86 -0
  22. data/lib/rorr/version.rb +3 -0
  23. data/lib/spec_helper.rb +4 -0
  24. data/rorr.gemspec +27 -0
  25. data/spec/check_answer/normal/001_spec.rb +14 -0
  26. data/spec/check_answer/normal/002_spec.rb +14 -0
  27. data/spec/check_answer/normal/003_spec.rb +14 -0
  28. data/spec/check_answer/normal/004_spec.rb +14 -0
  29. data/spec/check_answer/normal/005_spec.rb +11 -0
  30. data/spec/check_answer/normal/006_spec.rb +14 -0
  31. data/spec/check_answer/normal/007_spec.rb +14 -0
  32. data/spec/check_answer/normal/008_spec.rb +14 -0
  33. data/spec/check_answer/normal/009_spec.rb +11 -0
  34. data/spec/check_answer/normal/010_spec.rb +11 -0
  35. data/spec/rorr/config_spec.rb +15 -0
  36. data/spec/rorr/score_spec.rb +70 -0
  37. data/spec/rorr/ui_spec.rb +58 -0
  38. data/spec/spec_helper.rb +6 -0
  39. data/templates/README.erb +2 -0
  40. data/templates/Report.erb +14 -0
  41. data/templates/play.erb +3 -0
  42. data/topic/methods/normal/001.rb +15 -0
  43. data/topic/methods/normal/002.rb +17 -0
  44. data/topic/methods/normal/003.rb +19 -0
  45. data/topic/methods/normal/004.rb +16 -0
  46. data/topic/methods/normal/005.rb +16 -0
  47. data/topic/methods/normal/006.rb +15 -0
  48. data/topic/methods/normal/007.rb +16 -0
  49. data/topic/methods/normal/008.rb +17 -0
  50. data/topic/methods/normal/009.rb +16 -0
  51. data/topic/methods/normal/010.rb +17 -0
  52. data/topic/questions/normal/001.rb +19 -0
  53. data/topic/questions/normal/002.rb +19 -0
  54. data/topic/questions/normal/003.rb +1 -0
  55. data/topic/questions/normal/004.rb +1 -0
  56. data/topic/questions/normal/005.rb +4 -0
  57. data/topic/questions/normal/006.rb +14 -0
  58. data/topic/questions/normal/007.rb +14 -0
  59. data/topic/questions/normal/008.rb +14 -0
  60. data/topic/questions/normal/009.rb +14 -0
  61. data/topic/questions/normal/010.rb +14 -0
  62. data/topic/questions/normal/011.rb +4 -0
  63. data/topic/questions/normal/012.rb +4 -0
  64. data/topic/questions/normal/013.rb +5 -0
  65. data/topic/questions/normal/014.rb +5 -0
  66. data/topic/questions/normal/015.rb +5 -0
  67. data/topic/questions/normal/016.rb +5 -0
  68. data/topic/questions/normal/017.rb +2 -0
  69. data/topic/questions/normal/018.rb +2 -0
  70. data/topic/questions/normal/019.rb +1 -0
  71. data/topic/questions/normal/020.rb +14 -0
  72. data/topic/rails/001.rb +6 -0
  73. data/topic/rails/002.rb +12 -0
  74. data/topic/rails/003.rb +7 -0
  75. data/topic/rails/004.rb +20 -0
  76. data/topic/rails/005.rb +19 -0
  77. data/topic/rails/006.rb +17 -0
  78. data/topic/rails/007.rb +4 -0
  79. data/topic/rails/008.rb +6 -0
  80. data/topic/rails/009.rb +11 -0
  81. data/topic/rails/010.rb +9 -0
  82. data/topic/ruby/001.rb +5 -0
  83. data/topic/ruby/002.rb +9 -0
  84. data/topic/ruby/003.rb +8 -0
  85. data/topic/ruby/004.rb +4 -0
  86. data/topic/ruby/005.rb +5 -0
  87. data/topic/ruby/006.rb +8 -0
  88. data/topic/ruby/007.rb +8 -0
  89. data/topic/ruby/008.rb +7 -0
  90. data/topic/ruby/009.rb +5 -0
  91. data/topic/ruby/010.rb +6 -0
  92. metadata +207 -0
@@ -0,0 +1,14 @@
1
+ class Foo
2
+ def method1
3
+ rorr = Foo.new
4
+ rorr.method2
5
+ end
6
+
7
+ protected
8
+
9
+ def method2
10
+ "Hello World"
11
+ end
12
+ end
13
+
14
+ Foo.new.method1
@@ -0,0 +1,14 @@
1
+ class Foo
2
+ def method1
3
+ rorr = Foo.new
4
+ rorr.method2
5
+ end
6
+
7
+ private
8
+
9
+ def method2
10
+ "Hello World"
11
+ end
12
+ end
13
+
14
+ Foo.new.method1
@@ -0,0 +1,4 @@
1
+ foo, bar = false, 2
2
+ foo ||= bar
3
+
4
+ foo
@@ -0,0 +1,4 @@
1
+ foo, bar = [], 2
2
+ foo ||= bar
3
+
4
+ foo
@@ -0,0 +1,5 @@
1
+ def times_two(arg1);
2
+ arg1 * 2;
3
+ end
4
+
5
+ times_two (5)
@@ -0,0 +1,5 @@
1
+ def sum(arg1, arg2);
2
+ arg1 + arg2;
3
+ end
4
+
5
+ sum (1, 2)
@@ -0,0 +1,5 @@
1
+ item1 = "foo"
2
+ item2 = item1
3
+ item1.concat "bar"
4
+
5
+ item2
@@ -0,0 +1,5 @@
1
+ item1 = "foo"
2
+ item2 = item1
3
+ item1 += "bar"
4
+
5
+ item2
@@ -0,0 +1,2 @@
1
+ ary = []
2
+ ary ? true : false
@@ -0,0 +1,2 @@
1
+ str = ""
2
+ str ? true : false
@@ -0,0 +1 @@
1
+ -> (a){a}["Hello world"]
@@ -0,0 +1,14 @@
1
+ class Foo
2
+ def ==(b)
3
+ return 'Hi'
4
+ end
5
+ def size()
6
+ self
7
+ end
8
+ end
9
+
10
+ def empty?(s)
11
+ return s.size == 0
12
+ end
13
+
14
+ empty?(Foo.new)
@@ -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).
@@ -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}
@@ -0,0 +1,7 @@
1
+ 1.in?([1,2])
2
+
3
+ # solution
4
+ Returns true if this object is included in the argument. Argument must be any object which responds to #include?.
5
+
6
+ characters = ["Konata", "Kagami", "Tsukasa"]
7
+ "Konata".in?(characters) # => true
@@ -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
@@ -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"
@@ -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
@@ -0,0 +1,4 @@
1
+ DateTime.current
2
+
3
+ # solution
4
+ Returns Time.zone.now.to_datetime when Time.zone or config.time_zone are set, otherwise returns Time.now.to_datetime.
@@ -0,0 +1,6 @@
1
+ Array.wrap(nil) # => []
2
+ Array.wrap([1, 2, 3]) # => [1, 2, 3]
3
+ Array.wrap(0) # => [0]
4
+
5
+ # solution
6
+ Wraps its argument in an array unless it is already an array (or array-like).
@@ -0,0 +1,11 @@
1
+ .blank?
2
+
3
+ # solution
4
+ An object is blank if it’s false, empty, or a whitespace string.
5
+ For example, ”, ‘ ’, nil, [], and {} are all blank.
6
+
7
+ This simplifies
8
+
9
+ address.nil? || address.empty?
10
+ to
11
+ address.blank?
@@ -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.
@@ -0,0 +1,5 @@
1
+ Yukihiro Matsumoto
2
+
3
+ # solution
4
+ Ruby is a dynamic, reflective, object-oriented, general-purpose programming language.
5
+ It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.
@@ -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"
@@ -0,0 +1,8 @@
1
+ [1,2,3,4,5].sample
2
+
3
+ # solution
4
+ Choose a random element or n random elements from the array.
5
+
6
+ a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
7
+ a.sample #=> 7
8
+ a.sample(4) #=> [6, 4, 2, 5]
@@ -0,0 +1,4 @@
1
+ Date.today
2
+
3
+ # solution
4
+ Creates a date object denoting the present day.
@@ -0,0 +1,5 @@
1
+ FileUtils.rm_r 'somedir'
2
+
3
+ # solution
4
+ rm_r(list, options = {})
5
+ remove files list[0] list[1]… If list[n] is a directory, removes its all contents recursively.
@@ -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.
@@ -0,0 +1,8 @@
1
+ Array(foo: :bar) # => [[:foo, :bar]]
2
+
3
+ # solution
4
+ Array(arg) → array
5
+ Returns arg as an Array.
6
+ First tries to call to_ary on arg, then to_a.
7
+
8
+ Array(1..5) #=> [1, 2, 3, 4, 5]
@@ -0,0 +1,7 @@
1
+ .downcase!
2
+
3
+ # solution
4
+ downcase! → str or nil
5
+ Downcases the contents of str, returning nil if no changes were made.
6
+
7
+ 'AbC'.downcase! #=> "abc"
@@ -0,0 +1,5 @@
1
+ Time.now
2
+
3
+ # solution
4
+ Alias for Time.new.
5
+ Returns a Time object initialized to the current system time.
@@ -0,0 +1,6 @@
1
+ .empty?
2
+
3
+ # solution
4
+ Returns true if self contains no elements.
5
+
6
+ [].empty? #=> true
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: []