ro_thor 4.5.7 → 4.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f2c130067f45ad0815676db4152f971063e03487b82ef35d6824a7146a04425
4
- data.tar.gz: d939307abbefe9260132cb92d160568e0a0ebfd594d9c7d211d8a6d6c2a7136f
3
+ metadata.gz: 739ec510fe387cab1f522aa6ce897000ecd62f189b29b1ca947dc94a88664a06
4
+ data.tar.gz: dde5ecc67ee15a9c6d8f44719149bf53c9880b86920a8d6dec35efb880ed3ca0
5
5
  SHA512:
6
- metadata.gz: cf49e3f59b18ae2cff4cda9093c4b49f63ec69f9febcc98b1b138c88c25758093b7494ec2d7cbd0b8e4ef647b1d3311a10b88645043a06fa3deff181f4ec25cd
7
- data.tar.gz: 020ef1946c6d6b40cdbb26aa497bbd1f2c99409f7b76b83713c5ea1253050de1655b2ac56257eb52f5515d4f040aac838221bf3eb2976c528ca6f37667dde707
6
+ metadata.gz: 31c7c4e83600a3a05864fdc8ade5419b0f79323f82fdeebf1da22f6c5e0eee67099b7d89867837421a11dbbb268060eb20f4ce98a4b6416c2bfe1fee14bc46e5
7
+ data.tar.gz: 4642ce36d68307d9441dfc9ba4edc317aa86226985d289439b589ee3468dd17a0473ff8c702741c27c61c574ca0d02b502e17c9e6912923d39a3df6bb4015c39
@@ -1,11 +1,13 @@
1
1
  require 'pathname'
2
2
  $LOAD_PATH.unshift(Pathname.new(__FILE__).parent.to_s)
3
+ require 'shellwords'
3
4
  require 'thor'
4
5
  require 'open3'
5
6
  require 'ro_thor/base'
6
7
  require 'ro_thor/sh'
7
8
  require 'ro_thor/ro_file'
8
9
  require 'ro_thor/array'
10
+ require 'ro_thor/string'
9
11
  require 'ro_thor/helper'
10
12
  require 'ro_thor/ro_err'
11
13
  require 'ro_thor/http'
@@ -38,6 +40,14 @@ class RoThor < Thor
38
40
  desc(str, "")
39
41
  end
40
42
 
43
+ def st(*args)
44
+ start(*args)
45
+ end
46
+
47
+ def start(*args)
48
+ super(args)
49
+ end
50
+
41
51
  def create_command(*args, &blk)
42
52
  if @usage.nil?
43
53
  return
@@ -45,16 +55,12 @@ class RoThor < Thor
45
55
  super
46
56
  end
47
57
 
48
- def st(*args, &blk)
49
- start(args)
50
- end
51
-
52
58
  def lamb(*args, &blk)
53
59
  lambda(*args, &blk)
54
60
  end
55
61
  end
56
62
 
57
- def open_url(url, user_data_dir=nil, *args, &blk)
63
+ def open_url(url, user_data_dir = nil, *args, &blk)
58
64
  user_data_dir ||= "#{ENV['HOME']}/.config/google-chrome"
59
65
  sys %Q(google-chrome --user-data-dir=#{user_data_dir.strip} "#{url}")
60
66
  end
@@ -63,6 +69,10 @@ class RoThor < Thor
63
69
  RoFile.basename(Dir.pwd)
64
70
  end
65
71
 
72
+ def sh_esc(str)
73
+ Shellwords.escape(str)
74
+ end
75
+
66
76
  def cur_pj_name2(*args, &blk)
67
77
  cur_pj_name.gsub(%r{^ro_}, "")
68
78
  end
@@ -76,7 +86,6 @@ class RoThor < Thor
76
86
  end
77
87
 
78
88
 
79
-
80
89
  def down_d(*args, &blk)
81
90
  RoFile.join("/media/roroco/disk750/Downloads", *args, &blk)
82
91
  end
@@ -136,17 +145,16 @@ class RoThor < Thor
136
145
 
137
146
  def toggle_win(win_name)
138
147
  wins = begin
139
- shsu("xdotool search --onlyvisible #{win_name}").split("\n")
140
- rescue RoThor::Sh::Err => e
141
- out(e)
142
- out(e.backtrace.join("\n"))
143
- sleep(0.5)
144
- retry
145
- end
148
+ shsu("xdotool search --onlyvisible #{win_name}").split("\n")
149
+ rescue RoThor::Sh::Err => e
150
+ out(e)
151
+ out(e.backtrace.join("\n"))
152
+ sleep(0.5)
153
+ retry
154
+ end
146
155
  if wins.size > 0
147
156
  sh "xdotool windowactivate #{wins.first.strip}"
148
157
  end
149
158
  end
150
-
151
159
  end
152
160
 
@@ -1,6 +1,7 @@
1
1
  require_relative 'base'
2
2
  class Array
3
3
  unless method_defined? :ro_opts
4
+ # @return [] return args_without_options, options
4
5
  def ro_opts(*args, &blk)
5
6
  a = []
6
7
  opts = {}
@@ -1,4 +1,5 @@
1
1
  require_relative 'base'
2
+ require_relative 'string'
2
3
 
3
4
  class RoThor
4
5
  module Helper
@@ -11,8 +12,8 @@ class RoThor
11
12
  shsu("xclip -sel clip -o")
12
13
  end
13
14
 
14
- def to_md5(s, *args, &blk)
15
- Digest::MD5.hexdigest(s)
15
+ def to_md5(str)
16
+ str.md5
16
17
  end
17
18
 
18
19
  def in_pj(pj_name, *args, &blk)
@@ -16,6 +16,11 @@ class RoThor
16
16
  end
17
17
  end
18
18
 
19
+ def head(url, *args, &blk)
20
+ out "head #{url}"
21
+ h.head(url, *args, &blk)
22
+ end
23
+
19
24
  def get(url, *args, &blk)
20
25
  out "get #{url}"
21
26
  h.get(url, *args, &blk)
@@ -13,6 +13,10 @@ class RoThor
13
13
  binwrite(to, binread(from))
14
14
  end
15
15
 
16
+ def ls(path)
17
+ Dir.glob("#{path}/*")
18
+ end
19
+
16
20
  def abs(p, *args, &blk)
17
21
  if p.match(%r{^~})
18
22
  p.gsub(%r{^~}, ENV["HOME"])
@@ -42,7 +46,9 @@ class RoThor
42
46
 
43
47
  def msp(f, *args, &blk)
44
48
  p = parent(f)
45
- FileUtils.mkpath(p)
49
+ if !test(?d, p)
50
+ FileUtils.mkpath(p)
51
+ end
46
52
  end
47
53
 
48
54
  def msd(p, *args, &blk)
@@ -0,0 +1,7 @@
1
+ class String
2
+ if !method_defined? :md5
3
+ def md5
4
+ Digest::MD5.hexdigest(self)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'rails_helper'
2
+
3
+ describe 'RoFile' do
4
+ it "ls" do
5
+ ps = RoThor::RoFile.ls(__dir__)
6
+ asr ps.size > 0
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails_helper'
2
+
3
+ class C < RoThor
4
+ usg :todo
5
+
6
+ def todo(*args)
7
+
8
+ end
9
+ end
10
+
11
+ describe 'RoThor' do
12
+ it "1" do
13
+ C.start(*['todo', 'arg1', "arg2"])
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ro_thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.7
4
+ version: 4.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2020-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -110,10 +110,13 @@ files:
110
110
  - lib/ro_thor/ro_file.rb
111
111
  - lib/ro_thor/sh.rb
112
112
  - lib/ro_thor/ssh.rb
113
+ - lib/ro_thor/string.rb
113
114
  - spec/lib/core_ext/array_spec.rb
114
115
  - spec/lib/ro_cmd/thor/dp_spec.rb
115
116
  - spec/lib/ro_thor/ro_err_spec.rb
117
+ - spec/lib/ro_thor/ro_file_spec.rb
116
118
  - spec/lib/ro_thor/ssh_spec.rb
119
+ - spec/lib/ro_thor_spec.rb
117
120
  - spec/mysql/my.cnf
118
121
  - spec/rails_helper.rb
119
122
  - spec/spec_helper.rb
@@ -140,10 +143,12 @@ signing_key:
140
143
  specification_version: 4
141
144
  summary: ''
142
145
  test_files:
143
- - spec/spec_helper.rb
146
+ - spec/lib/ro_thor_spec.rb
144
147
  - spec/lib/ro_cmd/thor/dp_spec.rb
145
- - spec/lib/core_ext/array_spec.rb
146
148
  - spec/lib/ro_thor/ssh_spec.rb
149
+ - spec/lib/ro_thor/ro_file_spec.rb
147
150
  - spec/lib/ro_thor/ro_err_spec.rb
151
+ - spec/lib/core_ext/array_spec.rb
148
152
  - spec/rails_helper.rb
153
+ - spec/spec_helper.rb
149
154
  - spec/mysql/my.cnf