hackerrankit 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75ab49cacab002c0a5e70b0eed006fd0fd0b6b1d
4
- data.tar.gz: 38450fcfbf380dc0a37f4f141ab2b48370a25b75
3
+ metadata.gz: 53a66ece3c2f9976a5ff1f11256cb5c906b69c5c
4
+ data.tar.gz: 1ab7df1202474be8393bd9e8dde3c62881b70ac7
5
5
  SHA512:
6
- metadata.gz: 55d8923b39e1d317a897a151d37f28bf8aca10a9036f820beb097cc198edab79141abc68a070ffda5803035720648d9a02e7226820518e8717522b23bccb436e
7
- data.tar.gz: 0ac95fb7c99ccf5ff22aa0c5968a1b87ba29bd0c1f5800dcddf9211fb9d82636e5e75ccf765ccaceca346aecbf32e7b92f7de4627fc28ccb11304c4814e64c96
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 `[url]` is the url to the problem on Hackerrank.
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
@@ -1,3 +1,3 @@
1
1
  module Hackerrankit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler