appear 1.1.0 → 1.1.1

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: 2195b39f50d42701282eccd5bcca70318d9522d6
4
- data.tar.gz: c26570e72fae4f929d5c715510d64f671c2dc8ab
3
+ metadata.gz: 8d114dfa1bdcda18b13325f5d7961b296b09a8b2
4
+ data.tar.gz: 26fcebb685c8a0adcc5cac80c9bd1a7ce3153eef
5
5
  SHA512:
6
- metadata.gz: dd03024e868fdeb5a6d19da9d07e7c4387fab5002ebfd9b7a1ff884e4620750c6cbf67cd9273e7c18b208c63914e7b8c93efeccbae52b7552827de880fc4f5a3
7
- data.tar.gz: 0d4d9a852ed5477fd9cac3b537ec26740292b3c31220ccdc95248995c98ec5bb833921c00edf086da9bf1f668ed5fad6015f6d26279b23dcf4beb0db5da4cd3b
6
+ metadata.gz: 12f5f608f578ae6042e987fd20a5082d70c4b8067bfaebaf3e033fcacf66ede064bec3892d1174bf3be16a3168a91b80095ec798354d63f79e067609ab577eef
7
+ data.tar.gz: 848a59a97371e61417851e9fe8cdf33436d1e4e5ccf9a5d9ec9af0618c091d197babf493c48332ec0f5b975408acda7f0b02513582cf9b929334d74afb345a96
data/.doc-coverage CHANGED
@@ -1 +1 @@
1
- 73.05
1
+ 80.43
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1
4
+
5
+ - passing in a PID was broken.
6
+
3
7
  ## 1.1.0
4
8
 
5
9
  - You no longer have to pass a PID. If no PID is given, `appear` will default
@@ -4,8 +4,6 @@ require 'appear/instance'
4
4
  require 'optparse'
5
5
 
6
6
  module Appear
7
- class InvalidPidError < Error; end
8
-
9
7
  # Entrypoint and manager for the command-line `appear` tool.
10
8
  class Command
11
9
  def initialize
@@ -13,6 +11,9 @@ module Appear
13
11
  @config.silent = true
14
12
  end
15
13
 
14
+ # The ui for our command.
15
+ #
16
+ # @return [OptionParser]
16
17
  def option_parser
17
18
  @option_parser ||= OptionParser.new do |o|
18
19
  o.banner = 'Usage: appear [OPTION]... [PID]'
@@ -53,15 +54,18 @@ module Appear
53
54
  end
54
55
  end
55
56
 
57
+ # Execute the command. Will exit(3) with a status; does not return.
58
+ #
56
59
  # @param all_args [Array<String>] something like ARGV
57
60
  def execute(all_args)
58
61
  argv = option_parser.parse(*all_args)
59
62
 
60
- pid = Integer(argv[0] || Process.pid, 10)
61
-
62
- start_message = "STARTING. pid: #{pid}"
63
63
  if argv.empty?
64
- start_message += " (current process pid)"
64
+ pid = Process.pid
65
+ start_message = "STARTING. pid: #{pid} (current process pid)"
66
+ else
67
+ pid = Integer(argv[0])
68
+ start_message = "STARTING. pid: #{pid}"
65
69
  end
66
70
 
67
71
  start = Time.now
@@ -1,7 +1,8 @@
1
1
  require 'pathname'
2
2
 
3
3
  module Appear
4
- VERSION = '1.1.0'
4
+ # the version of Appear
5
+ VERSION = '1.1.1'
5
6
 
6
7
  # root error for our library; all other errors inherit from this one.
7
8
  class Error < StandardError; end
@@ -11,9 +11,6 @@ require 'appear/tmux'
11
11
  require 'appear/revealers'
12
12
 
13
13
  module Appear
14
- class CannotRevealError < Error; end
15
- class NoGuiError < CannotRevealError; end
16
-
17
14
  # Instance is the main class in Appear. It constructs all the other services
18
15
  # and co-ordinates the actual revealing process.
19
16
  class Instance < Service
@@ -40,6 +37,10 @@ module Appear
40
37
  super(@all_services)
41
38
  end
42
39
 
40
+ # appear the given PID.
41
+ #
42
+ # @param pid [Number] process id
43
+ # @return [Boolean] true if we revealed something, false otherwise.
43
44
  def call(pid)
44
45
  tree = process_tree(pid)
45
46
 
data/lib/appear/join.rb CHANGED
@@ -21,7 +21,7 @@ module Appear
21
21
  class Join
22
22
  # @param field [Symbol] the method or hash field name to join on.
23
23
  # @param tables [Array<Any>] arrays of any sort of object, so long as it is
24
- # either a hash, or implements the given field.
24
+ # either a hash, or has a method named `field`.
25
25
  # @return [Array<Join>]
26
26
  def self.join(field, *tables)
27
27
  by_field = Hash.new { |h, k| h[k] = self.new }
@@ -39,6 +39,12 @@ module Appear
39
39
  end
40
40
  end
41
41
 
42
+ # True if we can access the given field on an object, either by calling
43
+ # that method on the object, or by accessing using []
44
+ #
45
+ # @param obj [Any]
46
+ # @param field [Symbol, String]
47
+ # @return [Boolean]
42
48
  def self.can_access?(obj, field)
43
49
  if obj.respond_to?(field)
44
50
  return true
@@ -48,6 +54,12 @@ module Appear
48
54
  return false
49
55
  end
50
56
 
57
+ # Access the given field on an object.
58
+ # Raises an error if the field cannot be accessed.
59
+ #
60
+ # @param object [Any]
61
+ # @param field [Symbol, String]
62
+ # @return [Any] the value at that field
51
63
  def self.access(obj, field)
52
64
  if obj.respond_to?(field)
53
65
  obj.send(field)
@@ -58,21 +70,34 @@ module Appear
58
70
  end
59
71
  end
60
72
 
61
- # an instance of Join is a joined object containing all the data in all its
62
- # parts. Joins are read from left to right, returning the first non-nil
63
- # value encountered.
73
+ # A Join is a union of data objects. You can use a Join to group objects of
74
+ # different types, so that you may read from whichever has a given field.
75
+ #
76
+ # It is more useful to use self.join to perform a join operation on
77
+ # collections than to create Join objects directly.
64
78
  def initialize(*objs)
65
79
  @objs = objs
66
80
  end
67
81
 
68
- def push!(obj, note = nil)
82
+ # add another data object to this join.
83
+ #
84
+ # @param obj [Any]
85
+ def push!(obj)
69
86
  @objs << obj
70
87
  end
71
88
 
89
+ # get the number of objects in this join
90
+ #
91
+ # @return [Fixnum]
72
92
  def joined_count
73
93
  @objs.length
74
94
  end
75
95
 
96
+ # read a field from the join. Returns the first non-nil value we can read.
97
+ # @see self.access for information about how fields are accessed.
98
+ #
99
+ # @param sym [String, Symbol] the field name
100
+ # @return [Any, nil]
76
101
  def [](sym)
77
102
  result = nil
78
103
 
@@ -86,6 +111,12 @@ module Appear
86
111
  result
87
112
  end
88
113
 
114
+ # the {#method_missing} implementation on a Join allows you to access valid
115
+ # fields with regular accessors.
116
+ #
117
+ # @param method [String, Symbol]
118
+ # @param args [Array<Any>] should have none
119
+ # @param block [Proc] should have none
89
120
  def method_missing(method, *args, &block)
90
121
  raise NoMethodError.new("Cannot access #{method.inspect}") unless respond_to?(method)
91
122
  raise ArgumentError.new("Passed args to accessor") if args.length > 0
@@ -93,6 +124,9 @@ module Appear
93
124
  self[method]
94
125
  end
95
126
 
127
+ # @param sym [String, Symbol] name of the method
128
+ # @param priv [Boolean] default false
129
+ # @return [Boolean] true if we can respond to the given method name
96
130
  def respond_to?(sym, priv = false)
97
131
  super(sym, priv) || (@objs.any? { |o| self.class.can_access?(o, sym) })
98
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appear
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Teton-Landis