cli_application 0.1.5 → 0.1.6
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/lib/cli_application/argv.rb +4 -1
- data/lib/cli_application/mail_lib/sendmail.rb +6 -3
- data/lib/cli_application/version.rb +1 -1
- data/test/examples/1/stat/app.yml +19 -19
- data/test/examples/8/app.rb +30 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396b64a46663ed83492e82f9377ce57a4f1ff188
|
4
|
+
data.tar.gz: bfc59b4387917d419c521897af70bd822592275c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7449c7833ac02d037fc8033558851f48899b0d26d019333279d58bc6b7221d4cd4aa7f792942e782a6fdb258b226094a6ebc035bb1c1c581ca4cfa22b3a0a92
|
7
|
+
data.tar.gz: d0ecfcbfcddf3545f487a2772369575f46ec3835f22fe26687bc269a16afde87865e553849f1136d0316916e019b85397c182c168dcf9dc919364ecc37831011
|
data/lib/cli_application/argv.rb
CHANGED
@@ -16,7 +16,10 @@ module CliApplication
|
|
16
16
|
argv.each do |one|
|
17
17
|
if one.match(/[a-z\_0-9]\=/i)
|
18
18
|
pair = one.split('=')
|
19
|
-
|
19
|
+
# UPDATE 2015-10-26 - при указании пустого параметра при запуске скрипта
|
20
|
+
# он становился равным самому себе, поскольку split строки вида "param="
|
21
|
+
# возвращал pair.first равное pair.last
|
22
|
+
@params[pair.first.to_s.strip.downcase.to_sym] = pair.last if pair.count > 1
|
20
23
|
else
|
21
24
|
warn "WARNING: некорректный ключ параметра командной строки: #{one.inspect} (#{File.basename(__FILE__)} at #{__LINE__})"
|
22
25
|
end
|
@@ -59,19 +59,22 @@ module CliApplication
|
|
59
59
|
# Дополнительная информация по использованию sendmail:
|
60
60
|
# http://blog.antage.name/posts/sendmail-in-rails.html
|
61
61
|
|
62
|
+
filename = "/tmp/cli_application_mail_#{::Time.now.usec.to_s}.msg"
|
63
|
+
File.open(filename, 'w') { |file| file.write(message.to_s) }
|
64
|
+
|
62
65
|
cmdline = Array.new
|
63
|
-
cmdline << "echo \"#{'rrrrr' + message.to_s}\""
|
64
|
-
cmdline << '|'
|
65
66
|
cmdline << sendmail_location
|
66
67
|
cmdline << sendmail_arguments
|
68
|
+
cmdline << "< #{filename}"
|
67
69
|
cmdline << '2>&1'
|
68
70
|
cmdline = cmdline.join(' ')
|
69
71
|
|
70
72
|
output = `#{cmdline}`
|
71
73
|
res = $?.exitstatus
|
74
|
+
File.delete(filename)
|
72
75
|
|
73
76
|
if res != 0
|
74
|
-
raise "SendmailError_#{res}"
|
77
|
+
raise "SendmailError_#{res} (#{output.split(/\n/).first.strip})"
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
@@ -1,33 +1,33 @@
|
|
1
1
|
---
|
2
2
|
:name: app.rb
|
3
|
-
:shortdescription: "Пример
|
3
|
+
:shortdescription: "Пример 4 - Различные параметры командной строки"
|
4
4
|
:version: '1.0'
|
5
5
|
:releasedate: '2015-05-11'
|
6
6
|
:timezone: Moscow
|
7
|
-
:last_started_at: '2015-
|
7
|
+
:last_started_at: '2015-10-26 22:16:55 +0300'
|
8
8
|
:folders:
|
9
|
-
:app: "/Users/Stan/Documents/Development/RubyMine/cli_application/test/examples/
|
9
|
+
:app: "/Users/Stan/Documents/Development/RubyMine/cli_application/test/examples/8"
|
10
10
|
:class: "/Users/Stan/Documents/Development/RubyMine/cli_application/test/examples/1"
|
11
11
|
:stat: "/Users/Stan/Documents/Development/RubyMine/cli_application/test/examples/1/stat"
|
12
12
|
:avg:
|
13
|
-
:starts:
|
14
|
-
:executed_at: 4.
|
15
|
-
:executed_at_human: 4.
|
16
|
-
:memory:
|
13
|
+
:starts: 241
|
14
|
+
:executed_at: 4.43788
|
15
|
+
:executed_at_human: 4.43788 секунд
|
16
|
+
:memory: 35433
|
17
17
|
:last:
|
18
|
-
:started_at: '2015-
|
19
|
-
:executed_at: 0.
|
20
|
-
:executed_at_human: 0.
|
21
|
-
:memory:
|
22
|
-
:exitcode:
|
18
|
+
:started_at: '2015-10-26 22:16:55 +0300'
|
19
|
+
:executed_at: 0.029927
|
20
|
+
:executed_at_human: 0.029927 секунд
|
21
|
+
:memory: 36 кбайт
|
22
|
+
:exitcode: 0
|
23
23
|
:last10:
|
24
|
+
- 2015-10-26 22:16:55 +0300,0,0.029927,36 кбайт
|
25
|
+
- 2015-10-26 22:16:01 +0300,0,0.02892,36 кбайт
|
26
|
+
- 2015-10-26 22:10:40 +0300,0,0.033229,36 кбайт
|
27
|
+
- 2015-10-26 22:10:25 +0300,0,0.036708,36 кбайт
|
28
|
+
- 2015-10-26 22:08:56 +0300,0,0.036485,38 кбайт
|
29
|
+
- 2015-10-26 22:07:56 +0300,0,0.035323,36 кбайт
|
30
|
+
- 2015-10-26 22:04:20 +0300,255,0.053609,35 кбайт
|
24
31
|
- 2015-06-10 22:49:55 +0300,true,0.033085,37 кбайт
|
25
32
|
- 2015-06-09 23:56:11 +0300,255,0.033716,37 кбайт
|
26
33
|
- 2015-06-09 23:44:51 +0300,true,0.053136,36 кбайт
|
27
|
-
- 2015-06-09 23:37:45 +0300,true,0.06403,37 кбайт
|
28
|
-
- 2015-06-09 23:35:54 +0300,true,0.050132,37 кбайт
|
29
|
-
- 2015-06-09 23:35:40 +0300,true,0.047642,36 кбайт
|
30
|
-
- 2015-06-09 23:32:41 +0300,true,0.04385,37 кбайт
|
31
|
-
- 2015-06-09 23:31:44 +0300,true,0.060342,37 кбайт
|
32
|
-
- 2015-06-09 23:30:06 +0300,true,0.048131,36 кбайт
|
33
|
-
- 2015-06-09 23:29:48 +0300,true,0.044662,36 кбайт
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#encoding: utf-8
|
3
|
+
require '../1/cli_example.rb'
|
4
|
+
|
5
|
+
class TestApp < CliExample
|
6
|
+
|
7
|
+
def main
|
8
|
+
puts argv.inspect
|
9
|
+
|
10
|
+
puts
|
11
|
+
0
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
app = TestApp.new(ARGV, __dir__)
|
17
|
+
|
18
|
+
app.version = '1.0'
|
19
|
+
app.releasedate = '2015-05-11'
|
20
|
+
app.shortdescription = 'Пример 4 - Различные параметры командной строки'
|
21
|
+
app.description = "CliApplication gem демо. #{app.shortdescription}"
|
22
|
+
|
23
|
+
app.set_argv(:string, 'arg1', 'def', 'Пример пустой строки в качестве аргумента по умолчанию')
|
24
|
+
|
25
|
+
app.help
|
26
|
+
app.footer = "{status} ({exitcode}) - приложение завершено за {executed_at} секунд (занято в памяти {memory})"
|
27
|
+
|
28
|
+
app.run
|
29
|
+
exit(app.exitcode)
|
30
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli_application
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Zhuravlev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- test/examples/6/offer.rb
|
123
123
|
- test/examples/7/app.rb
|
124
124
|
- test/examples/7/mail/app-mail-2015-06-10.txt
|
125
|
+
- test/examples/8/app.rb
|
125
126
|
- test/stat/rdebug-ide
|
126
127
|
- test/stat/test_app.yml
|
127
128
|
- test/test_app.rb
|