hackerrankit 0.1.0 → 0.1.1
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/README.md +3 -1
- data/lib/hackerrankit/problem_parser.rb +21 -3
- data/lib/hackerrankit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53a66ece3c2f9976a5ff1f11256cb5c906b69c5c
|
4
|
+
data.tar.gz: 1ab7df1202474be8393bd9e8dde3c62881b70ac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e31f5547af366c33b605a2b9b511a677f8a9350f32afd0671d7287b1021875174db18d8fab34dca3e99abfebd1dc38c3629c9bb7353c32eb62b935ee326d8e11
|
7
|
+
data.tar.gz: 670a2e1674f583ddac019db97575c1f580e4c29f3d18ecdcfab3962a9806c7914b0b020e79ba1beb507491e90bf2e32038ca7336531d0456447fdb45ca602064
|
data/README.md
CHANGED
@@ -18,7 +18,9 @@ gem install hackerrankit
|
|
18
18
|
hackerrankit [url] [language]
|
19
19
|
```
|
20
20
|
|
21
|
-
where
|
21
|
+
where:
|
22
|
+
|
23
|
+
`[url]` is the url to the problem on Hackerrank.
|
22
24
|
|
23
25
|
`language` is the language you are going to solve the problem. To keep this gem simple, I don't consider the situation where you want to solve a problem with more than one language. Default: `C++`.
|
24
26
|
|
@@ -27,11 +27,27 @@ module Hackerrankit
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def get_problem_sample_input_from_json
|
30
|
-
doc.css("div.challenge_sample_input_body code").text
|
30
|
+
result = doc.css("div.challenge_sample_input_body code").text
|
31
|
+
if result.strip.size == 0
|
32
|
+
result = doc.css("div.challenge_sample_input_body p").text
|
33
|
+
end
|
34
|
+
if result.strip.size == 0
|
35
|
+
result = doc.xpath('//strong[contains(text(), "Sample Input")]').first
|
36
|
+
.parent.next_element.text
|
37
|
+
end
|
38
|
+
return result
|
31
39
|
end
|
32
40
|
|
33
41
|
def get_problem_sample_output_from_json
|
34
|
-
doc.css("div.challenge_sample_output_body code").text
|
42
|
+
result = doc.css("div.challenge_sample_output_body code").text
|
43
|
+
if result.strip.size == 0
|
44
|
+
result = doc.css("div.challenge_sample_output_body p").text
|
45
|
+
end
|
46
|
+
if result.strip.size == 0
|
47
|
+
result = doc.xpath('//strong[contains(text(), "Sample Output")]').first
|
48
|
+
.parent.next_element.text
|
49
|
+
end
|
50
|
+
return result
|
35
51
|
end
|
36
52
|
|
37
53
|
def get_problem_slug(url)
|
@@ -45,7 +61,9 @@ module Hackerrankit
|
|
45
61
|
|
46
62
|
def doc
|
47
63
|
@doc ||= Nokogiri::HTML(
|
48
|
-
@problem_json['model']['body_html'].force_encoding('UTF-8')
|
64
|
+
@problem_json['model']['body_html'].force_encoding('UTF-8').tap do |html|
|
65
|
+
# puts html
|
66
|
+
end
|
49
67
|
)
|
50
68
|
end
|
51
69
|
end
|
data/lib/hackerrankit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hackerrankit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tranvictor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|