newly 0.1.0

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.
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ # require 'spec_helper'
3
+
4
+ describe Newly do
5
+ let(:ec_bahia) { ec_bahia = Newly.new('http://www.ecbahia.com', 'spec/html/ecbahia.html') }
6
+ let(:g1) { g1_bahia = Newly.new('http://g1.globo.com', 'spec/html/g1.html') }
7
+ let(:g1_bahia) { g1_bahia = Newly.new('http://g1.globo.com/bahia/', 'spec/html/g1_bahia.html') }
8
+ let(:metro1) { g1_bahia = Newly.new('http://www.metro1.com.br/portal/?varSession=noticia&varEditoria=cidade', 'spec/html/metro1_cidade.html') }
9
+
10
+ it "should fetch ecbahia title" do
11
+ ec_bahia.title.should == "ecbahia.com - \u00e9 goleada tricolor na internet! (ecbahia, ecbahia.com, ecbahia.com.br, Esporte Clube Bahia)"
12
+ end
13
+
14
+ it "should fetch highlights from http://g1.globo.com/bahia" do
15
+ highlights = g1_bahia.highlights( css: '#ultimas-regiao div, #ultimas-regiao ul li',
16
+ url: 'a',
17
+ date: '.data-hora',
18
+ title: '.titulo',
19
+ subtitle: '.subtitulo',
20
+ image: 'img'
21
+ )
22
+ highlights.should_not be_empty
23
+ end
24
+
25
+ context "fetching news from http://g1.globo.com" do
26
+ it "should fetch highlights news" do
27
+ highlights = g1.highlights( css: '#glb-corpo .glb-area .chamada-principal',
28
+ url: 'a',
29
+ title: '.chapeu',
30
+ subtitle: '.subtitulo',
31
+ image: '.foto a img'
32
+ )
33
+ highlights.should_not be_empty
34
+ highlights[0].url.should == 'http://g1.globo.com/mundo/noticia/2012/08/ira-encerra-resgate-apos-terremotos-e-revisa-mortos-para-227-diz-tv-estatal.html'
35
+ highlights[0].subtitle.should == 'Tremores deixaram 1.380 pessoas feridas.'
36
+
37
+ highlights[1].url.should == 'http://g1.globo.com/politica/mensalao/noticia/2012/08/historias-de-togas-e-becas-alimentam-folclore-de-tribunais-veja-algumas.html'
38
+ highlights[1].title.should == 'julgamento no stf'
39
+
40
+ highlights[2].url.should == 'http://g1.globo.com/concursos-e-emprego/noticia/2012/08/fazenda-e-9-orgaos-abrem-inscricoes-para-12-mil-vagas-na-segunda.html'
41
+ highlights[2].title.should == 'a partir de amanha'
42
+ end
43
+
44
+ xit "should fetch keywords" do
45
+ highlights = g1.highlights( css: '#glb-corpo .glb-area .chamada-principal',
46
+ url: 'a',
47
+ title: '.chapeu',
48
+ subtitle: '.subtitulo',
49
+ image: '.foto a img'
50
+ )
51
+ highlights[0].url.should == 'http://g1.globo.com/mundo/noticia/2012/08/ira-encerra-resgate-apos-terremotos-e-revisa-mortos-para-227-diz-tv-estatal.html'
52
+ highlights[0].keywords.should == 'noticias, noticia, Mundo'
53
+ end
54
+ end
55
+
56
+ it "should fetch highlights from http://www.metro1.com.br" do
57
+ highlights = metro1.highlights( css: '#lista-de-resultados .resultado',
58
+ url: 'a',
59
+ date: '.resultado-data',
60
+ title: '.resultado-titulo',
61
+ subtitle: '.resultado-texto',
62
+ image: 'a img.img-resultado',
63
+ host: 'http://www.metro1.com.br'
64
+ )
65
+ highlights.should_not be_empty
66
+ end
67
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'newly'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ config.color_enabled = true
12
+ config.formatter = :documentation
13
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alabê Duarte
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: &70323538101160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70323538101160
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70323538100600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70323538100600
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &70323538099940 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.12'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70323538099940
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &70323538099180 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.5
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70323538099180
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &70323538098540 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.8.4
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70323538098540
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70323538097640 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70323538097640
80
+ description: Fetching breaking news from websites
81
+ email: alabeduarte@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files:
85
+ - LICENSE.txt
86
+ - README.rdoc
87
+ files:
88
+ - .DS_Store
89
+ - .document
90
+ - .rspec
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - lib/newly.rb
98
+ - lib/news.rb
99
+ - newly.gemspec
100
+ - spec/.DS_Store
101
+ - spec/html/ecbahia.html
102
+ - spec/html/g1.html
103
+ - spec/html/g1_bahia.html
104
+ - spec/html/metro1_cidade.html
105
+ - spec/newly_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: http://github.com/alabeduarte/newly
108
+ licenses:
109
+ - MIT
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: 2541934635408710939
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.10
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Fetching breaking news from websites
135
+ test_files: []