scoreboard_rubywarrior 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +11 -0
- data/lib/scoreboard_rubywarrior/reporter.rb +18 -3
- data/lib/scoreboard_rubywarrior/version.rb +1 -1
- data/spec/fixtures/.scoreboard_endpoint +1 -0
- data/spec/lib/scoreboard_rubywarrior/reporter_spec.rb +31 -18
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6201502dd7c54b3e76cd7e78272d2162026b2823
|
4
|
+
data.tar.gz: 83866ce8460f8f8c2a8ae08770b46f033eb3a744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4af27e288d25b7a3213492ce56d789402d76d9534862ef610ea08cfb27af10b2abe78cbdc8811b296fadedb62de97851359d57a3721c852f24c27a9a50ea5e6
|
7
|
+
data.tar.gz: 7dfe43996f0bbcd98f0a5f0b7bc893131bb0d6e4ac8db20861c9218a30d7abfff4ba4184c61969049292c0e67362139bd143a945b225fb9b17ed34b52e14833c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## 0.0.5 [Nov 30th 2014]
|
2
|
+
|
3
|
+
* Adds the ability to customize the endpoint which is posted to,
|
4
|
+
* so you can use this to basically stop the posting if you want to
|
5
|
+
* though we will add that at a future time
|
6
|
+
|
7
|
+
## 0.0.4 [Nov 2014]
|
8
|
+
|
9
|
+
* Adds the ability to post source code
|
10
|
+
|
11
|
+
## 0.0.3 [Nov 2014]
|
12
|
+
|
13
|
+
* Basic version of the gem, posting the scores to an endpoint
|
data/README.md
CHANGED
@@ -16,6 +16,17 @@ The website code is also open sourced at https://github.com/patrickdavey/rubywar
|
|
16
16
|
|
17
17
|
Please see Ryan Bates' instructions [on the original ruby-warrior](https://github.com/ryanb/ruby-warrior/)
|
18
18
|
|
19
|
+
## Endpoint
|
20
|
+
|
21
|
+
The website where the scores can be viewed (and source inspected etc.) is
|
22
|
+
available [on github](https://github.com/patrickdavey/rubywarrior_scoreboard)
|
23
|
+
by default, the scoreboard_rubywarrior will post to the demo herokuapp at
|
24
|
+
http://chchruby.herokuapp.com/scores .
|
25
|
+
|
26
|
+
If you want to post to your own custom website for your own meetup, all
|
27
|
+
you need to do is create a `.scoreboard_endpoint` file in the root of the
|
28
|
+
rubywarrior directory (so in the same directory as player.rb) and fill in
|
29
|
+
the URL that you want the scores to be posted to.
|
19
30
|
|
20
31
|
## Contributing
|
21
32
|
|
@@ -1,13 +1,28 @@
|
|
1
1
|
module ScoreboardRubywarrior
|
2
2
|
class Reporter
|
3
|
-
|
3
|
+
REPORTER_API_ENDPOINT_URI = 'http://chchruby-warrior.herokuapp.com/scores'
|
4
4
|
|
5
5
|
include HTTParty
|
6
|
-
base_uri
|
6
|
+
base_uri REPORTER_API_ENDPOINT_URI
|
7
7
|
|
8
8
|
def self.send_level_update(report)
|
9
|
-
post(
|
9
|
+
post(endpoint, body: report.to_json,
|
10
10
|
headers: { 'Content-Type' => 'application/json' })
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.endpoint
|
14
|
+
cusom_endpoint || REPORTER_API_ENDPOINT_URI
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.cusom_endpoint
|
21
|
+
endpoint_file = Pathname.new(Dir.pwd).join('.scoreboard_endpoint')
|
22
|
+
if File.exist?(endpoint_file)
|
23
|
+
return File.read(endpoint_file).strip
|
24
|
+
end
|
25
|
+
nil
|
26
|
+
end
|
12
27
|
end
|
13
28
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
http://mytest.example.com/endpoint
|
@@ -1,24 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module ScoreboardRubywarrior
|
3
|
+
describe Reporter do
|
4
|
+
let(:report_hash) { {
|
5
|
+
warrior_name: 'Trogdor',
|
6
|
+
level_score: 10,
|
7
|
+
time_bonus: 20,
|
8
|
+
clear_bonus: 30,
|
9
|
+
total_score: 60
|
10
|
+
}
|
10
11
|
}
|
11
|
-
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
before do
|
14
|
+
stub_request(:post, Reporter::REPORTER_API_ENDPOINT_URI).
|
15
|
+
with(:body => "{\"level_score\":0,\"time_bonus\":0,\"total_score\":\"0\",\"warrior_name\":null}",
|
16
|
+
:headers => {'Content-Type'=>'application/json'}).
|
17
|
+
to_return(:status => 200, :body => "", :headers => {})
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should post the details of a level" do
|
21
|
+
Reporter.should_receive(:post)
|
22
|
+
Reporter.send_level_update(report_hash)
|
23
|
+
end
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
describe 'endpoints' do
|
26
|
+
it "should have a default endpoint" do
|
27
|
+
Reporter.endpoint.should eq(Reporter::REPORTER_API_ENDPOINT_URI)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be possible to specify a different endpoint" do
|
32
|
+
allow(Dir).to receive(:pwd).and_return(File.expand_path('../../../fixtures/', __FILE__) )
|
33
|
+
Reporter.endpoint.should eq('http://mytest.example.com/endpoint')
|
34
|
+
end
|
23
35
|
end
|
36
|
+
|
24
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoreboard_rubywarrior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Davey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,7 @@ extensions: []
|
|
138
138
|
extra_rdoc_files: []
|
139
139
|
files:
|
140
140
|
- ".gitignore"
|
141
|
+
- CHANGELOG.md
|
141
142
|
- Gemfile
|
142
143
|
- Guardfile
|
143
144
|
- LICENSE.txt
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- lib/scoreboard_rubywarrior/reporter.rb
|
152
153
|
- lib/scoreboard_rubywarrior/version.rb
|
153
154
|
- scoreboard_rubywarrior.gemspec
|
155
|
+
- spec/fixtures/.scoreboard_endpoint
|
154
156
|
- spec/fixtures/temp_ruby/file_one.rb
|
155
157
|
- spec/fixtures/temp_ruby/file_two.rb
|
156
158
|
- spec/fixtures/temp_ruby/player.rb
|
@@ -183,6 +185,7 @@ signing_key:
|
|
183
185
|
specification_version: 4
|
184
186
|
summary: Adds the ability for rubywarrior to publish results to a webserver
|
185
187
|
test_files:
|
188
|
+
- spec/fixtures/.scoreboard_endpoint
|
186
189
|
- spec/fixtures/temp_ruby/file_one.rb
|
187
190
|
- spec/fixtures/temp_ruby/file_two.rb
|
188
191
|
- spec/fixtures/temp_ruby/player.rb
|