flox 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/flox +49 -56
- data/lib/flox.rb +3 -0
- data/lib/flox/rest_service.rb +1 -1
- data/lib/flox/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e270b70cbf4293d5e3ded85a0e179a1aadecb21
|
4
|
+
data.tar.gz: 7a9dd4ddb98a13d4491fbe12c677c8f77779a450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9233cde0da9935db8d8e9b4aa2e00177eee2f68c2ef46a9db828b3f247fa2a609fe15ac9198b13fbbf6aeb0db18da71b580edbb632ced6491807f0b4ef01f2c2
|
7
|
+
data.tar.gz: d748fe1818ce22e485257ed39916ab5211cb8b0a18c0f1f05ae53578726391de3e0a764934ce1c8f48d85ba043cd6ff207ab9f96880a9b7b17fb2dad9944e7d8
|
data/bin/flox
CHANGED
@@ -4,43 +4,36 @@
|
|
4
4
|
## Copyright: Copyright 2014 Gamua
|
5
5
|
## License: Simplified BSD
|
6
6
|
|
7
|
-
$LOAD_PATH << '../lib'
|
8
|
-
|
9
7
|
require 'flox'
|
10
8
|
require 'fileutils'
|
11
|
-
require '
|
9
|
+
require 'slop'
|
12
10
|
|
11
|
+
# Helper class that does the heavy lifting.
|
13
12
|
class Worker
|
14
13
|
|
15
14
|
attr_reader :flox
|
16
15
|
|
17
|
-
def initialize(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
flox.login_with_key(key)
|
23
|
-
end
|
16
|
+
def initialize(args={})
|
17
|
+
base_url = args[:url] || Flox::DEFAULT_URL
|
18
|
+
game_id = args[:game_id]
|
19
|
+
game_key = args[:game_key]
|
20
|
+
hero_key = args[:hero_key]
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rescue Exception => e
|
30
|
-
log "Error: " + e.to_s
|
31
|
-
end
|
22
|
+
@flox = Flox.new(game_id, game_key, base_url)
|
23
|
+
print "Logging in as Hero ... "
|
24
|
+
@flox.login_with_key hero_key
|
25
|
+
puts "done."
|
32
26
|
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
def download_logs(args={})
|
28
|
+
def load_logs(args={})
|
37
29
|
query = args[:query]
|
38
30
|
limit = args[:limit]
|
39
31
|
destination = args[:destination] || Dir.pwd
|
40
32
|
FileUtils.mkdir_p(destination)
|
41
33
|
|
42
|
-
|
34
|
+
print "Loading log IDs (this could take a moment) ... "
|
43
35
|
log_ids = flox.load_log_ids(query, limit)
|
36
|
+
puts "found #{log_ids.length} logs."
|
44
37
|
log_ids.each do |log_id|
|
45
38
|
remote_path = "logs/#{log_id}"
|
46
39
|
local_path = File.join(destination, log_id) + ".json"
|
@@ -48,55 +41,55 @@ class Worker
|
|
48
41
|
end
|
49
42
|
end
|
50
43
|
|
51
|
-
|
52
|
-
log "Fetching Server Status ..."
|
53
|
-
status = flox.status
|
54
|
-
log "Version: #{status['version']}, status: #{status['status']}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def log(message)
|
58
|
-
puts message
|
59
|
-
end
|
60
|
-
|
61
|
-
def fail(message)
|
62
|
-
log message
|
63
|
-
exit
|
64
|
-
end
|
44
|
+
private
|
65
45
|
|
66
46
|
def load_and_save_resource(remote_path, local_path)
|
67
47
|
if (File.exists? local_path)
|
68
|
-
|
48
|
+
puts("Skipped #{local_path} (file exists)")
|
69
49
|
else
|
70
50
|
resource = flox.load_resource(remote_path)
|
71
51
|
File.write(local_path, JSON.pretty_generate(resource))
|
72
|
-
|
52
|
+
puts("Saved #{local_path}")
|
73
53
|
end
|
74
54
|
end
|
75
55
|
|
76
56
|
end
|
77
57
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
58
|
+
#
|
59
|
+
# Parsing command line arguments
|
60
|
+
#
|
61
|
+
|
62
|
+
def shared_options
|
63
|
+
on :i, "game_id=", "The public identifier of the game", :required => true
|
64
|
+
on :k, "game_key=", "The private key of the game", :required => true
|
65
|
+
on :o, "hero_key=", "The key of a Hero player that will be logged in", :required => true
|
66
|
+
on :u, "url=", "The URL to the Flox service"
|
87
67
|
end
|
88
68
|
|
89
|
-
|
90
|
-
|
69
|
+
begin
|
70
|
+
|
71
|
+
ARGV << "-h" if ARGV.empty?
|
72
|
+
Slop.parse(ARGV, :help => true) do
|
91
73
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
base_url = options[:base_url] || Flox::DEFAULT_URL
|
74
|
+
on :v, "version", 'Print the current version of the Flox Gem.' do
|
75
|
+
puts "Gamua Flox v#{Flox::VERSION}"
|
76
|
+
end
|
96
77
|
|
97
|
-
|
98
|
-
|
78
|
+
command "load_logs" do
|
79
|
+
description "Fetch log files from the server."
|
80
|
+
|
81
|
+
shared_options
|
82
|
+
on :d, "destination=", "The directory in which to store the logs"
|
83
|
+
on :q, "query=", "Narrow down the results, e.g. 'day:2013-12-24 severity:error'"
|
84
|
+
on :l, "limit=", "Maximum number of logs to download", as: Integer
|
85
|
+
|
86
|
+
run do |opts, args|
|
87
|
+
Worker.new(opts).load_logs(opts)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
99
92
|
|
100
|
-
|
101
|
-
|
93
|
+
rescue Slop::Error, Flox::Error => error
|
94
|
+
puts error
|
102
95
|
end
|
data/lib/flox.rb
CHANGED
data/lib/flox/rest_service.rb
CHANGED
data/lib/flox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Sperl
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.4.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.4.7
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: mocha
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +86,8 @@ description: |
|
|
72
86
|
specific entities. It can be used from other Ruby scripts or directly with
|
73
87
|
its bundled command-line utility.
|
74
88
|
email: daniel@gamua.com
|
75
|
-
executables:
|
89
|
+
executables:
|
90
|
+
- flox
|
76
91
|
extensions: []
|
77
92
|
extra_rdoc_files: []
|
78
93
|
files:
|