fourchan-urler 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8509af020cc358bd749d14c9ce8a3ba108ce56d3
4
- data.tar.gz: 1e9b3a0302180f303320a832bea3d81c8aaf839b
3
+ metadata.gz: 7dafb090f85d7a3b04e81899649449a3be03e1ae
4
+ data.tar.gz: 54a9a42ad23ecce6f15bfaca0a1db68aab9a836e
5
5
  SHA512:
6
- metadata.gz: 443ae934ced6cc26d38771a25cded7d0c558c4da571cfdda0c5110c6ce497d308cae60c608f30fd2c0f15158f774ef23658f38c188f7b4b2f6e91616a13ac7ba
7
- data.tar.gz: 0089dbe54cae1c808d3796308b0a1033fbf18d72a143e949eea2190ff951c0517fbde3b1b67abc9cc0b0015153426496d8a43d22c8710e05df91850a8c49146a
6
+ metadata.gz: cb5e6fb4bdbfde0796ecc9c198e71721f24d7c139affbb92fe63c8294d387b3dc93621a8cd1301c6d688f8c632f899cfb0b1488de946457564f075a1fb926611
7
+ data.tar.gz: 29ddc992149ce312d478e4abf2322bce1c1a3cff1f4aed8df20cdaa4f5d135475e6b162a3f767069efb7c06f076704d3771929b89b1e709b1ce85e1b751ba657
@@ -0,0 +1,6 @@
1
+ class String
2
+ def path_check
3
+ parts = self.split('/')
4
+ parts.count == 4 && FourchanUrler.boards_list.include?(parts[1]) && parts[2] == 'res' && !parts[3][/\D/]
5
+ end
6
+ end
@@ -1,12 +1,14 @@
1
1
  require 'uri'
2
+ require 'extensions/strings'
2
3
 
3
4
  module FourchanUrler
5
+
4
6
  class Request
5
7
  attr_accessor :thread_id, :board
6
8
 
7
9
  def initialize(url)
8
10
  uri = URI(url)
9
- if uri.host == "boards.4chan.org"
11
+ if uri.host == "boards.4chan.org" && uri.path.path_check
10
12
  @thread_id = url[/(\d{3,})/].to_i
11
13
  @board = url[/\/[a-z]+\//][/[a-z]+/]
12
14
  else
@@ -14,4 +16,12 @@ module FourchanUrler
14
16
  end
15
17
  end
16
18
  end
19
+
20
+ def self.request(url)
21
+ self::Request.new(url)
22
+ end
23
+
24
+ def self.boards_list
25
+ ["a", "b", "c", "d", "e", "f", "g", "g", "i", "f", "h", "h", "r", "k", "m", "o", "p", "r", "s", "t", "u", "v", "v", "g", "v", "r", "w", "w", "g", "i", "i", "c", "r", "k", "s", "s", "c", "m", "h", "m", "l", "g", "b", "t", "y", "a", "d", "v", "a", "n", "a", "s", "p", "c", "g", "l", "c", "k", "c", "o", "d", "i", "y", "f", "a", "f", "i", "t", "g", "d", "h", "c", "i", "n", "t", "j", "p", "l", "i", "t", "m", "l", "p", "m", "u", "n", "o", "u", "t", "p", "o", "p", "o", "l", "s", "c", "i", "s", "o", "c", "s", "p", "t", "g", "t", "o", "y", "t", "r", "v", "t", "v", "v", "p", "w", "s", "g", "x"]
26
+ end
17
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fourchan-urler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Kim
@@ -16,6 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - lib/extensions/strings.rb
19
20
  - lib/fourchan-urler.rb
20
21
  homepage: https://github.com/serv/fourchan-urler.git
21
22
  licenses: []