scoreboard_rubywarrior 0.0.2 → 0.0.4
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/lib/scoreboard_rubywarrior/concatenator.rb +41 -0
- data/lib/scoreboard_rubywarrior/errors.rb +4 -0
- data/lib/scoreboard_rubywarrior/monkeys/level.rb +3 -0
- data/lib/scoreboard_rubywarrior/version.rb +1 -1
- data/lib/scoreboard_rubywarrior.rb +4 -2
- data/spec/fixtures/temp_ruby/file_one.rb +5 -0
- data/spec/fixtures/temp_ruby/file_two.rb +5 -0
- data/spec/fixtures/temp_ruby/player.rb +3 -0
- data/spec/fixtures/temp_ruby/subdir/file_three.rb +5 -0
- data/spec/lib/scoreboard_rubywarrior/concatenator_spec.rb +21 -0
- metadata +13 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3288d2d9f05ea8ed21c88a5e5214d9bcd47c313
|
4
|
+
data.tar.gz: 67442f5ffa316e14863e0cd1b6df643ae97bad3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac7ab7252babc0175bdb070efc322d1b1fb4580804df781aa276d2bff2e23bc562f3b004339bb37843f035d2256b22584af46c168d566d6545a847c8bbef0c1
|
7
|
+
data.tar.gz: 58ba749ae478dbf048f3862d5bbee400bf08dbfc2cf04c8d9d11e2f696d7506224d8fb4c3aa154983dcfe7861c32e6343cf77c92d9ea71c996bd0812a9bf150b
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ScoreboardRubywarrior
|
2
|
+
class Concatenator
|
3
|
+
def initialize(path)
|
4
|
+
@path = path
|
5
|
+
@contents_of_files = ""
|
6
|
+
end
|
7
|
+
|
8
|
+
def concatenate
|
9
|
+
raise ScoreboardRubywarrior::InvalidPlayerDirectory, "player.rb not present" unless player_file_exists?
|
10
|
+
all_ruby_files.each do |file|
|
11
|
+
append_file(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
contents_of_files
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :path
|
21
|
+
attr_accessor :contents_of_files
|
22
|
+
|
23
|
+
def all_ruby_files
|
24
|
+
Dir["#{path}/**/**/*.rb"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def append_file(file)
|
28
|
+
file_name = Pathname.new(file).basename
|
29
|
+
file_contents = File.read(file)
|
30
|
+
|
31
|
+
contents_of_files << "#" << file_name.to_s << "\n"
|
32
|
+
contents_of_files << "#---------------" << "\n"
|
33
|
+
contents_of_files << file_contents << "\n"
|
34
|
+
contents_of_files << "#---------------" << "\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def player_file_exists?
|
38
|
+
File.exist?(path + "/player.rb")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pry'
|
1
2
|
# here we patch the level.rb class to add our reporting
|
2
3
|
module RubyWarrior
|
3
4
|
class Level
|
@@ -31,6 +32,8 @@ module RubyWarrior
|
|
31
32
|
@profile.abilities = warrior.abilities.keys
|
32
33
|
report[:warrior_name] = @profile.warrior_name
|
33
34
|
report[:level_number] = @number
|
35
|
+
report[:source_code] = ::ScoreboardRubywarrior::Concatenator.new(Dir.pwd).concatenate
|
36
|
+
|
34
37
|
::ScoreboardRubywarrior::Reporter.send_level_update(report)
|
35
38
|
end
|
36
39
|
end
|
@@ -48,8 +48,10 @@ require 'ruby_warrior/abilities/explode'
|
|
48
48
|
require 'ruby_warrior/abilities/detonate'
|
49
49
|
require 'ruby_warrior/abilities/form'
|
50
50
|
|
51
|
-
require 'scoreboard_rubywarrior/reporter
|
52
|
-
require 'scoreboard_rubywarrior/
|
51
|
+
require 'scoreboard_rubywarrior/reporter'
|
52
|
+
require 'scoreboard_rubywarrior/concatenator'
|
53
|
+
require 'scoreboard_rubywarrior/errors'
|
54
|
+
require 'scoreboard_rubywarrior/monkeys/level'
|
53
55
|
|
54
56
|
module ScoreboardRubywarrior
|
55
57
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ScoreboardRubywarrior::Concatenator do
|
4
|
+
let(:path) { File.expand_path('../../../fixtures/temp_ruby/', __FILE__) }
|
5
|
+
|
6
|
+
it "should return a string representing all the files" do
|
7
|
+
content = ScoreboardRubywarrior::Concatenator.new(path).concatenate
|
8
|
+
expect(content).to match('def method_two')
|
9
|
+
expect(content).to match('class FileOne')
|
10
|
+
expect(content).to match('class FileTwo')
|
11
|
+
expect(content).to match('class FileThree')
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'path not containing player.rb' do
|
15
|
+
let(:path) { File.expand_path('../../../fixtures/', __FILE__) }
|
16
|
+
|
17
|
+
it "should rbinding.pryaise an error" do
|
18
|
+
expect{ScoreboardRubywarrior::Concatenator.new(path).concatenate}.to raise_exception(ScoreboardRubywarrior::InvalidPlayerDirectory)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Davey
|
@@ -145,10 +145,17 @@ files:
|
|
145
145
|
- Rakefile
|
146
146
|
- bin/scoreboard_rubywarrior
|
147
147
|
- lib/scoreboard_rubywarrior.rb
|
148
|
+
- lib/scoreboard_rubywarrior/concatenator.rb
|
149
|
+
- lib/scoreboard_rubywarrior/errors.rb
|
148
150
|
- lib/scoreboard_rubywarrior/monkeys/level.rb
|
149
151
|
- lib/scoreboard_rubywarrior/reporter.rb
|
150
152
|
- lib/scoreboard_rubywarrior/version.rb
|
151
153
|
- scoreboard_rubywarrior.gemspec
|
154
|
+
- spec/fixtures/temp_ruby/file_one.rb
|
155
|
+
- spec/fixtures/temp_ruby/file_two.rb
|
156
|
+
- spec/fixtures/temp_ruby/player.rb
|
157
|
+
- spec/fixtures/temp_ruby/subdir/file_three.rb
|
158
|
+
- spec/lib/scoreboard_rubywarrior/concatenator_spec.rb
|
152
159
|
- spec/lib/scoreboard_rubywarrior/reporter_spec.rb
|
153
160
|
- spec/spec_helper.rb
|
154
161
|
homepage: ''
|
@@ -176,5 +183,10 @@ signing_key:
|
|
176
183
|
specification_version: 4
|
177
184
|
summary: Adds the ability for rubywarrior to publish results to a webserver
|
178
185
|
test_files:
|
186
|
+
- spec/fixtures/temp_ruby/file_one.rb
|
187
|
+
- spec/fixtures/temp_ruby/file_two.rb
|
188
|
+
- spec/fixtures/temp_ruby/player.rb
|
189
|
+
- spec/fixtures/temp_ruby/subdir/file_three.rb
|
190
|
+
- spec/lib/scoreboard_rubywarrior/concatenator_spec.rb
|
179
191
|
- spec/lib/scoreboard_rubywarrior/reporter_spec.rb
|
180
192
|
- spec/spec_helper.rb
|