ruskino33_parser 0.1.1 → 0.1.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: feec7d4796072b2b299dfd2bee2be896056590bb
4
- data.tar.gz: b1b19808abffcabba47dbc1d970dc3f77f4423c0
3
+ metadata.gz: 5b145cd5878e444220c866fc905103922a5fd306
4
+ data.tar.gz: 754dd075679c46198c72194b5fbb3d84efd41f95
5
5
  SHA512:
6
- metadata.gz: 9870902d9b0752475e962d2f2ddadc2d33f8056801f064f14f429c548a2df4666784546b689ff57250159c43e198b91c1c6b7f6add869fbcec8d922158bf501e
7
- data.tar.gz: 96bb1b1b45c1d8ace8b8876cf5244d4ae923a1967902a81b2c12ac171bda72ea40c163892bf0d13be951d989e784bf2511665dbdc3a1b122d65cebe5d3953abd
6
+ metadata.gz: fab3dca153376bc000e66212fc86dc2d498ce12be67a780f57f7c6e94d20080854ee5831ac6b49cff5a3bdbd20e0e2c20ee9a34da890a37e2fbda5b578c1b478
7
+ data.tar.gz: 1fcd86c23ea0bc48772630679e2907755020cead728e2b044008b6a570dfec3adfe481d94d9083ace49a3de0cdee73f3e518fa1dfb659196b674f9e5bf374356
@@ -3,18 +3,16 @@ require 'httpclient'
3
3
  require 'ruskino33_parser/announce'
4
4
  require 'ruskino33_parser/movie'
5
5
  require "ruskino33_parser/version"
6
+ require "ruskino33_parser/premiers"
6
7
 
7
8
  module Ruskino33Parser
8
-
9
- # Headers are needed to mimic proper request to ruskino33
10
9
  def self.fetch(url)
11
- HTTPClient.new.get url, nil, { 'User-Agent'=>'a', 'Accept-Encoding'=>'a' }
10
+ HTTPClient.new.get url, nil, 'User-Agent' => 'a', 'Accept-Encoding' => 'a'
12
11
  end
13
12
 
14
- # Returns a nokogiri document or an error if fetch response status is not 200
15
13
  def self.parse(url)
16
14
  p = fetch url
17
- raise(Empty) if p.http_body.content.size.zero?
18
- p.status == 200 ? Nokogiri::HTML(p.body.encode('utf-8')) : raise(NotFound)
15
+ fail(Empty) if p.http_body.content.size.zero?
16
+ p.status == 200 ? Nokogiri::HTML(p.body.encode('utf-8')) : fail(NotFound)
19
17
  end
20
18
  end
@@ -1,10 +1,9 @@
1
1
  module Ruskino33Parser
2
2
  class Announce
3
- attr_accessor :url, :doc
3
+ attr_accessor :url, :doc, :date
4
4
 
5
- # date: '2015-03-11'
6
5
  def initialize(attributes = {})
7
- date = attributes[:date].nil? ? Date.today : Date.parse(attributes[:date].to_s)
6
+ @date = attributes[:date].nil? ? Date.today : Date.parse(attributes[:date].to_s)
8
7
  params = { action: :anonce, date: date.strftime("%d.%m.%Y") }
9
8
  @url = "http://www.ruskino33.ru/cgi-bin/webkino2/webkino.pl?#{URI.encode_www_form(params)}"
10
9
  @doc = Nokogiri::HTML(File.open('./spec/factories/anonce.html')) if attributes[:test] == true
@@ -1,6 +1,5 @@
1
1
  module Ruskino33Parser
2
2
  class Movie
3
- # get Nokogiri
4
3
  def initialize(movie)
5
4
  @movie = movie
6
5
  end
@@ -0,0 +1,19 @@
1
+ module Ruskino33Parser
2
+ class Premiers
3
+ attr_accessor :url, :doc
4
+
5
+ def initialize
6
+ @url = 'http://www.ruskino33.ru/cgi-bin/news0004.cgi'
7
+ end
8
+
9
+ def premiers
10
+ doc.search('.one_film_cut').map { |movie| Ruskino33Parser::Movie.new(movie) }
11
+ end
12
+
13
+ private
14
+
15
+ def doc
16
+ @doc ||= Ruskino33Parser.parse url
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Ruskino33Parser
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruskino33_parser
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
  - Eddie Fisher
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,6 +58,7 @@ files:
58
58
  - lib/ruskino33_parser.rb
59
59
  - lib/ruskino33_parser/announce.rb
60
60
  - lib/ruskino33_parser/movie.rb
61
+ - lib/ruskino33_parser/premiers.rb
61
62
  - lib/ruskino33_parser/version.rb
62
63
  - ruskino33_parser.gemspec
63
64
  homepage: https://github.com/eddiefisher/ruskino33_parser
@@ -85,3 +86,4 @@ signing_key:
85
86
  specification_version: 4
86
87
  summary: Parse anonce and films from ruskino33
87
88
  test_files: []
89
+ has_rdoc: