ttsttb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +24 -0
- data/README.md +194 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ttsttb.rb +32 -0
- data/lib/ttsttb/version.rb +3 -0
- data/main.rb +4 -0
- data/ttsttb.gemspec +36 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f916b02b86d132784599993ad65e6ca0d5b6497f3fb9718e958186a2ad2f5937
|
4
|
+
data.tar.gz: 14bcdc784fa817afcc583ffde6a4206b94e7cb42c4dfb4f54a0c2ce4de468af6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d1d2881696bd9621131bfa5492d639328be05dcc946361b9f7d8a9ed9d37cf56ce32419a82d75e8ae9559807ca3a1cdd0fb77b16fad71b02f5fc346a463589e
|
7
|
+
data.tar.gz: 7201d447f742941bd7b60b36f9192a159fd1046ab68b4fd5830e723658a1b381ddf6a24668ccd770af8dcf2169aa487d167bd63c1f61db4f4920964a412e03b9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ttsttb (0.0.1)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
mini_portile2 (2.3.0)
|
11
|
+
nokogiri (1.8.2)
|
12
|
+
mini_portile2 (~> 2.3.0)
|
13
|
+
rake (10.5.0)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.16)
|
20
|
+
rake (~> 10.0)
|
21
|
+
ttsttb!
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
# Ttsttb
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ttsttb`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ttsttb'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ttsttb
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
% irb
|
27
|
+
irb(main):011:0> pp Ttsttb.find(Date.new(2018,1,1)); nil
|
28
|
+
{"USD"=>
|
29
|
+
{"currency"=>{"en"=>"US Dollar", "ja"=>"米ドル"},
|
30
|
+
"code"=>"USD",
|
31
|
+
"tts"=>108.52,
|
32
|
+
"ttb"=>106.52},
|
33
|
+
"EUR"=>
|
34
|
+
{"currency"=>{"en"=>"Euro", "ja"=>"ユーロ"},
|
35
|
+
"code"=>"EUR",
|
36
|
+
"tts"=>133.41,
|
37
|
+
"ttb"=>130.41},
|
38
|
+
"CAD"=>
|
39
|
+
{"currency"=>{"en"=>"Canadian Dollar", "ja"=>"カナダ・ドル"},
|
40
|
+
"code"=>"CAD",
|
41
|
+
"tts"=>86.23,
|
42
|
+
"ttb"=>83.03},
|
43
|
+
"GBP"=>
|
44
|
+
{"currency"=>{"en"=>"Pound Sterling", "ja"=>"英ポンド"},
|
45
|
+
"code"=>"GBP",
|
46
|
+
"tts"=>153.49,
|
47
|
+
"ttb"=>145.49},
|
48
|
+
"CHF"=>
|
49
|
+
{"currency"=>{"en"=>"Swiss Franc", "ja"=>"スイス・フラン"},
|
50
|
+
"code"=>"CHF",
|
51
|
+
"tts"=>115.36,
|
52
|
+
"ttb"=>113.56},
|
53
|
+
"DKK"=>
|
54
|
+
{"currency"=>{"en"=>"Danish Krone", "ja"=>"デンマーク・クローネ"},
|
55
|
+
"code"=>"DKK",
|
56
|
+
"tts"=>18.01,
|
57
|
+
"ttb"=>17.41},
|
58
|
+
"NOK"=>
|
59
|
+
{"currency"=>{"en"=>"Norwegian Krone", "ja"=>"ノルウェー・クローネ"},
|
60
|
+
"code"=>"NOK",
|
61
|
+
"tts"=>13.96,
|
62
|
+
"ttb"=>13.36},
|
63
|
+
"SEK"=>
|
64
|
+
{"currency"=>{"en"=>"Swedish Krona", "ja"=>"スウェーデン・クローネ"},
|
65
|
+
"code"=>"SEK",
|
66
|
+
"tts"=>13.61,
|
67
|
+
"ttb"=>12.81},
|
68
|
+
"AUD"=>
|
69
|
+
{"currency"=>{"en"=>"Australian Dollar", "ja"=>"オーストラリア・ドル"},
|
70
|
+
"code"=>"AUD",
|
71
|
+
"tts"=>85.83,
|
72
|
+
"ttb"=>81.83},
|
73
|
+
"NZD"=>
|
74
|
+
{"currency"=>{"en"=>"New Zealand Dollar", "ja"=>"ニュージーランド・ドル"},
|
75
|
+
"code"=>"NZD",
|
76
|
+
"tts"=>80.63,
|
77
|
+
"ttb"=>76.63},
|
78
|
+
"HKD"=>
|
79
|
+
{"currency"=>{"en"=>"Hong Kong Dollar", "ja"=>"香港ドル"},
|
80
|
+
"code"=>"HKD",
|
81
|
+
"tts"=>14.17,
|
82
|
+
"ttb"=>13.31},
|
83
|
+
"MYR"=>
|
84
|
+
{"currency"=>{"en"=>"Malaysian Ringgit", "ja"=>"マレーシア・リンギット"},
|
85
|
+
"code"=>"MYR",
|
86
|
+
"tts"=>0.0,
|
87
|
+
"ttb"=>0.0},
|
88
|
+
"SGD"=>
|
89
|
+
{"currency"=>{"en"=>"Singapore Dollar", "ja"=>"シンガポール・ドル"},
|
90
|
+
"code"=>"SGD",
|
91
|
+
"tts"=>81.96,
|
92
|
+
"ttb"=>80.3},
|
93
|
+
"SAR"=>
|
94
|
+
{"currency"=>{"en"=>"Saudi Riyal", "ja"=>"サウジ・リアル"},
|
95
|
+
"code"=>"SAR",
|
96
|
+
"tts"=>29.52,
|
97
|
+
"ttb"=>27.92},
|
98
|
+
"AED"=>
|
99
|
+
{"currency"=>{"en"=>"UAE Dirham", "ja"=>"UAEディルハム"},
|
100
|
+
"code"=>"AED",
|
101
|
+
"tts"=>29.91,
|
102
|
+
"ttb"=>28.55},
|
103
|
+
"CNY"=>
|
104
|
+
{"currency"=>{"en"=>"Yuan Renminbi", "ja"=>"中国・人民元"},
|
105
|
+
"code"=>"CNY",
|
106
|
+
"tts"=>17.25,
|
107
|
+
"ttb"=>16.65},
|
108
|
+
"THB"=>
|
109
|
+
{"currency"=>{"en"=>"Baht", "ja"=>"タイ・バーツ"},
|
110
|
+
"code"=>"THB",
|
111
|
+
"tts"=>3.49,
|
112
|
+
"ttb"=>3.33},
|
113
|
+
"INR"=>
|
114
|
+
{"currency"=>{"en"=>"Indian Rupee", "ja"=>"インド・ルピー"},
|
115
|
+
"code"=>"INR",
|
116
|
+
"tts"=>1.82,
|
117
|
+
"ttb"=>1.52},
|
118
|
+
"PKR"=>
|
119
|
+
{"currency"=>{"en"=>"Pakistan Rupee", "ja"=>"パキスタン・ルピー"},
|
120
|
+
"code"=>"PKR",
|
121
|
+
"tts"=>1.13,
|
122
|
+
"ttb"=>0.83},
|
123
|
+
"KWD"=>
|
124
|
+
{"currency"=>{"en"=>"Kuwaiti Dinar", "ja"=>"クウェート・ディナール"},
|
125
|
+
"code"=>"KWD",
|
126
|
+
"tts"=>367.6,
|
127
|
+
"ttb"=>351.6},
|
128
|
+
"QAR"=>
|
129
|
+
{"currency"=>{"en"=>"Qatari Rial", "ja"=>"カタール・リヤル"},
|
130
|
+
"code"=>"QAR",
|
131
|
+
"tts"=>30.27,
|
132
|
+
"ttb"=>28.91},
|
133
|
+
"IDR"=>
|
134
|
+
{"currency"=>{"en"=>"Indonesia Rupiah", "ja"=>"インドネシア・ルピア"},
|
135
|
+
"code"=>"IDR",
|
136
|
+
"tts"=>0.91,
|
137
|
+
"ttb"=>0.67},
|
138
|
+
"MXN"=>
|
139
|
+
{"currency"=>{"en"=>"Mexican Peso", "ja"=>"メキシコ・ペソ"},
|
140
|
+
"code"=>"MXN",
|
141
|
+
"tts"=>6.71,
|
142
|
+
"ttb"=>4.71},
|
143
|
+
"KRW"=>
|
144
|
+
{"currency"=>{"en"=>"Won", "ja"=>"韓国ウォン"},
|
145
|
+
"code"=>"KRW",
|
146
|
+
"tts"=>10.16,
|
147
|
+
"ttb"=>9.76},
|
148
|
+
"PHP"=>
|
149
|
+
{"currency"=>{"en"=>"Philippine Peso", "ja"=>"フィリピン・ペソ"},
|
150
|
+
"code"=>"PHP",
|
151
|
+
"tts"=>2.22,
|
152
|
+
"ttb"=>1.94},
|
153
|
+
"ZAR"=>
|
154
|
+
{"currency"=>{"en"=>"Rand", "ja"=>"南アフリカ・ランド"},
|
155
|
+
"code"=>"ZAR",
|
156
|
+
"tts"=>10.71,
|
157
|
+
"ttb"=>7.71},
|
158
|
+
"CZK"=>
|
159
|
+
{"currency"=>{"en"=>"Czech Koruna", "ja"=>"チェコ・コルナ"},
|
160
|
+
"code"=>"CZK",
|
161
|
+
"tts"=>5.33,
|
162
|
+
"ttb"=>5.09},
|
163
|
+
"RUB"=>
|
164
|
+
{"currency"=>{"en"=>"Russian Ruble", "ja"=>"ロシア・ルーブル"},
|
165
|
+
"code"=>"RUB",
|
166
|
+
"tts"=>2.14,
|
167
|
+
"ttb"=>1.64},
|
168
|
+
"HUF"=>
|
169
|
+
{"currency"=>{"en"=>"Hungarian Forint", "ja"=>"ハンガリー・フォリント"},
|
170
|
+
"code"=>"HUF",
|
171
|
+
"tts"=>0.44,
|
172
|
+
"ttb"=>0.4},
|
173
|
+
"PLN"=>
|
174
|
+
{"currency"=>{"en"=>"Polish Zloty", "ja"=>"ポーランド・ズロチ"},
|
175
|
+
"code"=>"PLN",
|
176
|
+
"tts"=>32.77,
|
177
|
+
"ttb"=>30.37},
|
178
|
+
"TRY"=>
|
179
|
+
{"currency"=>{"en"=>"Turkish Lira", "ja"=>"トルコ・リラ"},
|
180
|
+
"code"=>"TRY",
|
181
|
+
"tts"=>30.83,
|
182
|
+
"ttb"=>25.83}}
|
183
|
+
=> nil
|
184
|
+
```
|
185
|
+
|
186
|
+
## Development
|
187
|
+
|
188
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
189
|
+
|
190
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
191
|
+
|
192
|
+
## Contributing
|
193
|
+
|
194
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/matsubo/ttsttb.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ttsttb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/ttsttb.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ttsttb/version'
|
2
|
+
|
3
|
+
module Ttsttb
|
4
|
+
def self.find(date)
|
5
|
+
require 'date'
|
6
|
+
url = 'http://www.murc-kawasesouba.jp/fx/past/index.php?id=%s' % [date.strftime('%y%m%d')]
|
7
|
+
|
8
|
+
rows = {}
|
9
|
+
|
10
|
+
require 'open-uri'
|
11
|
+
require 'nokogiri'
|
12
|
+
|
13
|
+
doc = Nokogiri::HTML(open(url))
|
14
|
+
doc.xpath('//table[1]/tr').each do |tr|
|
15
|
+
tds = tr.xpath('.//td')
|
16
|
+
|
17
|
+
next unless tds[0]
|
18
|
+
|
19
|
+
rows[tds[2].content] = {
|
20
|
+
'currency' => {
|
21
|
+
'en' => tds[0].content,
|
22
|
+
'ja' => tds[1].content
|
23
|
+
},
|
24
|
+
'code' => tds[2].content,
|
25
|
+
'tts' => tds[3].content.strip.to_f,
|
26
|
+
'ttb' => tds[4].content.strip.to_f
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
rows
|
31
|
+
end
|
32
|
+
end
|
data/main.rb
ADDED
data/ttsttb.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ttsttb/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ttsttb"
|
8
|
+
spec.version = Ttsttb::VERSION
|
9
|
+
spec.authors = ["Yuki Matsukura"]
|
10
|
+
spec.email = ["matsubokkuri@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Fetch TTS and TTB corresponding to the date.}
|
13
|
+
spec.description = %q{Scraping TTS and TTB data from http://www.murc-kawasesouba.jp/fx/index.php}
|
14
|
+
spec.homepage = "https://github.com/matsubo/ttsttb"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
21
|
+
"public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency 'nokogiri'
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ttsttb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuki Matsukura
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Scraping TTS and TTB data from http://www.murc-kawasesouba.jp/fx/index.php
|
56
|
+
email:
|
57
|
+
- matsubokkuri@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- lib/ttsttb.rb
|
70
|
+
- lib/ttsttb/version.rb
|
71
|
+
- main.rb
|
72
|
+
- ttsttb.gemspec
|
73
|
+
homepage: https://github.com/matsubo/ttsttb
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.7.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Fetch TTS and TTB corresponding to the date.
|
96
|
+
test_files: []
|