speedtest_net 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39d774cd49d85c30b04b9bb3dfd9743b33858f177ddaaaf9e3e165aef24e31cd
4
- data.tar.gz: d71d13cca347f15923c8aa1ffa14799554553f5201f41c613a6c4c451cf00bf5
3
+ metadata.gz: e5aeb295f704c706b11dd75b988b6e6bfca9654594f4bcb40c8e50578edd0f3d
4
+ data.tar.gz: 15393d3a2c2ae9280d2d21dc256f21dac8b6c852840ff73deae55a5f7cdc461e
5
5
  SHA512:
6
- metadata.gz: 9a7fc6501f22d46c3ed6e8a999e78042dd71b6f8e1aab714efaea797276bb3fea0727a755b916c9af3fc6bb63c23db5ee7dd82dbc38d9014a68a6d845c6e8e9a
7
- data.tar.gz: cfeea44e6c008e8fa52223c8add27a7807e9f41a2ded4a3dcdf08ef1651fc1947145f44b64fa7b8a495965136348e29bb78e042895a3e9066a2c194b19bf791c
6
+ metadata.gz: c6b7e29afdd57fc54ac599dee9063a38c96636658fced1f5c3d001fc096cb37136a272cbb1af3dc833f3581459645553c0c97dfaf3ff66d11d59d8810470452b
7
+ data.tar.gz: 2176eea906ec1d49ba51d20bc67c7a3fd0ba4f8a0991bf5910cf1c4f1cf102b7fcf3101555730e49469926678dd4b0283fa962d1d3daa8687545985cc5af1df8
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
- require: rubocop-rspec
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
2
5
 
3
6
  AllCops:
4
7
  TargetRubyVersion: 2.6
data/Gemfile CHANGED
@@ -10,6 +10,8 @@ gem 'factory_bot', '>= 6.0'
10
10
  gem 'rake', '>= 13.0'
11
11
  gem 'rspec', '>= 3.0'
12
12
  gem 'rubocop', '>= 1.0.0'
13
+ gem 'rubocop-performance', '>= 1.11.4'
14
+ gem 'rubocop-rake', '>= 0.6.0'
13
15
  gem 'rubocop-rspec', '>= 1.44.1'
14
16
  gem 'simplecov', '>= 0.17'
15
17
  gem 'vcr', '>= 6.0'
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/speedtest_net.svg)](https://badge.fury.io/rb/speedtest_net)
4
4
  [![Actions Status](https://github.com/ryonkn/speedtest_net/workflows/GitHub%20Actions/badge.svg)](https://github.com/ryonkn/speedtest_net/actions)
5
5
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/fa55809b2789403489d9d5063249c238)](https://www.codacy.com/manual/ryonkn/speedtest_net/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ryonkn/speedtest_net&utm_campaign=Badge_Grade)
6
- [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/fa55809b2789403489d9d5063249c238)](https://www.codacy.com/manual/ryonkn/speedtest_net/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ryonkn/speedtest_net&utm_campaign=Badge_Coverage)
6
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/fa55809b2789403489d9d5063249c238)](https://www.codacy.com/gh/ryonkn/speedtest_net/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ryonkn/speedtest_net&utm_campaign=Badge_Grade)
7
7
 
8
8
  A Ruby library for testing internet bandwidth using speedtest.net
9
9
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'curb'
4
4
  require 'securerandom'
5
+ require 'timeout'
5
6
  require 'pathname'
6
7
  require 'speedtest_net/calculate_speed'
7
8
  require 'speedtest_net/http_timeout'
@@ -42,7 +43,7 @@ module SpeedtestNet
42
43
 
43
44
  def create_urls(server, file, number)
44
45
  base_url = Pathname(server.url).dirname.to_s
45
- number.times.map do
46
+ Array.new(number) do
46
47
  random = SecureRandom.urlsafe_base64
47
48
  "#{base_url}/#{file}?x=#{random}"
48
49
  end
@@ -58,7 +59,7 @@ module SpeedtestNet
58
59
  multi.add(client)
59
60
  end
60
61
  multi.perform
61
- responses.map(&:download_speed).sum * 8
62
+ responses.sum(&:download_speed) * 8
62
63
  end
63
64
  end
64
65
  end
@@ -11,9 +11,8 @@ module SpeedtestNet
11
11
  end
12
12
 
13
13
  def distance(other) # rubocop:disable Metrics/AbcSize
14
- a = Math.sin(radian_lat) * Math.sin(other.radian_lat) +
15
- Math.cos(radian_lat) * Math.cos(other.radian_lat) *
16
- Math.cos(radian_long - other.radian_long)
14
+ a = (Math.sin(radian_lat) * Math.sin(other.radian_lat)) +
15
+ (Math.cos(radian_lat) * Math.cos(other.radian_lat) * Math.cos(radian_long - other.radian_long))
17
16
 
18
17
  Math.acos(a) * EARTH_RADIUS
19
18
  end
@@ -15,7 +15,7 @@ module SpeedtestNet
15
15
  test_length = test_length(config)
16
16
  timeout = config.latency[:timeout]
17
17
 
18
- latencies = test_length.times.map do
18
+ latencies = Array.new(test_length) do
19
19
  latency_url = latency_url(server)
20
20
  measure_latency(latency_url, timeout)
21
21
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'curb'
4
4
  require 'securerandom'
5
+ require 'timeout'
5
6
  require 'speedtest_net/calculate_speed'
6
7
  require 'speedtest_net/http_timeout'
7
8
 
@@ -39,7 +40,7 @@ module SpeedtestNet
39
40
  private
40
41
 
41
42
  def create_urls(server, number)
42
- number.times.map do
43
+ Array.new(number) do
43
44
  random = SecureRandom.urlsafe_base64
44
45
  "#{server.url}?x=#{random}"
45
46
  end
@@ -57,7 +58,7 @@ module SpeedtestNet
57
58
  multi.add(client)
58
59
  end
59
60
  multi.perform
60
- responses.map(&:upload_speed).sum * 8
61
+ responses.sum(&:upload_speed) * 8
61
62
  end
62
63
  end
63
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpeedtestNet
4
- VERSION = '0.8.1'
4
+ VERSION = '0.9.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speedtest_net
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-11 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.2.15
116
+ rubygems_version: 3.2.22
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Library for testing internet bandwidth using speedtest.net