elvallenato 0.0.6

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,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Letra do
4
+ before(:each) do
5
+ @content = File.open(File.join(File.dirname(__FILE__), "fixtures", "siete_palabras.htm"),'r:ISO-8859-1').read
6
+ @letra = Letra.new(@content)
7
+ end
8
+
9
+ it "should be started with the html content" do
10
+ @letra.content.size.should eql 71004
11
+ end
12
+
13
+ it "should have a title" do
14
+ @letra.title.should eql "Siete Palabras"
15
+ end
16
+
17
+ it "should have a body" do
18
+ @letra.body.scan(/y q sabe y no sabe nada,<br>/)[0].should == "y q sabe y no sabe nada,<br>"
19
+ end
20
+
21
+ it "chould have a composer" do
22
+ @letra.composer.should eql "Kaleth Morales"
23
+ end
24
+
25
+ it "should have an artist" do
26
+ @letra.artist.should eql "Kaleth Morales"
27
+ end
28
+
29
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Search do
4
+ before(:each) do
5
+ @search_content = File.open(File.join(File.dirname(__FILE__), "fixtures", "diomedes_search.htm"),'r:ISO-8859-1').read
6
+ @letra_content = File.open(File.join(File.dirname(__FILE__), "fixtures", "siete_palabras.htm"),'r:ISO-8859-1').read
7
+ OpenURI.stub!(:open_uri).and_return(StringIO.new(@search_content))
8
+ @search = Search.new('canta', 'Diomedes')
9
+ end
10
+
11
+ it "should initialize with a mode and a term" do
12
+ Search.new("canta", "Diomedes").term.should == "Diomedes"
13
+ end
14
+
15
+ it "should generate the right url" do
16
+ @search.url.should == "http://www.elvallenato.com/letras/busqueda.php?x=Diomedes&busca=canta&image.x=12&image.y=11"
17
+ end
18
+ it "should deal with url query with spaces" do
19
+ s = Search.new("canta", "Diomedes Dias")
20
+ s.url.should eql "http://www.elvallenato.com/letras/busqueda.php?x=Diomedes+Dias&busca=canta&image.x=12&image.y=11"
21
+ end
22
+
23
+ describe "Load" do
24
+ it "should open the url and read the html to a local variable" do
25
+ @search.content.size.should == 54171
26
+ end
27
+
28
+ it "should load the content only 1 time (we are using memoization)" do
29
+ OpenURI.should_receive(:open_uri).exactly(1).times
30
+ @search.content
31
+ @search.content
32
+ @search.content
33
+ end
34
+ end
35
+
36
+ it "should have n pages of searches" do
37
+ @search.pages.should == 44
38
+ end
39
+
40
+ it "should have a valid page" do
41
+ (1..44).each do |t|
42
+ @search.next_url.should eql "http://www.elvallenato.com/busqueda.php?x=Diomedes&busca=canta&pg=#{t}"
43
+ end
44
+ #the next one should be nil
45
+ @search.next_url.should be_nil
46
+ end
47
+
48
+ it "should clean the url" do
49
+ @search.liric_links[0].should == "http://www.elvallenato.com/letras/letras/1948/La+irremplazable-Diomedes+Diaz+Maestre-Edilberto+Daza.htm"
50
+ end
51
+
52
+ it "should collect lirics" do
53
+ @search.letras.size.should eql 20
54
+ end
55
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'elvallenato'
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+
7
+ include ElVallenato
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elvallenato
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - John Maya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rb-fsevent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: RedCloth
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: This gem will interface with http://www.elvallenato.com
126
+ email:
127
+ - jcmaya@hotmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .bundle/config
133
+ - .document
134
+ - .gitignore
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - Guardfile
138
+ - LICENSE
139
+ - README.rdoc
140
+ - Rakefile
141
+ - VERSION
142
+ - autotest/discover.rb
143
+ - elvallenato.gemspec
144
+ - lib/elvallenato.rb
145
+ - lib/elvallenato/letra.rb
146
+ - lib/elvallenato/search.rb
147
+ - lib/elvallenato/version.rb
148
+ - spec/elvallenato_spec.rb
149
+ - spec/fixtures/diomedes_search.htm
150
+ - spec/fixtures/siete_palabras.htm
151
+ - spec/letra_spec.rb
152
+ - spec/search_spec.rb
153
+ - spec/spec.opts
154
+ - spec/spec_helper.rb
155
+ homepage: ''
156
+ licenses: []
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project: elvallenato
174
+ rubygems_version: 2.2.2
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: This gem will interface with http://www.elvallenato.com
178
+ test_files:
179
+ - spec/elvallenato_spec.rb
180
+ - spec/fixtures/diomedes_search.htm
181
+ - spec/fixtures/siete_palabras.htm
182
+ - spec/letra_spec.rb
183
+ - spec/search_spec.rb
184
+ - spec/spec.opts
185
+ - spec/spec_helper.rb