procon_bypass_man 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +13 -0
- data/.github/workflows/gitleacks.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/bin/generate_default_app +10 -0
- data/docs/getting_started.md +46 -8
- data/lib/procon_bypass_man/background/jobs/base_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/concerns/{job_runnable.rb → job_performable.rb} +1 -1
- data/lib/procon_bypass_man/background.rb +1 -1
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +0 -4
- data/lib/procon_bypass_man/bypass.rb +4 -3
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +11 -0
- data/lib/procon_bypass_man/procon_display.rb +1 -0
- data/lib/procon_bypass_man/support/callbacks.rb +68 -34
- data/lib/procon_bypass_man/version.rb +1 -1
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/README.md +0 -5
- data/project_template/app.rb +14 -3
- data/project_template/app.rb.erb +64 -0
- data/project_template/lib/app_generator.rb +31 -0
- data/project_template/web.rb +1 -1
- data/tmp/.keep +0 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4d6700d287ed85a9361e1cf49cfa3a0eaaf64647556fa4eccdf8d7c20a49f5
|
4
|
+
data.tar.gz: b662feb50dce18c8777631f7164b0524c57cb782c5952fab8d558a6ae753543c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32bbbf4c03872be73e8bde95c4b42a03c300fb80d4b546e5b17abcc77e98cf9e46fcc4f7c196cc2652b240a520330f58594ed335b8b5fcc7f34c0a1b7e3d166
|
7
|
+
data.tar.gz: c9152a14f18c0ab48dbccb6b655723db3c23b1520087dc87f788ef06450286a7a6dc0d432a44f058bd49d6e2e5809d907a364d568ef4c402e6871815e5c94272
|
data/.circleci/config.yml
CHANGED
@@ -55,6 +55,14 @@ jobs:
|
|
55
55
|
- run: ruby -cw project_template/web.rb
|
56
56
|
- run: ruby -ryaml -e 'puts YAML.load_file("./project_template/setting.yml")["setting"]' > /tmp/content_of_setting.rb && ruby -cw /tmp/content_of_setting.rb
|
57
57
|
|
58
|
+
outdated_app_checker:
|
59
|
+
executor:
|
60
|
+
name: ruby
|
61
|
+
tag: 3.0.1
|
62
|
+
steps:
|
63
|
+
- checkout
|
64
|
+
- run: ruby bin/generate_default_app && git diff --exit-code project_template/app.rb
|
65
|
+
|
58
66
|
bundle_install:
|
59
67
|
parameters:
|
60
68
|
ruby-version:
|
@@ -101,10 +109,12 @@ jobs:
|
|
101
109
|
|
102
110
|
build_jobs: &build_jobs
|
103
111
|
- check_pbm_version
|
112
|
+
- outdated_app_checker
|
104
113
|
- syntax_check:
|
105
114
|
matrix:
|
106
115
|
parameters:
|
107
116
|
ruby-version:
|
117
|
+
- "2.5.5"
|
108
118
|
- "3.0.1"
|
109
119
|
- "3.0.2"
|
110
120
|
- "3.1.1"
|
@@ -112,6 +122,7 @@ build_jobs: &build_jobs
|
|
112
122
|
matrix:
|
113
123
|
parameters:
|
114
124
|
ruby-version:
|
125
|
+
- "2.5.5"
|
115
126
|
- "3.0.1"
|
116
127
|
- "3.0.2"
|
117
128
|
- "3.1.1"
|
@@ -119,6 +130,7 @@ build_jobs: &build_jobs
|
|
119
130
|
matrix:
|
120
131
|
parameters:
|
121
132
|
ruby-version:
|
133
|
+
- "2.5.5"
|
122
134
|
- "3.0.1"
|
123
135
|
- "3.0.2"
|
124
136
|
- "3.1.1"
|
@@ -137,6 +149,7 @@ build_jobs: &build_jobs
|
|
137
149
|
matrix:
|
138
150
|
parameters:
|
139
151
|
ruby-version:
|
152
|
+
- "2.5.5"
|
140
153
|
- "3.0.1"
|
141
154
|
- "3.0.2"
|
142
155
|
- "3.1.1"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.2.2] - 2022-07-10
|
2
|
+
* project_template/app.rbを動的に生成する仕組みを追加しました
|
3
|
+
* ドキュメントからpbm_webに関する記述を削除しました
|
4
|
+
* 起動スクリプト(app.rb) がたまに意図せず /usr/share/pbm/current を削除してしまう不具合を修正しました
|
5
|
+
|
1
6
|
## [0.2.1] - 2022-05-29
|
2
7
|
- 入力表示機能を提供するSwitchProconInputViewerに対応しました
|
3
8
|
- https://github.com/splaplapla/switch-procon-input-viewer
|
data/Gemfile
CHANGED
@@ -10,8 +10,11 @@ gem "rspec"
|
|
10
10
|
gem "pry"
|
11
11
|
gem "timecop"
|
12
12
|
gem "rubocop", require: false
|
13
|
-
gem "steep", require: false
|
14
|
-
gem 'typeprof', require: false
|
15
|
-
gem 'rbs', require: false
|
16
13
|
gem "sinatra", require: false
|
17
14
|
gem "webrick", require: false
|
15
|
+
|
16
|
+
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new("2.6.0")
|
17
|
+
gem 'typeprof', require: false
|
18
|
+
gem 'rbs', require: false
|
19
|
+
gem "steep", require: false
|
20
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.2.
|
4
|
+
procon_bypass_man (0.2.2)
|
5
5
|
action_cable_client
|
6
6
|
pbmenv (>= 0.1.9)
|
7
7
|
sorted_set
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
parallel (1.21.0)
|
37
37
|
parser (3.0.3.2)
|
38
38
|
ast (~> 2.4.1)
|
39
|
-
pbmenv (0.1.
|
39
|
+
pbmenv (0.1.10)
|
40
40
|
pry (0.14.1)
|
41
41
|
coderay (~> 1.1)
|
42
42
|
method_source (~> 1.0)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<img width="880" alt="スクリーンショット 2022-04-02 9 10 38" src="https://user-images.githubusercontent.com/1664497/161356057-71e4bc2a-0217-4434-9bf1-0002b9fb261a.png">
|
14
14
|
|
15
|
-
|
15
|
+
https://user-images.githubusercontent.com/1664497/171327108-f12f56a5-fc36-48da-95a5-65e976553a20.mov
|
16
16
|
|
17
17
|
<!--
|
18
18
|
![image](https://user-images.githubusercontent.com/1664497/123414210-942f6980-d5ee-11eb-8192-955bd9e37e0b.png)
|
@@ -33,7 +33,7 @@ Switch <-- (PBM): ZR連打
|
|
33
33
|
* データ通信が可能なUSBケーブル
|
34
34
|
|
35
35
|
## 使うソフトウェア
|
36
|
-
* ruby
|
36
|
+
* ruby 2.5 以上
|
37
37
|
|
38
38
|
## Usage
|
39
39
|
* USBガジェットモードで起動するRaspberry Pi4を用意する
|
data/docs/getting_started.md
CHANGED
@@ -41,7 +41,7 @@
|
|
41
41
|
* WEBから設定状態の閲覧・反映
|
42
42
|
* ボタンリマップ
|
43
43
|
* 入力表示
|
44
|
-
|
44
|
+
* https://github.com/splaplapla/switch-procon-input-viewer
|
45
45
|
|
46
46
|
## セットアップ
|
47
47
|
### ラズベリーパイのセットアップ
|
@@ -50,26 +50,64 @@
|
|
50
50
|
|
51
51
|
### procon_bypass_manのインストール
|
52
52
|
|
53
|
-
pbmenvを使うと https://pbm-cloud.herokuapp.com と連携ができるのでおすすめですが、pbmenvを使わなくてもprocon_bypass_manをインストールすることは可能です。
|
53
|
+
pbmenvを使うと https://pbm-cloud.herokuapp.com と連携ができるのでおすすめですが、pbmenvを使わなくてもprocon_bypass_manをインストールすることは可能です。
|
54
|
+
次の4つからインストール方法を1つ選んでください。
|
54
55
|
|
55
|
-
|
56
|
+
* pbmenvを使う方法
|
57
|
+
* systemにインストールされているrubyを使う場合(初心者におすすめ)
|
58
|
+
* rbenvでインストールしたrubyを使う場合
|
59
|
+
* pbmenvを使わない方法
|
60
|
+
* systemにインストールされているrubyを使う場合(初心者におすすめ)
|
61
|
+
* rbenvでインストールしたrubyを使う場合
|
62
|
+
|
63
|
+
#### 1) pbmenvを使う方法
|
56
64
|
|
57
65
|
https://github.com/splaplapla/pbmenv
|
58
|
-
pbmenvはprocon_bypass_manのバージョンマネジャーです。
|
66
|
+
pbmenvはprocon_bypass_manのバージョンマネジャーです。
|
67
|
+
procon_bypass_manはバージョンアップによって起動スクリプトに変更が入ることがあって、バージョンアップするときはpbmenvを使うとエラーが起きることなくインストールができるようになります。また、pbm-cloudと連携してすべての機能を使うには、pbmenvの利用が必須になります。
|
68
|
+
|
69
|
+
##### 1-1) systemにインストールされているrubyを使う場合(初心者におすすめ)
|
59
70
|
|
71
|
+
```bash
|
72
|
+
sudo apt-get install ruby ruby-dev
|
73
|
+
sudo gem i bundler pbmenv
|
74
|
+
sudo pbmenv install latest --use
|
75
|
+
cd /usr/share/pbm/current
|
76
|
+
sudo ruby app.rb
|
60
77
|
```
|
61
|
-
|
62
|
-
|
78
|
+
|
79
|
+
##### 1-2) rbenvでインストールしたrubyを使う場合
|
80
|
+
rbenvはrubyのパッケージマネージャーです。
|
81
|
+
|
82
|
+
```bash
|
83
|
+
rbenv install 3.0.1
|
84
|
+
sudo gem install pbmenv
|
85
|
+
sudo pbmenv install latest --use
|
63
86
|
cd /usr/share/pbm/current
|
64
87
|
sudo /home/pi/.rbenv/versions/3.0.1/bin/ruby app.rb
|
65
88
|
```
|
66
89
|
|
67
|
-
#### pbmenvを使わない方法
|
90
|
+
#### 2) pbmenvを使わない方法
|
91
|
+
https://github.com/jiikko/procon_bypass_man_sample にある app.rb と setting.yml を Raspberry Pi にダウンロードすれば、起動することができます。
|
68
92
|
|
69
|
-
|
93
|
+
##### 2-1) systemにインストールされているrubyを使う場合(初心者におすすめ)
|
70
94
|
|
95
|
+
```bash
|
96
|
+
sudo apt-get install ruby ruby-dev wget
|
97
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/app.rb
|
98
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/setting.yml
|
99
|
+
sudo gem i bundler
|
100
|
+
sudo ruby app.rb
|
71
101
|
```
|
102
|
+
|
103
|
+
##### 2-2) rbenvでインストールしたrubyを使う場合
|
104
|
+
rbenvはrubyのパッケージマネージャーです。
|
105
|
+
|
106
|
+
```bash
|
72
107
|
rbenv install 3.0.1
|
108
|
+
sudo apt-get install wget
|
109
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/app.rb
|
110
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/setting.yml
|
73
111
|
sudo /home/pi/.rbenv/versions/3.0.1/bin/ruby app.rb
|
74
112
|
```
|
75
113
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "procon_bypass_man/background/jobs/concerns/has_internal_api_setting"
|
2
2
|
require "procon_bypass_man/background/jobs/concerns/has_external_api_setting"
|
3
|
-
require "procon_bypass_man/background/jobs/concerns/
|
3
|
+
require "procon_bypass_man/background/jobs/concerns/job_performable"
|
4
4
|
require "procon_bypass_man/background/job_runner"
|
5
5
|
require "procon_bypass_man/background/job_performer"
|
6
6
|
require "procon_bypass_man/background/jobs/base_job"
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class ProconBypassMan::Bypass
|
2
2
|
module UsbHidLogger
|
3
|
-
extend ProconBypassMan::Callbacks::ClassMethods
|
4
3
|
include ProconBypassMan::Callbacks
|
5
4
|
|
6
5
|
define_callbacks :send_gadget_to_procon
|
@@ -32,9 +31,6 @@ class ProconBypassMan::Bypass
|
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
# TODO 別のコールバッククラスから実行したい
|
36
|
-
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash.dup
|
37
|
-
|
38
34
|
if ProconBypassMan.config.enable_reporting_pressed_buttons
|
39
35
|
ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
|
40
36
|
ProconBypassMan::ReportPressedButtonsJob.perform_async(
|
@@ -2,9 +2,10 @@ require "procon_bypass_man/bypass/usb_hid_logger"
|
|
2
2
|
require "procon_bypass_man/bypass/bypass_command"
|
3
3
|
|
4
4
|
class ProconBypassMan::Bypass
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
extend ProconBypassMan::CallbacksRegisterable
|
6
|
+
|
7
|
+
register_callback_module(ProconBypassMan::Bypass::UsbHidLogger)
|
8
|
+
register_callback_module(ProconBypassMan::ProconDisplay::BypassHook)
|
8
9
|
|
9
10
|
class BypassValue < Struct.new(:binary)
|
10
11
|
def to_text
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ProconBypassMan::ProconDisplay::BypassHook
|
2
|
+
include ProconBypassMan::Callbacks
|
3
|
+
|
4
|
+
define_callbacks :send_procon_to_gadget
|
5
|
+
|
6
|
+
set_callback :send_procon_to_gadget, :after, :write_procon_display_Status
|
7
|
+
|
8
|
+
def write_procon_display_Status
|
9
|
+
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash.dup
|
10
|
+
end
|
11
|
+
end
|
@@ -8,3 +8,4 @@ require "procon_bypass_man/procon_display/server_app"
|
|
8
8
|
require "procon_bypass_man/procon_display/status"
|
9
9
|
require "procon_bypass_man/procon_display/http_response"
|
10
10
|
require "procon_bypass_man/procon_display/http_request"
|
11
|
+
require "procon_bypass_man/procon_display/bypass_hook"
|
@@ -1,21 +1,15 @@
|
|
1
1
|
module ProconBypassMan
|
2
|
-
module
|
3
|
-
|
4
|
-
attr_accessor :filter, :chain_method
|
5
|
-
def initialize(filter: , chain_method: , block: )
|
6
|
-
@filter = filter
|
7
|
-
@chain_method = chain_method
|
8
|
-
@block = block
|
9
|
-
end
|
10
|
-
end
|
2
|
+
module CallbacksRegisterable
|
3
|
+
attr_accessor :callbacks
|
11
4
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
5
|
+
def register_callback_module(mod)
|
6
|
+
self.callbacks ||= []
|
7
|
+
callbacks << mod
|
8
|
+
self.include(mod)
|
17
9
|
end
|
10
|
+
end
|
18
11
|
|
12
|
+
module Callbacks
|
19
13
|
module ClassMethods
|
20
14
|
def define_callbacks(name)
|
21
15
|
self.singleton_class.attr_accessor "_#{name}_callbacks"
|
@@ -29,8 +23,9 @@ module ProconBypassMan
|
|
29
23
|
end
|
30
24
|
|
31
25
|
def set_callback(kind, filter, chain_method, &block)
|
32
|
-
|
33
|
-
|
26
|
+
self.__callbacks ||= {}
|
27
|
+
self.__callbacks[kind] ||= CallbackChain.new
|
28
|
+
self.__callbacks[kind].append Callback.new(
|
34
29
|
filter: filter,
|
35
30
|
chain_method: chain_method,
|
36
31
|
block: block,
|
@@ -38,33 +33,72 @@ module ProconBypassMan
|
|
38
33
|
end
|
39
34
|
end
|
40
35
|
|
36
|
+
def self.included(mod)
|
37
|
+
mod.singleton_class.attr_accessor :__callbacks
|
38
|
+
mod.extend(ClassMethods)
|
39
|
+
end
|
40
|
+
|
41
|
+
class CallbackChain
|
42
|
+
attr_accessor :callbacks
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
self.callbacks = {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def empty?
|
49
|
+
callbacks.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
def append(callback)
|
53
|
+
self.callbacks[callback.filter] ||= []
|
54
|
+
self.callbacks[callback.filter] << callback
|
55
|
+
end
|
56
|
+
|
57
|
+
def [](filter)
|
58
|
+
self.callbacks[filter]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Callback
|
63
|
+
attr_accessor :filter, :chain_method
|
64
|
+
|
65
|
+
def initialize(filter: , chain_method: , block: )
|
66
|
+
@filter = filter
|
67
|
+
@chain_method = chain_method
|
68
|
+
@block = block
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
41
72
|
# TODO haltしたらcallbackを止める
|
42
|
-
# TODO 複数をチェインできるようにする
|
43
73
|
def run_callbacks(kind, &block)
|
44
|
-
|
45
|
-
|
46
|
-
when :before
|
47
|
-
send chain.chain_method
|
48
|
-
block.call
|
49
|
-
when :after
|
74
|
+
chains = get_callbacks(kind) or raise("unknown callback")
|
75
|
+
if chains.nil? || chains.empty?
|
50
76
|
block.call
|
77
|
+
return
|
78
|
+
end
|
79
|
+
|
80
|
+
chains[:before]&.each do |chain|
|
81
|
+
send chain.chain_method
|
82
|
+
end
|
83
|
+
block.call
|
84
|
+
chains[:after]&.each do |chain|
|
51
85
|
send chain.chain_method
|
52
|
-
else
|
53
|
-
raise("unknown filter")
|
54
86
|
end
|
55
87
|
end
|
56
88
|
|
57
|
-
# def __run_callbacks__(name, &block)
|
58
|
-
# puts "called"
|
59
|
-
# end
|
60
|
-
|
61
89
|
def get_callbacks(kind) # :nodoc:
|
62
|
-
|
63
|
-
|
90
|
+
# classに直接moduleをincludeしている場合
|
91
|
+
if defined?(self.class.__callbacks)
|
92
|
+
return self.class.__callbacks[kind.to_sym]
|
93
|
+
end
|
64
94
|
|
65
|
-
|
66
|
-
|
67
|
-
|
95
|
+
list = self.class.callbacks.flat_map { |callback_mod|
|
96
|
+
callback_mod.__callbacks && callback_mod.__callbacks[kind.to_sym]
|
97
|
+
}.compact
|
98
|
+
table = {}
|
99
|
+
table[:before] = list.flat_map { |x| x[:before] }.compact
|
100
|
+
table[:after] = list.flat_map { |x| x[:after] }.compact
|
101
|
+
table
|
68
102
|
end
|
69
103
|
end
|
70
104
|
end
|
data/procon_bypass_man.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
data/project_template/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Project Template
|
2
2
|
* これらは https://github.com/splaplapla/pbmenv がinstallするときに配備するファイルです
|
3
|
-
* pbm_webはオプショナルです
|
4
3
|
|
5
4
|
## systemdを使ってサービスに登録する方法
|
6
5
|
systemctl enableした後は、次回のOS起動時にserviceも自動起動します
|
@@ -8,13 +7,9 @@ systemctl enableした後は、次回のOS起動時にserviceも自動起動し
|
|
8
7
|
* pbm
|
9
8
|
* sudo systemctl link /usr/share/pbm/current/systemd_units/pbm.service
|
10
9
|
* sudo systemctl enable pbm.service
|
11
|
-
* pbm_web
|
12
|
-
* sudo systemctl link /usr/share/pbm/current/systemd_units/pbm_web.service
|
13
|
-
* sudo systemctl enable pbm_web.service
|
14
10
|
|
15
11
|
## systemdを使ってサービスから解除する方法
|
16
12
|
* sudo systemctl disable pbm.service
|
17
|
-
* sudo systemctl disable pbm_web.service
|
18
13
|
|
19
14
|
### CheatSheet
|
20
15
|
* systemctl daemon-reload
|
data/project_template/app.rb
CHANGED
@@ -2,20 +2,31 @@
|
|
2
2
|
|
3
3
|
require 'bundler/inline'
|
4
4
|
|
5
|
+
retry_count_on_git_command_error = 0
|
5
6
|
begin
|
7
|
+
if retry_count_on_git_command_error > 10
|
8
|
+
STDOUT.puts "Stopped the procon_bypass_man program because could not download any source codes."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
6
12
|
gemfile do
|
7
13
|
source 'https://rubygems.org'
|
8
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
9
|
-
gem 'procon_bypass_man', '0.2.
|
15
|
+
gem 'procon_bypass_man', '0.2.2'
|
10
16
|
end
|
11
17
|
rescue Bundler::Source::Git::GitCommandError => e
|
18
|
+
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
19
|
+
sleep(5) # サービスの起動順によっては、まだoffline状態なので待機する
|
20
|
+
|
12
21
|
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
13
22
|
#"Git error: command `git fetch --force --quiet --tags https://github.com/splaplapla/procon_bypass_man refs/heads/\\*:refs/heads/\\*` in directory /home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af has failed.\n\nIf this error persists you could try removing the cache directory '/home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af'"
|
14
|
-
if /try removing the cache directory '([^']+)'/ =~ e.message
|
23
|
+
if /try removing the cache directory '([^']+)'/ =~ e.message && $1&.start_with?('/home/pi/.rbenv')
|
15
24
|
require 'fileutils'
|
16
25
|
FileUtils.rm_rf($1)
|
17
|
-
|
26
|
+
STDOUT.puts "Deleted #{$1}"
|
18
27
|
end
|
28
|
+
|
29
|
+
retry
|
19
30
|
end
|
20
31
|
|
21
32
|
ProconBypassMan.configure do |config|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
retry_count_on_git_command_error = 0
|
6
|
+
begin
|
7
|
+
if retry_count_on_git_command_error > 10
|
8
|
+
STDOUT.puts "Stopped the procon_bypass_man program because could not download any source codes."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
gemfile do
|
13
|
+
source 'https://rubygems.org'
|
14
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
15
|
+
gem 'procon_bypass_man', '0.2.2'
|
16
|
+
end
|
17
|
+
rescue Bundler::Source::Git::GitCommandError => e
|
18
|
+
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
19
|
+
sleep(5) # サービスの起動順によっては、まだoffline状態なので待機する
|
20
|
+
|
21
|
+
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
22
|
+
#"Git error: command `git fetch --force --quiet --tags https://github.com/splaplapla/procon_bypass_man refs/heads/\\*:refs/heads/\\*` in directory /home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af has failed.\n\nIf this error persists you could try removing the cache directory '/home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af'"
|
23
|
+
if /try removing the cache directory '([^']+)'/ =~ e.message && $1&.start_with?('/home/pi/.rbenv')
|
24
|
+
require 'fileutils'
|
25
|
+
FileUtils.rm_rf($1)
|
26
|
+
STDOUT.puts "Deleted #{$1}"
|
27
|
+
end
|
28
|
+
|
29
|
+
retry
|
30
|
+
end
|
31
|
+
|
32
|
+
ProconBypassMan.configure do |config|
|
33
|
+
config.root = File.expand_path(__dir__)
|
34
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 1, 1024 * 1024 * 1)
|
35
|
+
config.logger.level = :debug
|
36
|
+
|
37
|
+
# バイパスするログを全部app.logに流すか
|
38
|
+
config.verbose_bypass_log = false
|
39
|
+
|
40
|
+
# webからProconBypassManを操作できるwebサービス
|
41
|
+
<%- api_server_config = "config.api_servers = ['https://pbm-cloud.herokuapp.com']" -%>
|
42
|
+
<%- if enable_integration_with_pbm_cloud -%>
|
43
|
+
<%= api_server_config %>
|
44
|
+
<%- else -%>
|
45
|
+
<%= "# #{api_server_config}" %>
|
46
|
+
<%- end -%>
|
47
|
+
|
48
|
+
# エラーが起きたらerror.logに書き込みます
|
49
|
+
config.enable_critical_error_logging = true
|
50
|
+
|
51
|
+
# pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
|
52
|
+
config.never_exit_accidentally = true
|
53
|
+
|
54
|
+
# 毎秒行ったIOをログに出力するか
|
55
|
+
config.io_monitor_logging = false
|
56
|
+
|
57
|
+
# 接続に成功したらコントローラーのHOME LEDを光らせるか
|
58
|
+
config.enable_home_led_on_connect = true
|
59
|
+
|
60
|
+
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値を大きくしてください
|
61
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 10 }
|
62
|
+
end
|
63
|
+
|
64
|
+
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
# NOTE pbmenvで参照しているクラス
|
4
|
+
# 後方互換を維持するために、パラメータの削除・必須をしてはいけない
|
5
|
+
class AppGenerator
|
6
|
+
attr_reader :prefix_path
|
7
|
+
|
8
|
+
# @param [String] prefix_path
|
9
|
+
# @param [Boolean] enable_integration_with_pbm_cloud
|
10
|
+
def initialize(prefix_path: , enable_integration_with_pbm_cloud: )
|
11
|
+
@prefix_path = prefix_path
|
12
|
+
@enable_integration_with_pbm_cloud = enable_integration_with_pbm_cloud
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate
|
16
|
+
erb = File.read(template_path)
|
17
|
+
enable_integration_with_pbm_cloud = @enable_integration_with_pbm_cloud
|
18
|
+
app_rb = ERB.new(erb, nil, '-').result(binding)
|
19
|
+
File.write(output_path, app_rb)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def template_path
|
25
|
+
File.join(prefix_path, "app.rb.erb")
|
26
|
+
end
|
27
|
+
|
28
|
+
def output_path
|
29
|
+
File.join(prefix_path, "app.rb")
|
30
|
+
end
|
31
|
+
end
|
data/project_template/web.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
|
11
11
|
ProconBypassMan::Web.configure do |config|
|
12
12
|
config.root = File.expand_path(__dir__)
|
13
|
-
config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 *
|
13
|
+
config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 * 1)
|
14
14
|
end
|
15
15
|
|
16
16
|
ProconBypassMan::Web::Server.start
|
data/tmp/.keep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- Steepfile
|
77
77
|
- bin/console
|
78
78
|
- bin/dev_api_server.rb
|
79
|
+
- bin/generate_default_app
|
79
80
|
- bin/setup
|
80
81
|
- docs/getting_started.md
|
81
82
|
- docs/how_to_connect_procon.md
|
@@ -97,7 +98,7 @@ files:
|
|
97
98
|
- lib/procon_bypass_man/background/jobs/base_job.rb
|
98
99
|
- lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
|
99
100
|
- lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
|
100
|
-
- lib/procon_bypass_man/background/jobs/concerns/
|
101
|
+
- lib/procon_bypass_man/background/jobs/concerns/job_performable.rb
|
101
102
|
- lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
|
102
103
|
- lib/procon_bypass_man/background/jobs/report_boot_job.rb
|
103
104
|
- lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
|
186
187
|
- lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
|
187
188
|
- lib/procon_bypass_man/procon_display.rb
|
189
|
+
- lib/procon_bypass_man/procon_display/bypass_hook.rb
|
188
190
|
- lib/procon_bypass_man/procon_display/http_request.rb
|
189
191
|
- lib/procon_bypass_man/procon_display/http_response.rb
|
190
192
|
- lib/procon_bypass_man/procon_display/server.rb
|
@@ -235,6 +237,8 @@ files:
|
|
235
237
|
- procon_bypass_man.gemspec
|
236
238
|
- project_template/README.md
|
237
239
|
- project_template/app.rb
|
240
|
+
- project_template/app.rb.erb
|
241
|
+
- project_template/lib/app_generator.rb
|
238
242
|
- project_template/setting.yml
|
239
243
|
- project_template/systemd_units/pbm.service
|
240
244
|
- project_template/systemd_units/pbm_web.service
|
@@ -242,6 +246,7 @@ files:
|
|
242
246
|
- sig/README.md
|
243
247
|
- sig/main.rbs
|
244
248
|
- sig/on_memory_cache.rbs
|
249
|
+
- tmp/.keep
|
245
250
|
homepage: https://github.com/splaplapla/procon_bypass_man
|
246
251
|
licenses:
|
247
252
|
- MIT
|
@@ -257,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
257
262
|
requirements:
|
258
263
|
- - ">="
|
259
264
|
- !ruby/object:Gem::Version
|
260
|
-
version:
|
265
|
+
version: 2.5.0
|
261
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
267
|
requirements:
|
263
268
|
- - ">="
|