mind_control 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae35290f4f7d0100c3ca8bf7df326d629c9a928a
4
- data.tar.gz: 153d9050ab124979dceccfc64f059f5abc492473
3
+ metadata.gz: 696fd9a85294fbb472b51831c64e131ab2621f64
4
+ data.tar.gz: 71b19e9b4161993cef4dbe9961ff5cf847ce2c7b
5
5
  SHA512:
6
- metadata.gz: 987c0e69ef53d7a4362142fdbf52875d871254c7732831b41fa88f77fd95438b3acc8cae598c52d3012a4c44022a316b9e8f7e1f84503558f00fe044def62ce5
7
- data.tar.gz: e54ab48fb9883a0b2c149f9ff0dbf77cfb3c9f5e44acb4750e80d430fe76a0748f10403327bab4895ff2ea80109ad2245c302192d7ae4db419e16de3a1c83c11
6
+ metadata.gz: bec3f47e955feeedf129024eb9f6024e3f6d070c92d989cf8514ccc299fcb1ea04cd5601fab483d49273c5f9a6449c97a2fd33cbf9c8acef9073134a2b030344
7
+ data.tar.gz: 0db81ab0f37875f0be3bcd3a186eea69d6a077a76bdbc32961ce2bb4a3408d5544c3fd502c40f0442fd9015c6e5ba7a15f9be7fd3e084ac0ccc5df3743b0629b
data/bin/mind_control CHANGED
@@ -29,22 +29,28 @@ unless running_processes.any?
29
29
  exit
30
30
  end
31
31
 
32
- process =
32
+ filtered_processes =
33
33
  # If filter given
34
34
  if filter = ARGV[ 0 ]
35
- # Filter processes by substring in name or pid equality
36
- filtered_processes = running_processes.select! { |p| p.name.include?( filter ) || p.pid.to_s == filter.to_i }
37
-
38
- # If filter matches 1 process -- connect to it, otherwise ask user to select process from filtered list
39
- filtered_processes.size == 1 ? filtered_processes[ 0 ] : cui.select_process( filtered_processes )
35
+ # Filter processes by name substring and pid equality
36
+ running_processes.select { |p| p.name.include?( filter ) || p.pid.to_i == filter.to_i }
40
37
  else
41
- # Ask user to select process
42
- cui.select_process( running_processes )
38
+ []
39
+ end
40
+
41
+ # If filter matches 1 process -- connect to it,
42
+ # if filter matches > 1 processes -- ask user to select process from filtered processes,
43
+ # if filter matches no processes -- ask user to select process from all running processes.
44
+ selected_process =
45
+ case filtered_processes.size
46
+ when 1 then filtered_processes[ 0 ]
47
+ when 0 then cui.select_process( running_processes )
48
+ else cui.select_process( filtered_processes )
43
49
  end
44
50
 
45
51
  begin
46
- cui.show_debug "Connecting to #{process.name} via #{process.socket} ..."
47
- MindControl::Client.connect( process )
52
+ cui.show_debug "Connecting to #{selected_process.name} via #{selected_process.socket} ..."
53
+ MindControl::Client.connect( selected_process )
48
54
  rescue Exception => e
49
55
  cui.show_error e.message
50
56
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module MindControl
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mind_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Diachkov