need_for_type 0.3.1 → 0.3.2
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 +11 -5
- data/lib/need_for_type/api.rb +11 -3
- data/lib/need_for_type/display_window.rb +8 -2
- data/lib/need_for_type/states/end.rb +11 -1
- data/lib/need_for_type/states/submit_score.rb +1 -1
- data/lib/need_for_type/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630c7e4f50ccb4765104fa05235a4d8c68264e13
|
4
|
+
data.tar.gz: f436084b96f0c78466ad896407dfe031d4effde0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1aedd33ddb4c2b7f236460b47757836e6d9fe979fb5f6ded0c963a5b24aa379fc85aec99be2dab37425f4061e9b516e05e851538237be19fc1f1c183abf00f8
|
7
|
+
data.tar.gz: a537744ace862c531de82facae1a09b686e5e533ac790b66bc914ffda7127d046c78546b46e726237fbb24fdc035713bd4b0c37c6a8a193f4fc6a60c6c844cd1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# need-for-type
|
2
2
|
|
3
|
-
need-for-type is a terminal type racer inpired by [Nitro Type](https://www.nitrotype.com/).
|
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
5
|

|
6
6
|
|
@@ -12,7 +12,7 @@ Run the following command:
|
|
12
12
|
$ gem install 'need_for_type'
|
13
13
|
```
|
14
14
|
|
15
|
-
##
|
15
|
+
## How to play
|
16
16
|
|
17
17
|
On a new terminal window run the following command:
|
18
18
|
|
@@ -28,17 +28,23 @@ You can run `./bin/console` for an interactive prompt that will allow you to exp
|
|
28
28
|
|
29
29
|
To install the development version of the gem onto your local machine, run `bundle exec rake install`.
|
30
30
|
|
31
|
-
|
31
|
+
### How to release a new version
|
32
32
|
|
33
|
+
To release a new version follow these steps:
|
34
|
+
|
35
|
+
1. Update the version in `version.rb`
|
36
|
+
2. Update changes for the corresponding version in `CHANGELOG.md`
|
37
|
+
3. Commit both `version.rb` and `CHANGELOG.md`
|
38
|
+
4. 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)
|
33
39
|
|
34
40
|
## Contributing
|
35
41
|
|
36
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/need-for-type/need-for-type. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
37
43
|
|
38
44
|
|
39
45
|
## Credits
|
40
46
|
|
41
|
-
Texts used in need-for-type were all kindly provided to us by [TypeRacer](http://play.typeracer.com/)
|
47
|
+
Texts used in need-for-type were all kindly provided to us by [TypeRacer](http://play.typeracer.com/).
|
42
48
|
|
43
49
|
## License
|
44
50
|
|
data/lib/need_for_type/api.rb
CHANGED
@@ -6,8 +6,13 @@ module NeedForType::API
|
|
6
6
|
|
7
7
|
def get_scores(text_id)
|
8
8
|
url = "https://#{@@api_url}/v1/scores?text_id=#{text_id}"
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
begin
|
11
|
+
response = HTTParty.get(url)
|
12
|
+
JSON.parse(response.body)
|
13
|
+
rescue HTTParty::Error, StandardError
|
14
|
+
{ error: "Ups! Something went wrong." }
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
def post_score(username, text_id, stats)
|
@@ -18,6 +23,9 @@ module NeedForType::API
|
|
18
23
|
wpm: stats[:wpm],
|
19
24
|
time: stats[:total_time],
|
20
25
|
accuracy: stats[:accuracy] } }
|
21
|
-
|
26
|
+
begin
|
27
|
+
HTTParty.post(url, headers: headers, body: body.to_json)
|
28
|
+
rescue HTTParty::Error, StandardError
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
@@ -132,9 +132,15 @@ module NeedForType
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def render_scores(scores, y, x)
|
135
|
-
if scores.
|
136
|
-
self.set_render_pos(y
|
135
|
+
if scores.nil?
|
136
|
+
self.set_render_pos(y, x)
|
137
|
+
self.addstr("Fetching scores...")
|
138
|
+
elsif scores.empty?
|
139
|
+
self.set_render_pos(y, x)
|
137
140
|
self.addstr("There are no score yet for this text.")
|
141
|
+
elsif scores[:error]
|
142
|
+
self.set_render_pos(y + 1, x)
|
143
|
+
self.addstr(scores[:error])
|
138
144
|
else
|
139
145
|
scores.each do |s|
|
140
146
|
self.set_render_pos(y, x)
|
@@ -14,12 +14,15 @@ module NeedForType::States
|
|
14
14
|
@text_id = text_id
|
15
15
|
|
16
16
|
@option = 0
|
17
|
-
@scores =
|
17
|
+
@scores = nil
|
18
|
+
fetch_and_render_scores_async
|
18
19
|
end
|
19
20
|
|
20
21
|
def update
|
21
22
|
@display_window.render_end(@stats, @scores, @option)
|
22
23
|
|
24
|
+
@fetch_and_render_scores_thread.join
|
25
|
+
|
23
26
|
input_worker(4) do
|
24
27
|
case @option
|
25
28
|
when 0
|
@@ -33,5 +36,12 @@ module NeedForType::States
|
|
33
36
|
|
34
37
|
return self
|
35
38
|
end
|
39
|
+
|
40
|
+
def fetch_and_render_scores_async
|
41
|
+
@fetch_and_render_scores_thread = Thread.new do
|
42
|
+
@scores = get_scores(@text_id)
|
43
|
+
@display_window.render_end(@stats, @scores, @option)
|
44
|
+
end
|
45
|
+
end
|
36
46
|
end
|
37
47
|
end
|
@@ -23,7 +23,7 @@ module NeedForType::States
|
|
23
23
|
|
24
24
|
if input == Curses::Key::ENTER || input == 10
|
25
25
|
post_score(@username, @text_id, @stats)
|
26
|
-
@end_state.
|
26
|
+
@end_state.fetch_and_render_scores_async
|
27
27
|
return @end_state
|
28
28
|
elsif input == Curses::Key::BACKSPACE || input == 127
|
29
29
|
@username = @username.chop
|
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.2
|
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: 2016-10-
|
12
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
description: need-for-type is a terminal type racer inpired by Nitro Type
|
84
|
+
description: need-for-type is a terminal type racer inpired by Nitro Type and TypeRacer
|
85
85
|
email:
|
86
86
|
- tiagonbotelho@gmail.com
|
87
87
|
- jbamaro95@gmail.com
|
@@ -826,7 +826,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
826
826
|
requirements:
|
827
827
|
- - ">="
|
828
828
|
- !ruby/object:Gem::Version
|
829
|
-
version: '
|
829
|
+
version: '2.3'
|
830
830
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
831
831
|
requirements:
|
832
832
|
- - ">="
|
@@ -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.6.
|
837
|
+
rubygems_version: 2.6.7
|
838
838
|
signing_key:
|
839
839
|
specification_version: 4
|
840
840
|
summary: A terminal typeracer
|