ttsttb 0.0.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +21 -0
- data/.github/workflows/ruby.yml +48 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -2
- data/.rubocop_todo.yml +128 -0
- data/Gemfile.lock +52 -8
- data/README.md +125 -78
- data/lib/ttsttb/version.rb +1 -1
- data/lib/ttsttb.rb +28 -12
- data/ttsttb.gemspec +7 -3
- metadata +57 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '029b2dc42781b195ebb92867a8f46fd56f892a8e05906853d973e56ce10d47eb'
|
4
|
+
data.tar.gz: a000346c9cb97504ff70428996b73609448be1b9b9023e1ab4499733af97434b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d79adc16de5f73e3ec5c39dd2b57e60682cbd5f48633d469c6706f9d98d7f0370c98f7d8c5fb0c9717512e58f42ddad27ea736dcaecccdcab3da8d7b57aff226
|
7
|
+
data.tar.gz: 457476c47e3d708202b6233cd33baa16bc3982dc7a8aa66ba7bbe6dfe2bc8d4dc9ae3e87f8002507ccc07e2b175f81b333657d2115cd68a6be6158913f7c992e
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- "*"
|
7
|
+
tags:
|
8
|
+
- v*
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v1
|
15
|
+
|
16
|
+
- name: Release Gem
|
17
|
+
if: contains(github.ref, 'refs/tags/v')
|
18
|
+
uses: personal-social-media/publish-rubygems-action@master
|
19
|
+
env:
|
20
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
21
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run code format test
|
35
|
+
run: bundle exec rubocop
|
36
|
+
- name: Run tests
|
37
|
+
run: bundle exec rspec
|
38
|
+
- name: Archive code coverage results
|
39
|
+
uses: actions/upload-artifact@v2
|
40
|
+
with:
|
41
|
+
name: code-coverage-report
|
42
|
+
path: coverage/
|
43
|
+
- uses: paambaati/codeclimate-action@v3.0.0
|
44
|
+
env:
|
45
|
+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
46
|
+
with:
|
47
|
+
coverageCommand: bundle exec rspec
|
48
|
+
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
5
|
+
|
1
6
|
# This configuration was generated by
|
2
7
|
# `rubocop --auto-gen-config`
|
3
8
|
# on 2018-02-23 11:31:57 +0900 using RuboCop version 0.48.1.
|
@@ -13,10 +18,15 @@ Metrics/AbcSize:
|
|
13
18
|
# Offense count: 1
|
14
19
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
15
20
|
# URISchemes: http, https
|
16
|
-
|
21
|
+
Layout/LineLength:
|
17
22
|
Max: 99
|
18
23
|
|
19
24
|
# Offense count: 1
|
20
25
|
# Configuration parameters: CountComments.
|
21
26
|
Metrics/MethodLength:
|
22
|
-
Max:
|
27
|
+
Max: 20
|
28
|
+
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Exclude:
|
31
|
+
- 'spec/lib/**/*'
|
32
|
+
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2021-10-11 07:44:37 UTC using RuboCop version 1.22.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyle.
|
12
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
13
|
+
Layout/EmptyLinesAroundBlockBody:
|
14
|
+
Exclude:
|
15
|
+
- 'ttsttb.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
20
|
+
Layout/ExtraSpacing:
|
21
|
+
Exclude:
|
22
|
+
- 'ttsttb.gemspec'
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# Cop supports --auto-correct.
|
26
|
+
Layout/LeadingEmptyLines:
|
27
|
+
Exclude:
|
28
|
+
- 'ttsttb.gemspec'
|
29
|
+
|
30
|
+
# Offense count: 1
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
33
|
+
# SupportedStylesForExponentOperator: space, no_space
|
34
|
+
Layout/SpaceAroundOperators:
|
35
|
+
Exclude:
|
36
|
+
- 'ttsttb.gemspec'
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
# Cop supports --auto-correct.
|
40
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
41
|
+
# SupportedStyles: space, no_space
|
42
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
43
|
+
Layout/SpaceInsideBlockBraces:
|
44
|
+
Exclude:
|
45
|
+
- 'Gemfile'
|
46
|
+
|
47
|
+
# Offense count: 1
|
48
|
+
# Cop supports --auto-correct.
|
49
|
+
# Configuration parameters: EnforcedStyle.
|
50
|
+
# SupportedStyles: final_newline, final_blank_line
|
51
|
+
Layout/TrailingEmptyLines:
|
52
|
+
Exclude:
|
53
|
+
- 'main.rb'
|
54
|
+
|
55
|
+
# Offense count: 1
|
56
|
+
# Configuration parameters: AllowComments.
|
57
|
+
Lint/EmptyConditionalBody:
|
58
|
+
Exclude:
|
59
|
+
- 'ttsttb.gemspec'
|
60
|
+
|
61
|
+
# Offense count: 1
|
62
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
63
|
+
# IgnoredMethods: refine
|
64
|
+
Metrics/BlockLength:
|
65
|
+
Max: 60
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
69
|
+
Metrics/MethodLength:
|
70
|
+
Max: 18
|
71
|
+
|
72
|
+
# Offense count: 2
|
73
|
+
Security/Open:
|
74
|
+
Exclude:
|
75
|
+
- 'lib/ttsttb.rb'
|
76
|
+
|
77
|
+
# Offense count: 1
|
78
|
+
# Cop supports --auto-correct.
|
79
|
+
Style/ExpandPathArguments:
|
80
|
+
Exclude:
|
81
|
+
- 'ttsttb.gemspec'
|
82
|
+
|
83
|
+
# Offense count: 9
|
84
|
+
# Cop supports --auto-correct.
|
85
|
+
# Configuration parameters: EnforcedStyle.
|
86
|
+
# SupportedStyles: always, always_true, never
|
87
|
+
Style/FrozenStringLiteralComment:
|
88
|
+
Exclude:
|
89
|
+
- 'Gemfile'
|
90
|
+
- 'Rakefile'
|
91
|
+
- 'bin/console'
|
92
|
+
- 'lib/ttsttb.rb'
|
93
|
+
- 'lib/ttsttb/version.rb'
|
94
|
+
- 'main.rb'
|
95
|
+
- 'spec/lib/ttsttb_spec.rb'
|
96
|
+
- 'spec/spec_helper.rb'
|
97
|
+
- 'ttsttb.gemspec'
|
98
|
+
|
99
|
+
# Offense count: 7
|
100
|
+
# Cop supports --auto-correct.
|
101
|
+
# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
102
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
103
|
+
Style/HashSyntax:
|
104
|
+
EnforcedStyle: hash_rockets
|
105
|
+
|
106
|
+
# Offense count: 2
|
107
|
+
# Cop supports --auto-correct.
|
108
|
+
# Configuration parameters: PreferredDelimiters.
|
109
|
+
Style/PercentLiteralDelimiters:
|
110
|
+
Exclude:
|
111
|
+
- 'ttsttb.gemspec'
|
112
|
+
|
113
|
+
# Offense count: 2
|
114
|
+
# Cop supports --auto-correct.
|
115
|
+
Style/RedundantPercentQ:
|
116
|
+
Exclude:
|
117
|
+
- 'ttsttb.gemspec'
|
118
|
+
|
119
|
+
# Offense count: 21
|
120
|
+
# Cop supports --auto-correct.
|
121
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
122
|
+
# SupportedStyles: single_quotes, double_quotes
|
123
|
+
Style/StringLiterals:
|
124
|
+
Exclude:
|
125
|
+
- 'Gemfile'
|
126
|
+
- 'Rakefile'
|
127
|
+
- 'bin/console'
|
128
|
+
- 'ttsttb.gemspec'
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,68 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ttsttb (0.
|
4
|
+
ttsttb (0.2.4)
|
5
5
|
nokogiri
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
docile (1.4.0)
|
13
|
+
nokogiri (1.12.5-x86_64-darwin)
|
14
|
+
racc (~> 1.4)
|
15
|
+
parallel (1.21.0)
|
16
|
+
parser (3.0.2.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
racc (1.5.2)
|
19
|
+
rainbow (3.0.0)
|
20
|
+
rake (13.0.6)
|
21
|
+
regexp_parser (2.1.1)
|
22
|
+
rexml (3.2.5)
|
23
|
+
rspec (3.10.0)
|
24
|
+
rspec-core (~> 3.10.0)
|
25
|
+
rspec-expectations (~> 3.10.0)
|
26
|
+
rspec-mocks (~> 3.10.0)
|
27
|
+
rspec-core (3.10.1)
|
28
|
+
rspec-support (~> 3.10.0)
|
29
|
+
rspec-expectations (3.10.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-mocks (3.10.2)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.2)
|
36
|
+
rubocop (1.22.1)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 3.0.0.0)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8, < 3.0)
|
41
|
+
rexml
|
42
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
45
|
+
rubocop-ast (1.12.0)
|
46
|
+
parser (>= 3.0.1.1)
|
47
|
+
ruby-progressbar (1.11.0)
|
48
|
+
simplecov (0.21.2)
|
49
|
+
docile (~> 1.1)
|
50
|
+
simplecov-html (~> 0.11)
|
51
|
+
simplecov_json_formatter (~> 0.1)
|
52
|
+
simplecov-html (0.12.3)
|
53
|
+
simplecov_json_formatter (0.1.3)
|
54
|
+
unicode-display_width (2.1.0)
|
14
55
|
|
15
56
|
PLATFORMS
|
16
57
|
ruby
|
17
58
|
|
18
59
|
DEPENDENCIES
|
19
|
-
bundler (~>
|
20
|
-
rake (~>
|
60
|
+
bundler (~> 2)
|
61
|
+
rake (~> 13.0)
|
62
|
+
rspec
|
63
|
+
rubocop
|
64
|
+
simplecov
|
21
65
|
ttsttb!
|
22
66
|
|
23
67
|
BUNDLED WITH
|
24
|
-
|
68
|
+
2.2.16
|
data/README.md
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
-
# TTS TTB library
|
1
|
+
# TTS, TTB, TTM library
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ttsttb.svg)](https://badge.fury.io/rb/ttsttb)
|
4
|
+
![Gem](https://img.shields.io/gem/dt/ttsttb)
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/2f4736d38eaa5d261aae/maintainability)](https://codeclimate.com/github/matsubo/ttsttb/maintainability)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/2f4736d38eaa5d261aae/test_coverage)](https://codeclimate.com/github/matsubo/ttsttb/test_coverage)
|
7
|
+
|
2
8
|
|
3
9
|
[TTS and TTB value of Forex](http://www.murc-kawasesouba.jp/fx/past_3month.php) is provided by MUFG. Major information provider of TTS and TTB is MUFG in Japan but the data is not provided by commonly used data format like CSV and JSON to handle by program for ease.
|
4
10
|
|
5
11
|
I created Ruby gem to get the TTS and TTB corresponding to the passed date. You can get hash of currency code key and value of TTS and TTB.
|
6
12
|
|
7
|
-
__Caution__ : This library has no test and exception handling is not tested to cover all the source data.
|
8
13
|
|
9
14
|
|
10
15
|
## Installation
|
11
16
|
|
12
|
-
Add
|
13
|
-
|
14
|
-
```ruby
|
15
|
-
gem 'ttsttb'
|
16
|
-
```
|
17
|
+
Add by bundler
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
$ bundle
|
19
|
+
$ bundle add ttsttb
|
21
20
|
|
22
21
|
Or install it yourself as:
|
23
22
|
|
@@ -25,8 +24,6 @@ Or install it yourself as:
|
|
25
24
|
|
26
25
|
## Usage
|
27
26
|
|
28
|
-
- Common error
|
29
|
-
- `find` method throws `OpenURI::HTTPRedirect` exception if data source is not found.
|
30
27
|
|
31
28
|
```ruby
|
32
29
|
% bin/console
|
@@ -34,165 +31,195 @@ irb(main):001:0> require 'pp'
|
|
34
31
|
true
|
35
32
|
irb(main):001:0> require 'date'
|
36
33
|
true
|
37
|
-
irb(main):003:0> pp Ttsttb.find(Date.new(2018,
|
38
|
-
|
39
|
-
irb(main):004:0> pp Ttsttb.find(Date.new(2018,
|
34
|
+
irb(main):003:0> pp Ttsttb.find(Date.new(2018, 3, 7))['USD']['tts']
|
35
|
+
106.62
|
36
|
+
irb(main):004:0> pp Ttsttb.find(Date.new(2018, 3, 1))
|
40
37
|
{"USD"=>
|
41
38
|
{"currency"=>{"en"=>"US Dollar", "ja"=>"米ドル"},
|
42
39
|
"code"=>"USD",
|
43
|
-
"tts"=>
|
44
|
-
"ttb"=>
|
40
|
+
"tts"=>107.73,
|
41
|
+
"ttb"=>105.73,
|
42
|
+
"ttm"=>160.6},
|
45
43
|
"EUR"=>
|
46
44
|
{"currency"=>{"en"=>"Euro", "ja"=>"ユーロ"},
|
47
45
|
"code"=>"EUR",
|
48
|
-
"tts"=>
|
49
|
-
"ttb"=>
|
46
|
+
"tts"=>131.54,
|
47
|
+
"ttb"=>128.54,
|
48
|
+
"ttm"=>195.81},
|
50
49
|
"CAD"=>
|
51
50
|
{"currency"=>{"en"=>"Canadian Dollar", "ja"=>"カナダ・ドル"},
|
52
51
|
"code"=>"CAD",
|
53
|
-
"tts"=>
|
54
|
-
"ttb"=>
|
52
|
+
"tts"=>84.71,
|
53
|
+
"ttb"=>81.51,
|
54
|
+
"ttm"=>125.47},
|
55
55
|
"GBP"=>
|
56
56
|
{"currency"=>{"en"=>"Pound Sterling", "ja"=>"英ポンド"},
|
57
57
|
"code"=>"GBP",
|
58
|
-
"tts"=>
|
59
|
-
"ttb"=>
|
58
|
+
"tts"=>150.75,
|
59
|
+
"ttb"=>142.75,
|
60
|
+
"ttm"=>222.13},
|
60
61
|
"CHF"=>
|
61
62
|
{"currency"=>{"en"=>"Swiss Franc", "ja"=>"スイス・フラン"},
|
62
63
|
"code"=>"CHF",
|
63
|
-
"tts"=>
|
64
|
-
"ttb"=>
|
64
|
+
"tts"=>113.78,
|
65
|
+
"ttb"=>111.98,
|
66
|
+
"ttm"=>169.77},
|
65
67
|
"DKK"=>
|
66
68
|
{"currency"=>{"en"=>"Danish Krone", "ja"=>"デンマーク・クローネ"},
|
67
69
|
"code"=>"DKK",
|
68
|
-
"tts"=>
|
69
|
-
"ttb"=>17.
|
70
|
+
"tts"=>17.76,
|
71
|
+
"ttb"=>17.16,
|
72
|
+
"ttm"=>26.34},
|
70
73
|
"NOK"=>
|
71
74
|
{"currency"=>{"en"=>"Norwegian Krone", "ja"=>"ノルウェー・クローネ"},
|
72
75
|
"code"=>"NOK",
|
73
|
-
"tts"=>13.
|
74
|
-
"ttb"=>13.
|
76
|
+
"tts"=>13.79,
|
77
|
+
"ttb"=>13.19,
|
78
|
+
"ttm"=>20.39},
|
75
79
|
"SEK"=>
|
76
80
|
{"currency"=>{"en"=>"Swedish Krona", "ja"=>"スウェーデン・クローネ"},
|
77
81
|
"code"=>"SEK",
|
78
|
-
"tts"=>13.
|
79
|
-
"ttb"=>12.
|
82
|
+
"tts"=>13.27,
|
83
|
+
"ttb"=>12.47,
|
84
|
+
"ttm"=>19.51},
|
80
85
|
"AUD"=>
|
81
86
|
{"currency"=>{"en"=>"Australian Dollar", "ja"=>"オーストラリア・ドル"},
|
82
87
|
"code"=>"AUD",
|
83
|
-
"tts"=>
|
84
|
-
"ttb"=>
|
88
|
+
"tts"=>84.6,
|
89
|
+
"ttb"=>80.6,
|
90
|
+
"ttm"=>124.9},
|
85
91
|
"NZD"=>
|
86
92
|
{"currency"=>{"en"=>"New Zealand Dollar", "ja"=>"ニュージーランド・ドル"},
|
87
93
|
"code"=>"NZD",
|
88
|
-
"tts"=>
|
89
|
-
"ttb"=>
|
94
|
+
"tts"=>78.87,
|
95
|
+
"ttb"=>74.87,
|
96
|
+
"ttm"=>116.31},
|
90
97
|
"HKD"=>
|
91
98
|
{"currency"=>{"en"=>"Hong Kong Dollar", "ja"=>"香港ドル"},
|
92
99
|
"code"=>"HKD",
|
93
|
-
"tts"=>14.
|
94
|
-
"ttb"=>13.
|
100
|
+
"tts"=>14.07,
|
101
|
+
"ttb"=>13.21,
|
102
|
+
"ttm"=>20.68},
|
95
103
|
"MYR"=>
|
96
104
|
{"currency"=>{"en"=>"Malaysian Ringgit", "ja"=>"マレーシア・リンギット"},
|
97
105
|
"code"=>"MYR",
|
98
|
-
"tts"=>
|
99
|
-
"ttb"=>
|
106
|
+
"tts"=>nil,
|
107
|
+
"ttb"=>nil,
|
108
|
+
"ttm"=>nil},
|
100
109
|
"SGD"=>
|
101
110
|
{"currency"=>{"en"=>"Singapore Dollar", "ja"=>"シンガポール・ドル"},
|
102
111
|
"code"=>"SGD",
|
103
|
-
"tts"=>81.
|
104
|
-
"ttb"=>
|
112
|
+
"tts"=>81.3,
|
113
|
+
"ttb"=>79.64,
|
114
|
+
"ttm"=>121.12},
|
105
115
|
"SAR"=>
|
106
116
|
{"currency"=>{"en"=>"Saudi Riyal", "ja"=>"サウジ・リアル"},
|
107
117
|
"code"=>"SAR",
|
108
|
-
"tts"=>29.
|
109
|
-
"ttb"=>27.
|
118
|
+
"tts"=>29.31,
|
119
|
+
"ttb"=>27.71,
|
120
|
+
"ttm"=>43.17},
|
110
121
|
"AED"=>
|
111
122
|
{"currency"=>{"en"=>"UAE Dirham", "ja"=>"UAEディルハム"},
|
112
123
|
"code"=>"AED",
|
113
|
-
"tts"=>29.
|
114
|
-
"ttb"=>28.
|
124
|
+
"tts"=>29.79,
|
125
|
+
"ttb"=>28.43,
|
126
|
+
"ttm"=>44.01},
|
115
127
|
"CNY"=>
|
116
128
|
{"currency"=>{"en"=>"Yuan Renminbi", "ja"=>"中国・人民元"},
|
117
129
|
"code"=>"CNY",
|
118
|
-
"tts"=>17.
|
119
|
-
"ttb"=>16.
|
130
|
+
"tts"=>17.15,
|
131
|
+
"ttb"=>16.55,
|
132
|
+
"ttm"=>25.43},
|
120
133
|
"THB"=>
|
121
134
|
{"currency"=>{"en"=>"Baht", "ja"=>"タイ・バーツ"},
|
122
135
|
"code"=>"THB",
|
123
|
-
"tts"=>3.
|
124
|
-
"ttb"=>3.
|
136
|
+
"tts"=>3.46,
|
137
|
+
"ttb"=>3.3,
|
138
|
+
"ttm"=>5.11},
|
125
139
|
"INR"=>
|
126
140
|
{"currency"=>{"en"=>"Indian Rupee", "ja"=>"インド・ルピー"},
|
127
141
|
"code"=>"INR",
|
128
|
-
"tts"=>1.
|
129
|
-
"ttb"=>1.
|
142
|
+
"tts"=>1.8,
|
143
|
+
"ttb"=>1.5,
|
144
|
+
"ttm"=>2.55},
|
130
145
|
"PKR"=>
|
131
146
|
{"currency"=>{"en"=>"Pakistan Rupee", "ja"=>"パキスタン・ルピー"},
|
132
147
|
"code"=>"PKR",
|
133
|
-
"tts"=>1.
|
134
|
-
"ttb"=>0.
|
148
|
+
"tts"=>1.12,
|
149
|
+
"ttb"=>0.82,
|
150
|
+
"ttm"=>1.53},
|
135
151
|
"KWD"=>
|
136
152
|
{"currency"=>{"en"=>"Kuwaiti Dinar", "ja"=>"クウェート・ディナール"},
|
137
153
|
"code"=>"KWD",
|
138
|
-
"tts"=>
|
139
|
-
"ttb"=>
|
154
|
+
"tts"=>364.96,
|
155
|
+
"ttb"=>348.96,
|
156
|
+
"ttm"=>539.44},
|
140
157
|
"QAR"=>
|
141
158
|
{"currency"=>{"en"=>"Qatari Rial", "ja"=>"カタール・リヤル"},
|
142
159
|
"code"=>"QAR",
|
143
|
-
"tts"=>30.
|
144
|
-
"ttb"=>28.
|
160
|
+
"tts"=>30.05,
|
161
|
+
"ttb"=>28.69,
|
162
|
+
"ttm"=>44.4},
|
145
163
|
"IDR"=>
|
146
164
|
{"currency"=>{"en"=>"Indonesia Rupiah", "ja"=>"インドネシア・ルピア"},
|
147
165
|
"code"=>"IDR",
|
148
|
-
"tts"=>0.
|
149
|
-
"ttb"=>0.
|
166
|
+
"tts"=>0.9,
|
167
|
+
"ttb"=>0.66,
|
168
|
+
"ttm"=>1.23},
|
150
169
|
"MXN"=>
|
151
170
|
{"currency"=>{"en"=>"Mexican Peso", "ja"=>"メキシコ・ペソ"},
|
152
171
|
"code"=>"MXN",
|
153
|
-
"tts"=>6.
|
154
|
-
"ttb"=>4.
|
172
|
+
"tts"=>6.66,
|
173
|
+
"ttb"=>4.66,
|
174
|
+
"ttm"=>8.99},
|
155
175
|
"KRW"=>
|
156
176
|
{"currency"=>{"en"=>"Won", "ja"=>"韓国ウォン"},
|
157
177
|
"code"=>"KRW",
|
158
|
-
"tts"=>10.
|
159
|
-
"ttb"=>9.
|
178
|
+
"tts"=>10.05,
|
179
|
+
"ttb"=>9.65,
|
180
|
+
"ttm"=>14.88},
|
160
181
|
"PHP"=>
|
161
182
|
{"currency"=>{"en"=>"Philippine Peso", "ja"=>"フィリピン・ペソ"},
|
162
183
|
"code"=>"PHP",
|
163
|
-
"tts"=>2.
|
164
|
-
"ttb"=>1.
|
184
|
+
"tts"=>2.21,
|
185
|
+
"ttb"=>1.93,
|
186
|
+
"ttm"=>3.18},
|
165
187
|
"ZAR"=>
|
166
188
|
{"currency"=>{"en"=>"Rand", "ja"=>"南アフリカ・ランド"},
|
167
189
|
"code"=>"ZAR",
|
168
|
-
"tts"=>10.
|
169
|
-
"ttb"=>7.
|
190
|
+
"tts"=>10.55,
|
191
|
+
"ttb"=>7.55,
|
192
|
+
"ttm"=>14.33},
|
170
193
|
"CZK"=>
|
171
194
|
{"currency"=>{"en"=>"Czech Koruna", "ja"=>"チェコ・コルナ"},
|
172
195
|
"code"=>"CZK",
|
173
|
-
"tts"=>5.
|
174
|
-
"ttb"=>5.
|
196
|
+
"tts"=>5.24,
|
197
|
+
"ttb"=>5.0,
|
198
|
+
"ttm"=>7.74},
|
175
199
|
"RUB"=>
|
176
200
|
{"currency"=>{"en"=>"Russian Ruble", "ja"=>"ロシア・ルーブル"},
|
177
201
|
"code"=>"RUB",
|
178
|
-
"tts"=>2.
|
179
|
-
"ttb"=>1.
|
202
|
+
"tts"=>2.15,
|
203
|
+
"ttb"=>1.65,
|
204
|
+
"ttm"=>2.98},
|
180
205
|
"HUF"=>
|
181
206
|
{"currency"=>{"en"=>"Hungarian Forint", "ja"=>"ハンガリー・フォリント"},
|
182
207
|
"code"=>"HUF",
|
183
|
-
"tts"=>0.
|
184
|
-
"ttb"=>0.
|
208
|
+
"tts"=>0.43,
|
209
|
+
"ttb"=>0.39,
|
210
|
+
"ttm"=>0.63},
|
185
211
|
"PLN"=>
|
186
212
|
{"currency"=>{"en"=>"Polish Zloty", "ja"=>"ポーランド・ズロチ"},
|
187
213
|
"code"=>"PLN",
|
188
|
-
"tts"=>32.
|
189
|
-
"ttb"=>
|
214
|
+
"tts"=>32.35,
|
215
|
+
"ttb"=>29.95,
|
216
|
+
"ttm"=>47.33},
|
190
217
|
"TRY"=>
|
191
218
|
{"currency"=>{"en"=>"Turkish Lira", "ja"=>"トルコ・リラ"},
|
192
219
|
"code"=>"TRY",
|
193
|
-
"tts"=>30.
|
194
|
-
"ttb"=>25.
|
195
|
-
=>
|
220
|
+
"tts"=>30.56,
|
221
|
+
"ttb"=>25.56,
|
222
|
+
"ttm"=>43.34}}
|
196
223
|
```
|
197
224
|
|
198
225
|
## Development
|
@@ -201,6 +228,26 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
201
228
|
|
202
229
|
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).
|
203
230
|
|
231
|
+
|
232
|
+
### Tests
|
233
|
+
|
234
|
+
|
235
|
+
```
|
236
|
+
% bundle exec rspec
|
237
|
+
```
|
238
|
+
|
239
|
+
### Publis a new version
|
240
|
+
|
241
|
+
Create a tag to be released and push to the github reopsitory. Github actions workflow proceeds ruby gem publish process.
|
242
|
+
```
|
243
|
+
% git switch master
|
244
|
+
% vim lib/ttsttb/version.rb
|
245
|
+
% git commit lib/ttsttb/version.rb -m 'bump version'
|
246
|
+
% git tag <v0.0.0>
|
247
|
+
% git push --tags
|
248
|
+
```
|
249
|
+
|
250
|
+
|
204
251
|
## Contributing
|
205
252
|
|
206
253
|
Bug reports and pull requests are welcome on GitHub at https://github.com/matsubo/ttsttb.
|
data/lib/ttsttb/version.rb
CHANGED
data/lib/ttsttb.rb
CHANGED
@@ -1,23 +1,35 @@
|
|
1
1
|
require 'ttsttb/version'
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'date'
|
3
5
|
|
4
6
|
# Scrape TTS and TTB data from MURC.
|
5
7
|
module Ttsttb
|
6
8
|
# Execute scraping
|
7
9
|
def self.find(date)
|
8
10
|
# TODO
|
9
|
-
|
11
|
+
raise 'Today is not supported yet.' if date == Date.today
|
10
12
|
|
11
|
-
|
12
|
-
throw 'Old data is not supported yet.' if date == Date.new(2006, 1, 1)
|
13
|
+
raise 'Old data before 1990/1/1 is not provided.' if date < Date.new(1990, 1, 1)
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
doc = Nokogiri::HTML(html(date))
|
16
|
+
scrape(doc)
|
17
|
+
end
|
16
18
|
|
17
|
-
|
19
|
+
def self.html(date)
|
20
|
+
url = format('http://www.murc-kawasesouba.jp/fx/past/index.php?id=%<ymd>s',
|
21
|
+
{ :ymd => date.strftime('%y%m%d') })
|
18
22
|
|
19
|
-
|
20
|
-
|
23
|
+
URI.open(url, :redirect => false).read.encode('utf-8')
|
24
|
+
rescue OpenURI::HTTPRedirect
|
25
|
+
url = format('http://www.murc-kawasesouba.jp/fx/past_3month_result.php?y=%<y>s&m=%<m>s&d=%<d>s&c=',
|
26
|
+
{
|
27
|
+
:y => date.strftime('%Y'),
|
28
|
+
:m => date.strftime('%m'),
|
29
|
+
:d => date.strftime('%d')
|
30
|
+
})
|
31
|
+
|
32
|
+
URI.open(url, :redirect => false).read.encode('utf-8')
|
21
33
|
end
|
22
34
|
|
23
35
|
# parse document
|
@@ -28,15 +40,18 @@ module Ttsttb
|
|
28
40
|
|
29
41
|
next unless tds[0]
|
30
42
|
|
43
|
+
tts = normalize(tds[3].content)
|
44
|
+
ttb = normalize(tds[4].content)
|
45
|
+
|
31
46
|
rows[tds[2].content] = {
|
32
47
|
'currency' => {
|
33
48
|
'en' => tds[0].content,
|
34
49
|
'ja' => tds[1].content
|
35
50
|
},
|
36
51
|
'code' => tds[2].content,
|
37
|
-
'tts' =>
|
38
|
-
'ttb' =>
|
39
|
-
'ttm' => get_ttm(
|
52
|
+
'tts' => tts,
|
53
|
+
'ttb' => ttb,
|
54
|
+
'ttm' => get_ttm(tts, ttb)
|
40
55
|
}
|
41
56
|
end
|
42
57
|
|
@@ -47,6 +62,7 @@ module Ttsttb
|
|
47
62
|
def self.normalize(value)
|
48
63
|
value = value.strip
|
49
64
|
return nil if value == 'unquoted'
|
65
|
+
|
50
66
|
value.to_f
|
51
67
|
end
|
52
68
|
|
@@ -56,6 +72,6 @@ module Ttsttb
|
|
56
72
|
|
57
73
|
return nil unless tts && ttb
|
58
74
|
|
59
|
-
(BigDecimal(tts.to_s) + BigDecimal(ttb.to_s) / 2).round(2).to_f
|
75
|
+
((BigDecimal(tts.to_s) + BigDecimal(ttb.to_s)) / 2).round(2).to_f
|
60
76
|
end
|
61
77
|
end
|
data/ttsttb.gemspec
CHANGED
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
if spec.respond_to?(:metadata)
|
19
19
|
else
|
20
20
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
21
|
-
|
21
|
+
"public gem pushes."
|
22
22
|
end
|
23
23
|
|
24
|
+
spec.required_ruby_version = '>= 2.7'
|
24
25
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
26
|
f.match(%r{^(test|spec|features)/})
|
26
27
|
end
|
@@ -28,8 +29,11 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
30
|
spec.require_paths = ["lib"]
|
30
31
|
|
31
|
-
spec.add_development_dependency "bundler", "~>
|
32
|
-
spec.add_development_dependency "rake", "~>
|
32
|
+
spec.add_development_dependency "bundler", "~> 2"
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
34
|
+
spec.add_development_dependency "rspec"
|
35
|
+
spec.add_development_dependency "rubocop"
|
36
|
+
spec.add_development_dependency 'simplecov'
|
33
37
|
|
34
38
|
spec.add_runtime_dependency 'nokogiri'
|
35
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ttsttb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Matsukura
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: 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: rubocop
|
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: simplecov
|
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'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: nokogiri
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,8 +101,12 @@ executables: []
|
|
59
101
|
extensions: []
|
60
102
|
extra_rdoc_files: []
|
61
103
|
files:
|
104
|
+
- ".github/workflows/publish.yml"
|
105
|
+
- ".github/workflows/ruby.yml"
|
62
106
|
- ".gitignore"
|
107
|
+
- ".rspec"
|
63
108
|
- ".rubocop.yml"
|
109
|
+
- ".rubocop_todo.yml"
|
64
110
|
- Gemfile
|
65
111
|
- Gemfile.lock
|
66
112
|
- README.md
|
@@ -74,7 +120,7 @@ files:
|
|
74
120
|
homepage: https://github.com/matsubo/ttsttb
|
75
121
|
licenses: []
|
76
122
|
metadata: {}
|
77
|
-
post_install_message:
|
123
|
+
post_install_message:
|
78
124
|
rdoc_options: []
|
79
125
|
require_paths:
|
80
126
|
- lib
|
@@ -82,16 +128,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
128
|
requirements:
|
83
129
|
- - ">="
|
84
130
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
131
|
+
version: '2.7'
|
86
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
133
|
requirements:
|
88
134
|
- - ">="
|
89
135
|
- !ruby/object:Gem::Version
|
90
136
|
version: '0'
|
91
137
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
signing_key:
|
138
|
+
rubygems_version: 3.1.2
|
139
|
+
signing_key:
|
95
140
|
specification_version: 4
|
96
141
|
summary: Fetch TTS and TTB corresponding to the date.
|
97
142
|
test_files: []
|