zion_data 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +22 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +66 -0
- data/README.md +79 -0
- data/bin/zion_data +5 -0
- data/lib/zion_data.rb +30 -0
- data/lib/zion_data/client.rb +27 -0
- data/lib/zion_data/parser.rb +32 -0
- data/lib/zion_data/parser/helpers.rb +28 -0
- data/lib/zion_data/parser/loopholes.rb +30 -0
- data/lib/zion_data/parser/sentinels.rb +29 -0
- data/lib/zion_data/parser/sniffers.rb +43 -0
- data/lib/zion_data/version.rb +3 -0
- data/main.rb +4 -0
- data/spec/lib/zion_data/parser/loopholes_spec.rb +44 -0
- data/spec/lib/zion_data/parser/sentinels_spec.rb +34 -0
- data/spec/lib/zion_data/parser/sniffers_spec.rb +53 -0
- data/spec/spec_helper.rb +6 -0
- data/zion_data.gemspec +21 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 528dcc4c4949a2b7c74294850e0e424b2f0d3ee0
|
4
|
+
data.tar.gz: 47c3dfcbf7451527806781892ddb25707cac9de1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97711d09d5d38165ffebc2f4e1c24f9758993ab58a6931b42388131f6d581b5f237b4a5c7140ed26d92988a4e9b05697e060eb1c41cb3abc1d6a3ef895440793
|
7
|
+
data.tar.gz: eb3bd987b27df091e86e9a9c5443233dc0cb294e5a66b252337591758c421b9fc231b1ca0b321ced64811f7c5453f3f6cc8c042aea688f9d7c4aca96efbbe0ba
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# See full list of defaults here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
+
# To see all cops used see here: https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.3
|
6
|
+
DisplayCopNames: true
|
7
|
+
|
8
|
+
LineLength:
|
9
|
+
Max: 120
|
10
|
+
|
11
|
+
Style/OpMethod:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/FrozenStringLiteralComment:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Security/Eval:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Exclude:
|
22
|
+
- '**/*_spec.rb'
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zion_data (0.1.0)
|
5
|
+
rest-client (= 2.0.2)
|
6
|
+
rubyzip (= 1.2.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.3.0)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
domain_name (0.5.20170404)
|
14
|
+
unf (>= 0.0.5, < 1.0.0)
|
15
|
+
http-cookie (1.0.3)
|
16
|
+
domain_name (~> 0.5)
|
17
|
+
mime-types (3.1)
|
18
|
+
mime-types-data (~> 3.2015)
|
19
|
+
mime-types-data (3.2016.0521)
|
20
|
+
netrc (0.11.0)
|
21
|
+
parser (2.4.0.0)
|
22
|
+
ast (~> 2.2)
|
23
|
+
powerpack (0.1.1)
|
24
|
+
rainbow (2.2.2)
|
25
|
+
rake
|
26
|
+
rake (12.0.0)
|
27
|
+
rest-client (2.0.2)
|
28
|
+
http-cookie (>= 1.0.2, < 2.0)
|
29
|
+
mime-types (>= 1.16, < 4.0)
|
30
|
+
netrc (~> 0.8)
|
31
|
+
rspec (3.6.0)
|
32
|
+
rspec-core (~> 3.6.0)
|
33
|
+
rspec-expectations (~> 3.6.0)
|
34
|
+
rspec-mocks (~> 3.6.0)
|
35
|
+
rspec-core (3.6.0)
|
36
|
+
rspec-support (~> 3.6.0)
|
37
|
+
rspec-expectations (3.6.0)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.6.0)
|
40
|
+
rspec-mocks (3.6.0)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.6.0)
|
43
|
+
rspec-support (3.6.0)
|
44
|
+
rubocop (0.48.1)
|
45
|
+
parser (>= 2.3.3.1, < 3.0)
|
46
|
+
powerpack (~> 0.1)
|
47
|
+
rainbow (>= 1.99.1, < 3.0)
|
48
|
+
ruby-progressbar (~> 1.7)
|
49
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
50
|
+
ruby-progressbar (1.8.1)
|
51
|
+
rubyzip (1.2.1)
|
52
|
+
unf (0.1.4)
|
53
|
+
unf_ext
|
54
|
+
unf_ext (0.0.7.4)
|
55
|
+
unicode-display_width (1.2.1)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
rspec
|
62
|
+
rubocop
|
63
|
+
zion_data!
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.14.6
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
### Installation
|
2
|
+
|
3
|
+
```bash
|
4
|
+
gem install zion_data
|
5
|
+
```
|
6
|
+
|
7
|
+
### Usage
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ zion_data
|
11
|
+
Zion data manager version: 0.1.0
|
12
|
+
=== Get loopholes
|
13
|
+
=== Get sentinels
|
14
|
+
=== Get sniffers
|
15
|
+
=== Post loopholes data: {:start_node=>"gamma", :end_node=>"theta", :start_time=>"2030-12-31T13:00:04", :end_time=>"2030-12-31T13:00:05"}
|
16
|
+
(•̀_•́ ) -> Targeting... almost there. Lock! I got him!
|
17
|
+
(⌐■_■) -> Now, Tank now!
|
18
|
+
-------- -> --------
|
19
|
+
ヽ(´‿`)ノ -> Welcome to the real world, Neo.
|
20
|
+
=== Post loopholes data: {:start_node=>"theta", :end_node=>"lambda", :start_time=>"2030-12-31T13:00:05", :end_time=>"2030-12-31T13:00:06"}
|
21
|
+
(•̀_•́ ) -> Targeting... almost there. Lock! I got him!
|
22
|
+
(⌐■_■) -> Now, Tank now!
|
23
|
+
-------- -> --------
|
24
|
+
ヽ(´‿`)ノ -> Welcome to the real world, Neo.
|
25
|
+
...
|
26
|
+
```
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'zion_data'
|
30
|
+
require 'pp'
|
31
|
+
pp ZionData.sources # returns parsed sources
|
32
|
+
#{"loopholes"=>
|
33
|
+
# [{:start_node=>"gamma",
|
34
|
+
# :end_node=>"theta",
|
35
|
+
# :start_time=>"2030-12-31T13:00:04",
|
36
|
+
# :end_time=>"2030-12-31T13:00:05"},
|
37
|
+
# {:start_node=>"theta",
|
38
|
+
# :end_node=>"lambda",
|
39
|
+
# :start_time=>"2030-12-31T13:00:05",
|
40
|
+
# :end_time=>"2030-12-31T13:00:06"},
|
41
|
+
# {:start_node=>"beta",
|
42
|
+
# :end_node=>"theta",
|
43
|
+
# :start_time=>"2030-12-31T13:00:05",
|
44
|
+
# :end_time=>"2030-12-31T13:00:06"},
|
45
|
+
# {:start_node=>"theta",
|
46
|
+
# :end_node=>"lambda",
|
47
|
+
# :start_time=>"2030-12-31T13:00:06",
|
48
|
+
# :end_time=>"2030-12-31T13:00:07"}],
|
49
|
+
# "sentinels"=>
|
50
|
+
# [{:start_node=>"beta",
|
51
|
+
# :end_node=>"beta",
|
52
|
+
# :start_time=>"2030-12-31T13:00:02",
|
53
|
+
# :end_time=>"2030-12-31T13:00:03"},
|
54
|
+
# {:start_node=>"gamma",
|
55
|
+
# :end_node=>"gamma",
|
56
|
+
# :start_time=>"2030-12-31T13:00:03",
|
57
|
+
# :end_time=>"2030-12-31T13:00:04"}],
|
58
|
+
# "sniffers"=>
|
59
|
+
# [{:start_node=>"lambda",
|
60
|
+
# :end_node=>"tau",
|
61
|
+
# :start_time=>"2030-12-31T13:00:06",
|
62
|
+
# :end_time=>"2030-12-31T13:00:07"},
|
63
|
+
# {:start_node=>"tau",
|
64
|
+
# :end_node=>"psi",
|
65
|
+
# :start_time=>"2030-12-31T13:00:06",
|
66
|
+
# :end_time=>"2030-12-31T13:00:07"},
|
67
|
+
# {:start_node=>"psi",
|
68
|
+
# :end_node=>"omega",
|
69
|
+
# :start_time=>"2030-12-31T13:00:06",
|
70
|
+
# :end_time=>"2030-12-31T13:00:07"},
|
71
|
+
# {:start_node=>"lambda",
|
72
|
+
# :end_node=>"psi",
|
73
|
+
# :start_time=>"2030-12-31T13:00:07",
|
74
|
+
# :end_time=>"2030-12-31T13:00:08"},
|
75
|
+
# {:start_node=>"psi",
|
76
|
+
# :end_node=>"omega",
|
77
|
+
# :start_time=>"2030-12-31T13:00:07",
|
78
|
+
# :end_time=>"2030-12-31T13:00:08"}]}
|
79
|
+
```
|
data/bin/zion_data
ADDED
data/lib/zion_data.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'csv'
|
3
|
+
require 'zip'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'zion_data/client'
|
6
|
+
require 'zion_data/parser'
|
7
|
+
require 'zion_data/parser/helpers'
|
8
|
+
require 'zion_data/parser/loopholes'
|
9
|
+
require 'zion_data/parser/sentinels'
|
10
|
+
require 'zion_data/parser/sniffers'
|
11
|
+
require 'zion_data/version'
|
12
|
+
|
13
|
+
# Base namespace of the gem
|
14
|
+
module ZionData
|
15
|
+
SOURCES = %w[loopholes sentinels sniffers].freeze
|
16
|
+
|
17
|
+
module_function
|
18
|
+
|
19
|
+
def send_corrected_sources
|
20
|
+
sources.each do |source, data|
|
21
|
+
data.each { |di| Client.post_source_data(source, di) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def sources
|
26
|
+
SOURCES.each_with_object({}) do |source, result|
|
27
|
+
result[source] = Parser.parse(source, Client.get_source(source))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ZionData
|
2
|
+
# Class for communication with zion server
|
3
|
+
module Client
|
4
|
+
ZION_URL = 'http://challenge.distribusion.com/the_one/routes'.freeze
|
5
|
+
PASS_PHRASE = 'Kans4s-i$-g01ng-by3-bye'.freeze
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def get_source(source)
|
9
|
+
puts "=== Get #{source}"
|
10
|
+
client.get(params: { source: source, passphrase: PASS_PHRASE }).body
|
11
|
+
end
|
12
|
+
|
13
|
+
def post_source_data(source, payload)
|
14
|
+
puts "=== Post #{source} data: #{payload}"
|
15
|
+
data = client.post(payload.merge(source: source, passphrase: PASS_PHRASE)).body
|
16
|
+
messages = eval(data)
|
17
|
+
puts(messages.map { |k, v| " #{k} -> #{v}" }) if messages.respond_to?(:map)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client ||= RestClient::Resource.new(ZION_URL)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ZionData
|
2
|
+
# Namespace for Zion data parsers
|
3
|
+
module Parser
|
4
|
+
class << self
|
5
|
+
def parse(source, data)
|
6
|
+
[].tap do |result|
|
7
|
+
Zip::File.open_buffer(data) do |zip|
|
8
|
+
params = zip_entries_data(zip)
|
9
|
+
result.push(*get_source_const(source).new(params).parse)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def basename(file_name)
|
17
|
+
File.basename(file_name).gsub(/\..+$/, '').to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_source_const(name)
|
21
|
+
Object.const_get([self.name, name.capitalize].join('::'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def zip_entries_data(zip)
|
25
|
+
zip.select { |e| e.file? && e.name =~ %r{\w+/\w+\.\w+} }
|
26
|
+
.each_with_object({}) do |entry, result|
|
27
|
+
result[basename(entry.name)] = entry.get_input_stream.read
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ZionData
|
2
|
+
module Parser
|
3
|
+
# Helpers module for parsing Zion data
|
4
|
+
module Helpers
|
5
|
+
TIME_FORMAT = '%FT%T'.freeze
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def parse_csv(csv_string)
|
10
|
+
options = { headers: true, converters: :numeric, col_sep: ', ' }
|
11
|
+
CSV.parse(csv_string, options).map(&:to_hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
def convert_time(time_string)
|
15
|
+
DateTime.parse(time_string).to_time.utc.strftime(TIME_FORMAT)
|
16
|
+
end
|
17
|
+
|
18
|
+
def payload(start_node, end_node, start_time, end_time)
|
19
|
+
{
|
20
|
+
start_node: start_node,
|
21
|
+
end_node: end_node,
|
22
|
+
start_time: convert_time(start_time),
|
23
|
+
end_time: convert_time(end_time)
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ZionData
|
2
|
+
module Parser
|
3
|
+
# Class for parsing Zion loopholes data
|
4
|
+
class Loopholes
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
attr_reader :routes, :node_pairs
|
8
|
+
|
9
|
+
def initialize(routes:, node_pairs:)
|
10
|
+
@routes = JSON.parse(routes)['routes']
|
11
|
+
@node_pairs = JSON.parse(node_pairs)['node_pairs']
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse
|
15
|
+
routes.each_with_object([]) do |route, result|
|
16
|
+
node_pair = find_node_pair(route['node_pair_id'])
|
17
|
+
next unless node_pair
|
18
|
+
result << payload(node_pair['start_node'], node_pair['end_node'],
|
19
|
+
route['start_time'], route['end_time'])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def find_node_pair(node_pair_id)
|
26
|
+
node_pairs.find { |np| np['id'] == node_pair_id }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ZionData
|
2
|
+
module Parser
|
3
|
+
# Class for parsing Zion sentinels data
|
4
|
+
class Sentinels
|
5
|
+
ROUTE_GROUP_SIZE = 2
|
6
|
+
|
7
|
+
include Helpers
|
8
|
+
|
9
|
+
attr_reader :routes
|
10
|
+
|
11
|
+
def initialize(routes:)
|
12
|
+
@routes = parse_csv(routes)
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse
|
16
|
+
route_groups.map do |first, last|
|
17
|
+
payload(first['node'], last['node'], first['time'], last['time'])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def route_groups
|
24
|
+
routes.sort_by { |r| r['route_id'] }.group_by { |r| r['index'] }.values
|
25
|
+
.select { |r| r.size == ROUTE_GROUP_SIZE }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ZionData
|
2
|
+
module Parser
|
3
|
+
# Class for parsing Zion sniffers data
|
4
|
+
class Sniffers
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
attr_reader :routes, :node_times, :sequences
|
8
|
+
|
9
|
+
def initialize(routes:, node_times:, sequences:)
|
10
|
+
@routes = parse_csv(routes)
|
11
|
+
@node_times = parse_csv(node_times)
|
12
|
+
@sequences = parse_csv(sequences)
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse
|
16
|
+
sequences.each_with_object([]) do |sequence, result|
|
17
|
+
route = find_route(sequence['route_id'])
|
18
|
+
node_time = find_node_time(sequence['node_time_id'])
|
19
|
+
next unless route && node_time
|
20
|
+
|
21
|
+
result << payload(node_time['start_node'], node_time['end_node'],
|
22
|
+
route['time'], end_time(route['time'], node_time))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def end_time(time_string, node_time)
|
29
|
+
start_time = DateTime.parse(time_string).to_time.utc
|
30
|
+
end_time = start_time + node_time['duration_in_milliseconds'] / 1000
|
31
|
+
end_time.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_route(route_id)
|
35
|
+
routes.find { |r| r['route_id'] == route_id }
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_node_time(node_time_id)
|
39
|
+
node_times.find { |r| r['node_time_id'] == node_time_id }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/main.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ZionData::Parser::Loopholes do
|
4
|
+
describe '#parse' do
|
5
|
+
subject { described_class.new(routes: routes, node_pairs: node_pairs).parse }
|
6
|
+
|
7
|
+
context 'when correct data given' do
|
8
|
+
let(:routes) do
|
9
|
+
'{"routes":[{
|
10
|
+
"route_id":"1",
|
11
|
+
"node_pair_id":"1",
|
12
|
+
"start_time":"2030-12-31T13:00:04Z",
|
13
|
+
"end_time":"2030-12-31T13:00:05Z"}]}'
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:node_pairs) do
|
17
|
+
'{"node_pairs":[{
|
18
|
+
"id":"1",
|
19
|
+
"start_node":"gamma",
|
20
|
+
"end_node":"theta"}]}'
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:expected_data) do
|
24
|
+
[
|
25
|
+
{
|
26
|
+
start_node: 'gamma',
|
27
|
+
end_node: 'theta',
|
28
|
+
start_time: '2030-12-31T13:00:04',
|
29
|
+
end_time: '2030-12-31T13:00:05'
|
30
|
+
}
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
it { is_expected.to eql(expected_data) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when empty data given' do
|
38
|
+
let(:routes) { '{"routes":[]}' }
|
39
|
+
let(:node_pairs) { '{"node_pairs":[]}' }
|
40
|
+
|
41
|
+
it { is_expected.to be_empty }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ZionData::Parser::Sentinels do
|
4
|
+
describe '#parse' do
|
5
|
+
subject { described_class.new(routes: routes).parse }
|
6
|
+
|
7
|
+
context 'when correct data given' do
|
8
|
+
let(:routes) do
|
9
|
+
'"route_id", "node", "index", "time"
|
10
|
+
"1", "alpha", "0", "2030-12-31T22:00:01+09:00"
|
11
|
+
"2", "delta", "0", "2030-12-31T22:00:02+09:00"'
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:expected_data) do
|
15
|
+
[
|
16
|
+
{
|
17
|
+
start_node: 'alpha',
|
18
|
+
end_node: 'delta',
|
19
|
+
start_time: '2030-12-31T13:00:01',
|
20
|
+
end_time: '2030-12-31T13:00:02'
|
21
|
+
}
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
it { is_expected.to eql(expected_data) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when empty data given' do
|
29
|
+
let(:routes) { '"route_id", "node", "index", "time"' }
|
30
|
+
|
31
|
+
it { is_expected.to be_empty }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ZionData::Parser::Sniffers do
|
4
|
+
describe '#parse' do
|
5
|
+
subject { described_class.new(routes: routes, node_times: node_times, sequences: sequences).parse }
|
6
|
+
|
7
|
+
context 'when correct data given' do
|
8
|
+
let(:routes) do
|
9
|
+
'"route_id", "time", "time_zone"
|
10
|
+
"1", "2030-12-31T13:00:06", "UTC±00:00"'
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:node_times) do
|
14
|
+
'"node_time_id", "start_node", "end_node", "duration_in_milliseconds"
|
15
|
+
"1", "lambda", "tau", "1000"'
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:sequences) do
|
19
|
+
'"route_id", "node_time_id"
|
20
|
+
"1", "1"'
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:expected_data) do
|
24
|
+
[
|
25
|
+
{
|
26
|
+
start_node: 'lambda',
|
27
|
+
end_node: 'tau',
|
28
|
+
start_time: '2030-12-31T13:00:06',
|
29
|
+
end_time: '2030-12-31T13:00:07'
|
30
|
+
}
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
it { is_expected.to eql(expected_data) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when empty data given' do
|
38
|
+
let(:routes) do
|
39
|
+
'"route_id", "time", "time_zone"'
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:node_times) do
|
43
|
+
'"node_time_id", "start_node", "end_node", "duration_in_milliseconds"'
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:sequences) do
|
47
|
+
'"route_id", "node_time_id"'
|
48
|
+
end
|
49
|
+
|
50
|
+
it { is_expected.to be_empty }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/zion_data.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../lib/zion_data/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'zion_data'
|
5
|
+
gem.version = ZionData::VERSION
|
6
|
+
gem.date = '2017-05-12'
|
7
|
+
gem.summary = 'Zion data manager'
|
8
|
+
gem.description = 'Ruby gem to manage zion data'
|
9
|
+
gem.authors = ['Konstantin Lynda']
|
10
|
+
gem.email = 'knlynda@gmail.com'
|
11
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
12
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
13
|
+
gem.require_paths = ['lib']
|
14
|
+
gem.bindir = 'bin'
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
|
+
gem.homepage = 'http://rubygems.org/gems/zion_data'
|
17
|
+
gem.license = 'MIT'
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'rest-client', '2.0.2'
|
20
|
+
gem.add_runtime_dependency 'rubyzip', '1.2.1'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zion_data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Lynda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyzip
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.1
|
41
|
+
description: Ruby gem to manage zion data
|
42
|
+
email: knlynda@gmail.com
|
43
|
+
executables:
|
44
|
+
- zion_data
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".rubocop.yml"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- bin/zion_data
|
53
|
+
- lib/zion_data.rb
|
54
|
+
- lib/zion_data/client.rb
|
55
|
+
- lib/zion_data/parser.rb
|
56
|
+
- lib/zion_data/parser/helpers.rb
|
57
|
+
- lib/zion_data/parser/loopholes.rb
|
58
|
+
- lib/zion_data/parser/sentinels.rb
|
59
|
+
- lib/zion_data/parser/sniffers.rb
|
60
|
+
- lib/zion_data/version.rb
|
61
|
+
- main.rb
|
62
|
+
- spec/lib/zion_data/parser/loopholes_spec.rb
|
63
|
+
- spec/lib/zion_data/parser/sentinels_spec.rb
|
64
|
+
- spec/lib/zion_data/parser/sniffers_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- zion_data.gemspec
|
67
|
+
homepage: http://rubygems.org/gems/zion_data
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.5.1
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Zion data manager
|
91
|
+
test_files:
|
92
|
+
- spec/lib/zion_data/parser/loopholes_spec.rb
|
93
|
+
- spec/lib/zion_data/parser/sentinels_spec.rb
|
94
|
+
- spec/lib/zion_data/parser/sniffers_spec.rb
|
95
|
+
- spec/spec_helper.rb
|