railjet 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +8 -2
- data/.semaphore/setup_codeclimate_test_coverage.sh +11 -0
- data/README.md +5 -2
- data/VERSION +1 -1
- data/lib/railjet.rb +8 -0
- data/lib/railjet/console/debug_helpers.rb +143 -0
- data/lib/railjet/version.rb +1 -1
- data/railjet.gemspec +1 -1
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dabef786fc068425030ba7491d155b468603cad7e60b87cba1279947675193bb
|
4
|
+
data.tar.gz: e3bec2083b8df544538483cd4c31bb7450926075f9b214f70bf9797be52693d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c86ac300b35515fa2474f2f0da707ee42df17b98b586dcd74dd926c2459a3e2e6bf2d56412a88427bc82fcab0b60dde9cc190607e769ee771dffe825a71e1a3c
|
7
|
+
data.tar.gz: 74dd2b89e62fc17ae6ae1f54358cea04156cbe446bbdec1bf738b04d6125f5394975b41204498ea55bd1aae7b3b8e2cfdd3143c7db6c47780b1483b60a0f02da
|
data/.semaphore/semaphore.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
version: v1.0
|
2
|
-
name:
|
2
|
+
name: Railjet Pipeline
|
3
3
|
agent:
|
4
4
|
machine:
|
5
5
|
type: e1-standard-2
|
@@ -8,8 +8,11 @@ auto_cancel:
|
|
8
8
|
running:
|
9
9
|
when: "branch != 'master'"
|
10
10
|
blocks:
|
11
|
-
- name: '
|
11
|
+
- name: 'Rspec'
|
12
12
|
task:
|
13
|
+
env_vars:
|
14
|
+
- name: CC_TEST_REPORTER_ID
|
15
|
+
value: 9cfd93bf8178ecfe837889113add5d001b2110503d238294a56ac7dcb3286852
|
13
16
|
jobs:
|
14
17
|
- name: specs
|
15
18
|
matrix:
|
@@ -18,7 +21,10 @@ blocks:
|
|
18
21
|
commands:
|
19
22
|
- sem-version ruby $RUBY_VERSION
|
20
23
|
- bundle install --path vendor/bundle
|
24
|
+
- source ./.semaphore/setup_codeclimate_test_coverage.sh
|
21
25
|
- bundle exec rake spec
|
26
|
+
- ./cc-test-reporter format-coverage
|
27
|
+
- ./cc-test-reporter upload-coverage
|
22
28
|
prologue:
|
23
29
|
commands:
|
24
30
|
- checkout
|
@@ -0,0 +1,11 @@
|
|
1
|
+
cache restore cc-test-reporter-$(date +%F)
|
2
|
+
|
3
|
+
if [ -f 'cc-test-reporter' ]; then
|
4
|
+
echo 'found test reporter in cache'
|
5
|
+
else
|
6
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
7
|
+
chmod +x ./cc-test-reporter
|
8
|
+
cache store cc-test-reporter-$(date +%F) cc-test-reporter
|
9
|
+
fi
|
10
|
+
|
11
|
+
./cc-test-reporter before-build
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
# Railjet, architecture for high-speed railway
|
1
|
+
# Railjet, architecture for high-speed railway
|
2
2
|
|
3
|
+
[![Build Status](https://nedap-opensource.semaphoreci.com/badges/railjet/branches/master.svg?style=shields)](https://semaphoreci.com/nedap/railjet)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/457bb41a82546fd6e459/maintainability)](https://codeclimate.com/github/nedap/railjet/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/457bb41a82546fd6e459/test_coverage)](https://codeclimate.com/github/nedap/railjet/test_coverage)
|
3
6
|
|
4
7
|
![Railjet](https://www.swisspasses.com/railpass/popup/railjet/slideshow/RailJet-Zuerich-St.-Anton-Transfer-Ticket-from-Swisspasses.com.jpg)
|
5
8
|
|
@@ -251,7 +254,7 @@ end
|
|
251
254
|
|
252
255
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
253
256
|
|
254
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run rake task to bump the version `rake version:bump:<major,minor,patch>` and then run `rake release` to release it to
|
257
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run rake task to bump the version `rake version:bump:<major,minor,patch>` and then run `rake release` to release it to https://rubygems.org/
|
255
258
|
|
256
259
|
## Contributing
|
257
260
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/lib/railjet.rb
CHANGED
@@ -50,3 +50,11 @@ require "railjet/repository/registry"
|
|
50
50
|
require "railjet/repository"
|
51
51
|
require "railjet/repository/active_record"
|
52
52
|
require "railjet/repository/redis"
|
53
|
+
|
54
|
+
if defined?(Rails)
|
55
|
+
Rails::Application.console do
|
56
|
+
require "railjet/console/debug_helpers"
|
57
|
+
|
58
|
+
Railjet::Console::RailjetHelpers.load
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Railjet
|
4
|
+
module Console
|
5
|
+
# Adds helper methods for auditing of console customer usage
|
6
|
+
module RailjetHelpers
|
7
|
+
def setup_railjet(context_class: nil)
|
8
|
+
@context_class = context_class
|
9
|
+
|
10
|
+
@context_class ||= RailjetContextHelper.determine_context_class
|
11
|
+
|
12
|
+
railjet_helper_after_init_message
|
13
|
+
end
|
14
|
+
|
15
|
+
def railjet_helper_after_init_message
|
16
|
+
puts 'Setup finished. railjet helpers are now available from console'
|
17
|
+
puts 'available commands:'
|
18
|
+
puts "\t- use_case(<Class>)"
|
19
|
+
puts "\t- form(<Class>, params)"
|
20
|
+
puts "\t- console_context"
|
21
|
+
end
|
22
|
+
|
23
|
+
def railjet_helper_after_load_message
|
24
|
+
puts '*' * 61
|
25
|
+
puts "\nCall 'setup_railjet' to setup and debug Railjet"
|
26
|
+
puts 'Argument are:'
|
27
|
+
method(:setup_railjet).parameters.each do |param|
|
28
|
+
case param[0]
|
29
|
+
when :key, :keyreq
|
30
|
+
puts "\t- #{param[1]}:"
|
31
|
+
else
|
32
|
+
puts "\t- #{param[1]}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
puts "\n"
|
36
|
+
puts '*' * 61
|
37
|
+
end
|
38
|
+
|
39
|
+
def console_context
|
40
|
+
@context_class.init(
|
41
|
+
*context_params
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def use_case(klass)
|
46
|
+
klass.new(console_context)
|
47
|
+
end
|
48
|
+
|
49
|
+
def form(klass, clean_params)
|
50
|
+
klass.new(clean_params).tap(&:validate)
|
51
|
+
end
|
52
|
+
|
53
|
+
def context_params
|
54
|
+
parameters, missing_methods = find_context_params
|
55
|
+
|
56
|
+
RailjetContextHelper.print_context_param_errors(missing_methods)
|
57
|
+
|
58
|
+
parameters
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_context_params
|
62
|
+
parameters = []
|
63
|
+
missing_methods = []
|
64
|
+
|
65
|
+
@context_class.method(:init).parameters.each do |param|
|
66
|
+
param_value, missing_method_error = find_context_param(
|
67
|
+
param[0], param[1]
|
68
|
+
)
|
69
|
+
|
70
|
+
parameters.push(param_value)
|
71
|
+
|
72
|
+
if missing_method_error.present?
|
73
|
+
missing_methods.push(missing_method_error)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
[parameters, missing_methods]
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_context_param(type, method_name)
|
81
|
+
send("find_#{type}_context_param", method_name)
|
82
|
+
end
|
83
|
+
|
84
|
+
def find_req_context_param(method_name)
|
85
|
+
[send(method_name), nil]
|
86
|
+
rescue StandardError => e
|
87
|
+
[nil, { method_name => e.message }]
|
88
|
+
end
|
89
|
+
alias find_opt_context_param find_req_context_param
|
90
|
+
|
91
|
+
def find_keyreq_context_param(method_name)
|
92
|
+
[{ method_name => send(method_name) }, nil]
|
93
|
+
rescue StandardError => e
|
94
|
+
[{ method_name => nil }, { method_name => e.message }]
|
95
|
+
end
|
96
|
+
alias find_key_context_param find_keyreq_context_param
|
97
|
+
|
98
|
+
def self.load
|
99
|
+
Object.include(self)
|
100
|
+
end
|
101
|
+
|
102
|
+
class RailjetContextHelper
|
103
|
+
def self.determine_context_class
|
104
|
+
contexts_classes = Railjet::Context.descendants
|
105
|
+
contexts_classes.each_with_index do |context_class, index|
|
106
|
+
puts "(#{index + 1}) #{context_class}"
|
107
|
+
end
|
108
|
+
|
109
|
+
puts "\nPlease enter the number of needed railjet context"
|
110
|
+
puts "(default: #{contexts_classes.first})"
|
111
|
+
puts '-' * 61
|
112
|
+
|
113
|
+
begin
|
114
|
+
input = $stdin.gets.strip
|
115
|
+
if input.present?
|
116
|
+
chosen_index = Float(input)
|
117
|
+
contexts_classes.fetch(chosen_index - 1)
|
118
|
+
else
|
119
|
+
contexts_classes[0]
|
120
|
+
end
|
121
|
+
rescue StandardError
|
122
|
+
puts 'Invalid choice. Please try again.'
|
123
|
+
retry
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.print_context_param_errors(missing_methods)
|
128
|
+
return if missing_methods.empty?
|
129
|
+
|
130
|
+
puts '!' * 61
|
131
|
+
puts "\nError raised while finding context value(s) for methods below using `nil` instead"
|
132
|
+
puts "To assign value simply define function(s) in console and it will be used the next time\n\n"
|
133
|
+
missing_methods.each do |error|
|
134
|
+
puts "\t- Method `#{error.keys.first}` => error: `#{error.values.first}`"
|
135
|
+
end
|
136
|
+
puts "\n"
|
137
|
+
puts '!' * 61
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
data/lib/railjet/version.rb
CHANGED
data/railjet.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake", "> 13"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency "pry"
|
26
|
-
spec.add_development_dependency "gemfury"
|
27
26
|
spec.add_development_dependency "rake-version", "~> 1.0"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0.17.1"
|
28
28
|
|
29
29
|
spec.add_dependency "activesupport", '> 4'
|
30
30
|
spec.add_dependency "activemodel", '> 4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railjet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Zalewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,33 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake-version
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.17.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.17.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activesupport
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- ".ruby-gemset"
|
163
163
|
- ".ruby-version"
|
164
164
|
- ".semaphore/semaphore.yml"
|
165
|
+
- ".semaphore/setup_codeclimate_test_coverage.sh"
|
165
166
|
- Gemfile
|
166
167
|
- LICENSE.txt
|
167
168
|
- README.md
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- lib/railjet/auth/ability.rb
|
182
183
|
- lib/railjet/auth/activity.rb
|
183
184
|
- lib/railjet/composed_policy.rb
|
185
|
+
- lib/railjet/console/debug_helpers.rb
|
184
186
|
- lib/railjet/context.rb
|
185
187
|
- lib/railjet/form.rb
|
186
188
|
- lib/railjet/policy.rb
|