nine-gag 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be29168f757ce5a2a52c4bf0a35d59d44f8b41a1
4
- data.tar.gz: 4c43610a54bfad17665c652904865603fa06a745
3
+ metadata.gz: 1a03b9d37f6806e7af4939f5c5fe0c5b6bbc0c60
4
+ data.tar.gz: ed67c7abfc014eb84413d3bfe483d9ab9f1b4aff
5
5
  SHA512:
6
- metadata.gz: 7315715f60bb55c37493239922556c0e16c41bc44528eb26daf0d30b80be581f650179acea7c56b2aa79babf8dc27e9bb277f73441ff588588bccfbec80f7306
7
- data.tar.gz: 5df8b22e79ebb591e8862980670299f2f1db7c68806e09736350f7c29251afc6ef5889383a7c3c43a30b46cf47fd8e82b38ea6a3c1b03590813f90d245a32c5b
6
+ metadata.gz: 4ba5f2c3c62fd9673c573ac79f8e8075b2b2c6283ab9b7415f111437ada26fbecab7553f173743c33e74243173f5318e9da2851c88685550b9098e841067f9d1
7
+ data.tar.gz: 75a41dac70696dbf06670ff0d6b3b4eda74cf6884cbbfa6f98fd42158dcc6acbf03928524de4ceda725eca941c37a5142623fd22f10e4ee2d0adc1a71ea4a066
@@ -0,0 +1,11 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ require 'nine-gag/version'
7
+ require 'nine-gag/scraper'
8
+ require 'nine-gag/generator'
9
+
10
+ module NineGag
11
+ end
File without changes
@@ -1,12 +1,16 @@
1
+ require 'ostruct'
2
+
1
3
  module NineGag
2
4
  class Scraper
3
5
  # path = ":section/:type"
4
6
  # next_page = "last_id"
5
7
  def self.index(path, next_page = nil)
6
- if next_page.nil?
7
- data = scrape_html(path)
8
+ path = full_url(path)
9
+
10
+ data = if next_page.nil?
11
+ scrape_html(path)
8
12
  else
9
- data = generate_json_posts(path, next_page)
13
+ generate_json_posts(path, next_page)
10
14
  end
11
15
 
12
16
  generate_index_data(data, next_page)
@@ -14,7 +18,7 @@ module NineGag
14
18
 
15
19
  # path = "gag/:id"
16
20
  def self.show(path)
17
- path = "gag/#{path}"
21
+ path = full_url("gag/#{path}")
18
22
  generate_show_data(scrape_html(path).search('article').first)
19
23
  end
20
24
 
@@ -32,7 +36,7 @@ module NineGag
32
36
  end
33
37
 
34
38
  def self.scrape_json(path, next_page)
35
- RestClient.get(full_url(path),
39
+ RestClient.get(path,
36
40
  { Accept: 'application/json', "X-Requested-With": 'XMLHttpRequest',
37
41
  params: { id: next_page, c: 10 }
38
42
  }
@@ -48,7 +52,7 @@ module NineGag
48
52
  def self.path_or_html(data)
49
53
  # if path
50
54
  if data.length < 50
51
- open(full_url(data))
55
+ open data
52
56
  else
53
57
  data
54
58
  end
@@ -0,0 +1,3 @@
1
+ module NineGag
2
+ VERSION = "0.1.1"
3
+ end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'nine_gag/version'
4
+ require 'nine-gag/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'nine-gag'
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.0
4
+ version: 0.1.1
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-04 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -148,10 +148,10 @@ files:
148
148
  - Rakefile
149
149
  - bin/console
150
150
  - bin/setup
151
- - lib/nine_gag.rb
152
- - lib/nine_gag/generator.rb
153
- - lib/nine_gag/scraper.rb
154
- - lib/nine_gag/version.rb
151
+ - lib/nine-gag.rb
152
+ - lib/nine-gag/generator.rb
153
+ - lib/nine-gag/scraper.rb
154
+ - lib/nine-gag/version.rb
155
155
  - nine-gag.gemspec
156
156
  homepage: https://github.com/dimasjt/nine-gag
157
157
  licenses:
@@ -1,12 +0,0 @@
1
- require 'open-uri'
2
- require 'nokogiri'
3
- require 'rest-client'
4
- require 'json'
5
- require 'ostruct'
6
-
7
- require 'nine_gag/version'
8
- require 'nine_gag/scraper'
9
- require 'nine_gag/generator'
10
-
11
- module NineGag
12
- end
@@ -1,3 +0,0 @@
1
- module NineGag
2
- VERSION = "0.1.0"
3
- end