dratools 0.0.5 → 0.0.7
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/docs/environment.md +2 -0
- data/docs/usage.md +1 -1
- data/lib/dratools/command_line_interface.rb +4 -3
- data/lib/dratools/commands/base_command.rb +2 -2
- data/lib/dratools/commands/get_command.rb +1 -1
- data/lib/dratools/external_command_runner.rb +30 -2
- data/lib/dratools/message_format.rb +10 -0
- data/lib/dratools/version.rb +1 -1
- data/lib/dratools.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6155f21e4f394c155ef82c844cfc74fbeb0b437f1c0a31fa0d24947df4d5757f
|
|
4
|
+
data.tar.gz: 9e20ec3dbe6d7e33e93d3a3f1f45b8d267829d4b83f99d57b14a161d8fd81012
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3d9c448ee4258317bdbf4c513bb3efdcb3aae132ca1676a23038ff31389288e4107b188ee861e00df367806b1d76d421b434677ba3fc86511347d74ed93cf7c
|
|
7
|
+
data.tar.gz: 2497ee2dbc090c9049e8958366b75e92891a261e0fddad8c4d55fd9d168da50ccb2f1d60b14bf0b7d7dfbdb92bba2584f47e999e7ec95077fe0e2036db5d2a90
|
data/docs/environment.md
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
|
|
29
29
|
`DRATOOLS_DOWNLOAD_COMMAND` を指定しない場合は、`curl`, `wget` の順で PATH にあるものを使います。`aria2c` は自動探索しません。`aria2c` を使う場合は `DRATOOLS_DOWNLOAD_COMMAND=aria2c` を指定してください。指定した場合はそのコマンドだけを使います。見つからない場合は、別のコマンドへ自動では切り替えません。
|
|
30
30
|
|
|
31
|
+
Windows では `PATHEXT` を使って実行ファイル拡張子を解決します。たとえば `curl.exe`, `wget.cmd` のような名前でも自動探索の対象になります。
|
|
32
|
+
|
|
31
33
|
`DRATOOLS_DOWNLOAD_RETRY_COUNT` は、初回の試行を含まない「リトライ回数」です。`curl` にはそのまま渡します。`wget` と `aria2c` は総試行回数を受け取るため、内部で `リトライ回数 + 1` に変換します。
|
|
32
34
|
|
|
33
35
|
## 例
|
data/docs/usage.md
CHANGED
|
@@ -190,7 +190,7 @@ direct run を多数持つ親 accession では、`tree` は各 run を個別取
|
|
|
190
190
|
dratools get -O ~/Downloads DRR000001
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
ダウンロード開始時は `[dratools] Downloading<TAB>PATH` と表示し、その後に `curl`, `wget`, `aria2c` のいずれかの進捗が標準エラーに出ます。取得したファイルは `[dratools] Downloaded<TAB>PATH` と表示します。既存ファイルを再利用した場合は `[dratools] Skipped<TAB>PATH` と表示します。これらは標準エラーに出ます。最後に `[dratools]
|
|
193
|
+
ダウンロード開始時は `[dratools] Downloading<TAB>PATH` と表示し、その後に `curl`, `wget`, `aria2c` のいずれかの進捗が標準エラーに出ます。取得したファイルは `[dratools] Downloaded<TAB>PATH` と表示します。既存ファイルを再利用した場合は `[dratools] Skipped<TAB>PATH` と表示します。これらは標準エラーに出ます。最後に `[dratools] get: N downloaded, M skipped` のサマリを出します。状態とパスは TAB 区切りです。パスだけを取り出すには `cut -f2` を使います。
|
|
194
194
|
|
|
195
195
|
### 既存ファイルの扱い
|
|
196
196
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'version'
|
|
4
|
+
require_relative 'message_format'
|
|
4
5
|
require_relative 'accession_resolver'
|
|
5
6
|
require_relative 'ddbj_resource_client'
|
|
6
7
|
require_relative 'download_service'
|
|
@@ -43,11 +44,11 @@ module Dratools
|
|
|
43
44
|
VERSION_FLAGS = ['-v', '--version', 'version'].freeze
|
|
44
45
|
|
|
45
46
|
SUBCOMMAND_SUMMARIES = {
|
|
46
|
-
'url' => 'ダウンロード URL を表示する
|
|
47
|
+
'url' => 'ダウンロード URL を表示する',
|
|
47
48
|
'get' => 'ファイルをダウンロードする',
|
|
48
49
|
'probe' => '短時間の接続確認だけ行う',
|
|
49
50
|
'tree' => '探索ツリーを表示する',
|
|
50
|
-
'meta' => 'レコードのメタ情報を表示する
|
|
51
|
+
'meta' => 'レコードのメタ情報を表示する',
|
|
51
52
|
'runs' => 'run accession の一覧を出力する',
|
|
52
53
|
'size' => 'ダウンロード合計サイズを集計する'
|
|
53
54
|
}.freeze
|
|
@@ -106,7 +107,7 @@ module Dratools
|
|
|
106
107
|
command_class = SUBCOMMANDS[name] || SUBCOMMANDS[SUBCOMMAND_ALIASES[name]]
|
|
107
108
|
unless command_class
|
|
108
109
|
expected = SUBCOMMANDS.keys.join(', ')
|
|
109
|
-
@stderr.puts "
|
|
110
|
+
@stderr.puts Dratools.message("unknown command '#{name}' (expected: #{expected})")
|
|
110
111
|
return FAILURE_EXIT_STATUS
|
|
111
112
|
end
|
|
112
113
|
|
|
@@ -180,11 +180,11 @@ module Dratools
|
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
def dratools_message(message)
|
|
183
|
-
|
|
183
|
+
Dratools.message(message)
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
def report_error(message, accession: nil)
|
|
187
|
-
prefix =
|
|
187
|
+
prefix = command_name
|
|
188
188
|
prefix = "#{prefix}: #{accession}" if accession
|
|
189
189
|
@stderr.puts dratools_message("#{prefix}: #{message}")
|
|
190
190
|
end
|
|
@@ -60,7 +60,7 @@ module Dratools
|
|
|
60
60
|
def finalize
|
|
61
61
|
parts = ["#{@downloaded_count.to_i} downloaded", "#{@skipped_count.to_i} skipped"]
|
|
62
62
|
parts << "#{@failed_count} failed" if @failed_count.positive?
|
|
63
|
-
@stderr.puts dratools_message("#{
|
|
63
|
+
@stderr.puts dratools_message("#{command_name}: #{parts.join(', ')}")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def save_one_download(accession, download)
|
|
@@ -172,9 +172,37 @@ module Dratools
|
|
|
172
172
|
|
|
173
173
|
def executable_command?(command_name)
|
|
174
174
|
ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).any? do |directory|
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
command_candidates_for(command_name).any? do |candidate|
|
|
176
|
+
command_path = File.join(directory, candidate)
|
|
177
|
+
executable_file?(command_path)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def executable_file?(command_path)
|
|
183
|
+
return File.file?(command_path) if windows_platform?
|
|
184
|
+
|
|
185
|
+
File.file?(command_path) && File.executable?(command_path)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def command_candidates_for(command_name)
|
|
189
|
+
return [command_name] unless windows_platform?
|
|
190
|
+
return [command_name] unless File.extname(command_name).empty?
|
|
191
|
+
|
|
192
|
+
windows_executable_extensions.map { |extension| "#{command_name}#{extension}" }.uniq
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def windows_executable_extensions
|
|
196
|
+
pathext = ENV.fetch('PATHEXT', '')
|
|
197
|
+
extensions = pathext.split(';').map(&:strip).reject(&:empty?).map do |extension|
|
|
198
|
+
extension.start_with?('.') ? extension : ".#{extension}"
|
|
177
199
|
end
|
|
200
|
+
extensions = %w[.com .exe .bat .cmd] if extensions.empty?
|
|
201
|
+
extensions.map(&:downcase)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def windows_platform?
|
|
205
|
+
File::ALT_SEPARATOR == '\\'
|
|
178
206
|
end
|
|
179
207
|
|
|
180
208
|
def command_not_found_message
|
data/lib/dratools/version.rb
CHANGED
data/lib/dratools.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dratools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kojix2
|
|
@@ -47,6 +47,7 @@ files:
|
|
|
47
47
|
- lib/dratools/download_service.rb
|
|
48
48
|
- lib/dratools/errors.rb
|
|
49
49
|
- lib/dratools/external_command_runner.rb
|
|
50
|
+
- lib/dratools/message_format.rb
|
|
50
51
|
- lib/dratools/progress_reporter.rb
|
|
51
52
|
- lib/dratools/run_record_collector.rb
|
|
52
53
|
- lib/dratools/traversal_node.rb
|
|
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
72
|
- !ruby/object:Gem::Version
|
|
72
73
|
version: '0'
|
|
73
74
|
requirements: []
|
|
74
|
-
rubygems_version: 4.0.
|
|
75
|
+
rubygems_version: 4.0.3
|
|
75
76
|
specification_version: 4
|
|
76
77
|
summary: DDBJ DRA toolkit
|
|
77
78
|
test_files: []
|