xkcd 0.0.1 → 0.0.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.
Files changed (2) hide show
  1. data/lib/xkcd.rb +10 -1
  2. metadata +18 -7
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/evn ruby
2
2
  require 'net/http'
3
+ require 'open-uri'
3
4
  class XKCD
4
- def self.get()
5
+
6
+ def self.comic()
5
7
  # This method gets random comic links from xkcd, the uri is the redirected location found in the resp headers
6
8
  uri = URI.parse 'http://dynamic.xkcd.com/random/comic/'
7
9
  req = Net::HTTP::Get.new(uri.request_uri)
@@ -11,4 +13,11 @@ class XKCD
11
13
  }
12
14
  res["location"]
13
15
  end
16
+
17
+ def self.img
18
+ url = 'http://dynamic.xkcd.com/random/comic/'
19
+ html = open(url).read()
20
+ imgs = URI.extract(html).select{ |l| l[/comics\//]}
21
+ imgs.first
22
+ end
14
23
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xkcd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Hemanth.HM
@@ -9,8 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2012-05-20 00:00:00 +05:30
13
- default_executable: xkcd
18
+ date: 2012-05-20 00:00:00 Z
14
19
  dependencies: []
15
20
 
16
21
  description: A simple gem to get random img url from xkcd
@@ -25,7 +30,7 @@ files:
25
30
  - Rakefile
26
31
  - lib/xkcd.rb
27
32
  - bin/xkcd
28
- has_rdoc: true
33
+ - test/test_karam.rb
29
34
  homepage: http://rubygems.org/gems/xkcd
30
35
  licenses: []
31
36
 
@@ -35,21 +40,27 @@ rdoc_options: []
35
40
  require_paths:
36
41
  - lib
37
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
38
44
  requirements:
39
45
  - - ">="
40
46
  - !ruby/object:Gem::Version
47
+ hash: 3
48
+ segments:
49
+ - 0
41
50
  version: "0"
42
- version:
43
51
  required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
44
53
  requirements:
45
54
  - - ">="
46
55
  - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
47
59
  version: "0"
48
- version:
49
60
  requirements: []
50
61
 
51
62
  rubyforge_project:
52
- rubygems_version: 1.3.5
63
+ rubygems_version: 1.8.24
53
64
  signing_key:
54
65
  specification_version: 3
55
66
  summary: XCKD randome img urls!