need_for_type 0.3.4 → 0.3.5
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/need_for_type/api.rb +6 -4
- data/lib/need_for_type/display_window.rb +2 -2
- data/lib/need_for_type/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 21273239660063b2eb6f792b9331fd087a464c03dd9ec56d521761739b614ae6
|
|
4
|
+
data.tar.gz: ed03bda50015ef66ec13db94bbd482fbc8198f10050fd8dac9a9dbc8e121fb61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35bef576f4ac5756dbeccfa215fd66af6f3efad6984031b817c30eee54f59bd58c76634c7f0277adb135b259c23284950eaa2667b102faf1ba95aac29a7bd3c9
|
|
7
|
+
data.tar.gz: fb8088952b578e156b4779e98bd8d6a3c1e5e4ffa9c76a0d242c20266a2b36267c4ed505f5424848f40916e258e72e9f93a38956e54eea63fb10c6818949d425
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
need-for-type is a terminal type racer inpired by [Nitro Type](https://www.nitrotype.com/) and [TypeRacer](http://play.typeracer.com/).
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
data/lib/need_for_type/api.rb
CHANGED
|
@@ -2,26 +2,28 @@ require 'json'
|
|
|
2
2
|
require 'httparty'
|
|
3
3
|
|
|
4
4
|
module NeedForType::API
|
|
5
|
-
|
|
5
|
+
API_URL = 'need-for-type.herokuapp.com'.freeze
|
|
6
6
|
|
|
7
7
|
def get_scores(text_id)
|
|
8
|
-
url = "https://#{
|
|
8
|
+
url = "https://#{API_URL}/v1/scores?text_id=#{text_id}"
|
|
9
9
|
|
|
10
10
|
begin
|
|
11
11
|
response = HTTParty.get(url)
|
|
12
12
|
{ scores: JSON.parse(response.body) }
|
|
13
|
+
rescue SocketError
|
|
14
|
+
{ error: 'You are not connected to the internet.' }
|
|
13
15
|
rescue HTTParty::Error, StandardError
|
|
14
16
|
{ error: "Ups! Something went wrong." }
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def post_score(username, text_id, stats)
|
|
19
|
-
url = "https://#{
|
|
21
|
+
url = "https://#{API_URL}/v1/scores"
|
|
20
22
|
headers = { 'Content-Type' => 'application/json' }
|
|
21
23
|
body = { score: { username: username,
|
|
22
24
|
text_id: text_id,
|
|
23
25
|
wpm: stats[:wpm],
|
|
24
|
-
time: stats[:total_time],
|
|
26
|
+
time: stats[:total_time],
|
|
25
27
|
accuracy: stats[:accuracy] } }
|
|
26
28
|
begin
|
|
27
29
|
HTTParty.post(url, headers: headers, body: body.to_json)
|
|
@@ -83,7 +83,7 @@ module NeedForType
|
|
|
83
83
|
self.render_text("4. Exit", WHITE, mode)
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
def render_submit_score(username)
|
|
88
88
|
self.render_box do
|
|
89
89
|
self.set_render_pos(3, 4)
|
|
@@ -140,7 +140,7 @@ module NeedForType
|
|
|
140
140
|
self.addstr("There are no scores yet for this text.")
|
|
141
141
|
elsif scores_request[:error]
|
|
142
142
|
self.set_render_pos(y + 1, x)
|
|
143
|
-
self.addstr(
|
|
143
|
+
self.addstr(scores_request[:error])
|
|
144
144
|
else
|
|
145
145
|
scores_request[:scores].each do |s|
|
|
146
146
|
self.set_render_pos(y, x)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: need_for_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tiagonbotelho
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-
|
|
12
|
+
date: 2018-10-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -834,7 +834,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
834
834
|
version: '0'
|
|
835
835
|
requirements: []
|
|
836
836
|
rubyforge_project:
|
|
837
|
-
rubygems_version: 2.7.
|
|
837
|
+
rubygems_version: 2.7.7
|
|
838
838
|
signing_key:
|
|
839
839
|
specification_version: 4
|
|
840
840
|
summary: A terminal typeracer
|