nine-gag 0.1.1 → 0.1.2

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: 1a03b9d37f6806e7af4939f5c5fe0c5b6bbc0c60
4
- data.tar.gz: ed67c7abfc014eb84413d3bfe483d9ab9f1b4aff
3
+ metadata.gz: dc18e2768eae1aa8a57124ece8eb16e4b7fa7ea7
4
+ data.tar.gz: 5d60c8509c6acd4fb3db048aa94e64d456a1a4ed
5
5
  SHA512:
6
- metadata.gz: 4ba5f2c3c62fd9673c573ac79f8e8075b2b2c6283ab9b7415f111437ada26fbecab7553f173743c33e74243173f5318e9da2851c88685550b9098e841067f9d1
7
- data.tar.gz: 75a41dac70696dbf06670ff0d6b3b4eda74cf6884cbbfa6f98fd42158dcc6acbf03928524de4ceda725eca941c37a5142623fd22f10e4ee2d0adc1a71ea4a066
6
+ metadata.gz: d8d526decc30b6d2f5f2a5594bc6c7b2d29dbad001dc016f65382c4c710660d7316bbbdb04cf87e47d03670f8efa00fba8df6bfb02436dbbab560fe9995dc98b
7
+ data.tar.gz: 608acd7ce182b03d0878ed5b0986a3b4d0583431e105f521a9c7731e2bdf8c81fe8aa8b16857dc56ecbd108f1b63455fc073a357ead82d0af8cf76d25d62278c
data/.travis.yml CHANGED
@@ -3,3 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
5
  before_install: gem install bundler -v 1.13.6
6
+ install:
7
+ - bundle install
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ | master | develop |
2
+ | ------ | ------- |
3
+ | [![Build Status](https://travis-ci.org/dimasjt/nine-gag.svg?branch=master)](https://travis-ci.org/dimasjt/nine-gag) | [![Build Status](https://travis-ci.org/dimasjt/nine-gag.svg?branch=develop)](https://travis-ci.org/dimasjt/nine-gag) |
4
+
1
5
  ## Installation
2
6
 
3
7
  Add this line to your application's Gemfile:
@@ -16,28 +20,28 @@ Or install it yourself as:
16
20
 
17
21
  ## Usage
18
22
 
19
- * Get data from /section/type
23
+ ### Get data from /section/type
20
24
  ```ruby
21
25
  # http://9gag.com/gif/hot
22
- NineGag::Scraper.index('gif/hot')
26
+ NineGag.index('gif/hot')
23
27
  ```
24
28
 
25
- * Load more data
29
+ ### Load more data
26
30
  ```ruby
27
- NineGag::Scraper.index('gif/hot', :last_id_post)
31
+ NineGag.index('gif/hot', :last_id_post)
28
32
 
29
33
  # example
30
34
  # page 1
31
- posts = NineGag::Scraper.index('gif/hot')
35
+ posts = NineGag.index('gif/hot')
32
36
 
33
37
  # page 2
34
38
  last_id = posts.last.id
35
- posts = NineGag::Scraper.index('gif/hot', last_id)
39
+ posts = NineGag.index('gif/hot', last_id)
36
40
  ```
37
41
 
38
- * Detail post
42
+ ### Detail post
39
43
  ```ruby
40
- post = NineGag::Scraper.show(:post_id)
44
+ post = NineGag.show(:post_id)
41
45
  ```
42
46
 
43
47
  ## Contributing
data/lib/nine-gag.rb CHANGED
@@ -5,7 +5,19 @@ require 'json'
5
5
 
6
6
  require 'nine-gag/version'
7
7
  require 'nine-gag/scraper'
8
- require 'nine-gag/generator'
9
8
 
10
9
  module NineGag
10
+ def self.index(path, next_page = nil)
11
+ NineGag::Scraper.index(full_url(path), next_page)
12
+ end
13
+
14
+ def self.show(path)
15
+ NineGag::Scraper.show(full_url("gag/#{path}"))
16
+ end
17
+
18
+ private
19
+
20
+ def self.full_url(path)
21
+ "http://9gag.com/#{path}"
22
+ end
11
23
  end
@@ -5,8 +5,6 @@ module NineGag
5
5
  # path = ":section/:type"
6
6
  # next_page = "last_id"
7
7
  def self.index(path, next_page = nil)
8
- path = full_url(path)
9
-
10
8
  data = if next_page.nil?
11
9
  scrape_html(path)
12
10
  else
@@ -18,16 +16,11 @@ module NineGag
18
16
 
19
17
  # path = "gag/:id"
20
18
  def self.show(path)
21
- path = full_url("gag/#{path}")
22
19
  generate_show_data(scrape_html(path).search('article').first)
23
20
  end
24
21
 
25
22
  private
26
23
 
27
- def self.full_url(path)
28
- "http://9gag.com/#{path}"
29
- end
30
-
31
24
  # will return Array of Nokogiri
32
25
  def self.generate_json_posts(path, next_page)
33
26
  items = JSON.parse(scrape_json(path, next_page).body)["items"]
@@ -1,3 +1,3 @@
1
1
  module NineGag
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/nine-gag.gemspec CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.required_ruby_version = '>= 2.0.0'
25
+
24
26
  spec.add_dependency 'nokogiri', '~> 1.6.0', '>= 1.6.0'
25
27
  spec.add_dependency 'rest-client', '~> 2.0.0', '>= 2.0.0'
26
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nine-gag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimas J. Taniawan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -149,7 +149,6 @@ files:
149
149
  - bin/console
150
150
  - bin/setup
151
151
  - lib/nine-gag.rb
152
- - lib/nine-gag/generator.rb
153
152
  - lib/nine-gag/scraper.rb
154
153
  - lib/nine-gag/version.rb
155
154
  - nine-gag.gemspec
@@ -165,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
164
  requirements:
166
165
  - - ">="
167
166
  - !ruby/object:Gem::Version
168
- version: '0'
167
+ version: 2.0.0
169
168
  required_rubygems_version: !ruby/object:Gem::Requirement
170
169
  requirements:
171
170
  - - ">="
@@ -1,4 +0,0 @@
1
- module NineGag
2
- module Generator
3
- end
4
- end