bovespa 0.5.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.
- data/bovespa.gemspec +13 -0
- data/bovespa.gemspec~ +15 -0
- data/lib/bovespa.rb +63 -0
- data/lib/bovespa.rb~ +63 -0
- metadata +88 -0
data/bovespa.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.add_dependency("nokogiri", "1.4.4")
|
3
|
+
s.authors = ["Marco Antonio Fogaça Nogueira"]
|
4
|
+
s.description = %q{A Ruby wrapper for the Bovespa stock quotes API}
|
5
|
+
s.email = ["marcofognog@gmail.com"]
|
6
|
+
s.files = `git ls-files`.split("\n")
|
7
|
+
s.name = "bovespa"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.8.7")
|
11
|
+
s.summary = %q{Ruby wrapper for the Bovespa API}
|
12
|
+
s.version = '0.5.0'
|
13
|
+
end
|
data/bovespa.gemspec~
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.add_dependency("nokogiri", "1.4.4")
|
3
|
+
s.authors = ["Marco Antonio Fogaça Nogueira"]
|
4
|
+
s.description = %q{A Ruby wrapper for the Bovespa stock quotes API}
|
5
|
+
s.email = ["marcofognog@gmail.com"]
|
6
|
+
s.date = File.utime('VERSION')
|
7
|
+
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.name = "bovespa"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.8.7")
|
13
|
+
s.summary = %q{Ruby wrapper for the Bovespa API}
|
14
|
+
s.version = '0.5.0'
|
15
|
+
end
|
data/lib/bovespa.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
class Bovespa
|
2
|
+
|
3
|
+
def initialize(codigo_ativo)
|
4
|
+
Net::HTTP.start('www.bmfbovespa.com.br') do |http|
|
5
|
+
@resultado = http.get('/cotacoes2000/formCotacoesMobile.asp?codsocemi='+codigo_ativo).body
|
6
|
+
end
|
7
|
+
@info = Nokogiri::XML(@resultado)
|
8
|
+
|
9
|
+
@info.css('PAPEL').each do |node|
|
10
|
+
@descricao = node['DESCRICAO']
|
11
|
+
@codigo = node['CODIGO']
|
12
|
+
@ibovespa = node['IBOVESPA']
|
13
|
+
@data = node['DATA']
|
14
|
+
@hora = node['HORA']
|
15
|
+
@oscilacao = node['OSCILACAO']
|
16
|
+
@ultimo_valor = node['VALOR_ULTIMO']
|
17
|
+
@quantidade_negociada = node['QUANT_NEG']
|
18
|
+
@mercado = node['MERCADO']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def descricao
|
23
|
+
@descricao
|
24
|
+
end
|
25
|
+
|
26
|
+
def codigo
|
27
|
+
@codigo
|
28
|
+
end
|
29
|
+
|
30
|
+
def ibovespa
|
31
|
+
if @ibovespa == 'S'
|
32
|
+
@ibovespa="Sim"
|
33
|
+
else
|
34
|
+
@ibovespa="Não"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def data
|
39
|
+
@data
|
40
|
+
end
|
41
|
+
|
42
|
+
def hora
|
43
|
+
@hora
|
44
|
+
end
|
45
|
+
|
46
|
+
def oscilacao
|
47
|
+
@oscilacao
|
48
|
+
end
|
49
|
+
|
50
|
+
def ultimo_valor
|
51
|
+
@ultimo_valor
|
52
|
+
end
|
53
|
+
|
54
|
+
def quantidade_negociada
|
55
|
+
@quantidade_negociada
|
56
|
+
end
|
57
|
+
|
58
|
+
def mercado
|
59
|
+
@mercado
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
data/lib/bovespa.rb~
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
class Ativo
|
2
|
+
|
3
|
+
def initialize(codigo_ativo)
|
4
|
+
Net::HTTP.start('www.bmfbovespa.com.br') do |http|
|
5
|
+
@resultado = http.get('/cotacoes2000/formCotacoesMobile.asp?codsocemi='+codigo_ativo).body
|
6
|
+
end
|
7
|
+
@info = Nokogiri::XML(@resultado)
|
8
|
+
|
9
|
+
@info.css('PAPEL').each do |node|
|
10
|
+
@descricao = node['DESCRICAO']
|
11
|
+
@codigo = node['CODIGO']
|
12
|
+
@ibovespa = node['IBOVESPA']
|
13
|
+
@data = node['DATA']
|
14
|
+
@hora = node['HORA']
|
15
|
+
@oscilacao = node['OSCILACAO']
|
16
|
+
@ultimo_valor = node['VALOR_ULTIMO']
|
17
|
+
@quantidade_negociada = node['QUANT_NEG']
|
18
|
+
@mercado = node['MERCADO']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def descricao
|
23
|
+
@descricao
|
24
|
+
end
|
25
|
+
|
26
|
+
def codigo
|
27
|
+
@codigo
|
28
|
+
end
|
29
|
+
|
30
|
+
def ibovespa
|
31
|
+
if @ibovespa == 'S'
|
32
|
+
@ibovespa="Sim"
|
33
|
+
else
|
34
|
+
@ibovespa="Não"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def data
|
39
|
+
@data
|
40
|
+
end
|
41
|
+
|
42
|
+
def hora
|
43
|
+
@hora
|
44
|
+
end
|
45
|
+
|
46
|
+
def oscilacao
|
47
|
+
@oscilacao
|
48
|
+
end
|
49
|
+
|
50
|
+
def ultimo_valor
|
51
|
+
@ultimo_valor
|
52
|
+
end
|
53
|
+
|
54
|
+
def quantidade_negociada
|
55
|
+
@quantidade_negociada
|
56
|
+
end
|
57
|
+
|
58
|
+
def mercado
|
59
|
+
@mercado
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bovespa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Marco Antonio Foga\xC3\xA7a Nogueira"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-02 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: nokogiri
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
- 4
|
34
|
+
version: 1.4.4
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: A Ruby wrapper for the Bovespa stock quotes API
|
38
|
+
email:
|
39
|
+
- marcofognog@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- bovespa.gemspec
|
48
|
+
- bovespa.gemspec~
|
49
|
+
- lib/bovespa.rb
|
50
|
+
- lib/bovespa.rb~
|
51
|
+
has_rdoc: true
|
52
|
+
homepage:
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 57
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 8
|
78
|
+
- 7
|
79
|
+
version: 1.8.7
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.7
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Ruby wrapper for the Bovespa API
|
87
|
+
test_files: []
|
88
|
+
|