pprof 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: 1e19ab5781df3a2fe5ddd41e85b937da9134941a
4
- data.tar.gz: ec74aa8ec2cd3341756d38ab617839cb259d87ac
3
+ metadata.gz: 2f60b44644e56bc45b81947c9199dd4764fb662a
4
+ data.tar.gz: db0e68c466cda99a9f3bf089c51d8acf6d6b9ce9
5
5
  SHA512:
6
- metadata.gz: fd233c67e41648c601af8a57ae712a2ad32dfbd8912ba71d062633afbb6dbddeadc32161d9f5d929213c4479dfe8a0479c38c10d42d9bd6485477a28754df261
7
- data.tar.gz: df20d443af778ba98a8b44d44927a994dd94d97536369bfba77580e8740787c1a9ab593938a4000cf6ad6a667f18e42ab43a9f7ed5310a400dfecf95983e1e6c
6
+ metadata.gz: ce03ae54a596510d275de06aefa1d37bc303cb4e48be2ff64dfefa2df5105f4138f4a93c721fb5cf94fe8ff246577bf94d14d653fb7837d899c68dbd523a7c6e
7
+ data.tar.gz: 86d71af33e77f24bfbe5a22ba24c06f9eeee51a346fe8f640b8a18520a37d317b6d00d07f2f9099c30b1b41aaf7def99861736010fc4a329c2fef88dca9c86ca
data/README.md CHANGED
@@ -60,7 +60,11 @@ $ pprof --has-devices
60
60
 
61
61
  # Combine filters
62
62
  $ pprof --has-devices --aps --appid com.foo
63
+
64
+ # List only the expired profiles, and pipe the resulting list to xargs to remove them all
65
+ $ pprof --exp -0 | xargs -0 rm
63
66
  ```
67
+
64
68
  ```sh
65
69
  # Print info for a given Provisioning Profile
66
70
  $ pprof '12345678-ABCD-EF90-1234-567890ABCDEF'
data/bin/pprof CHANGED
@@ -3,7 +3,9 @@
3
3
  require 'pprof'
4
4
  require 'optparse'
5
5
 
6
-
6
+ # Creates a Regex if the string is wrapped inside `/…/`
7
+ # Or a standard match if the string is bare.
8
+ #
7
9
  def matcher(string)
8
10
  m = string.match(%r[^/(.*)/(.*)$])
9
11
  if m.nil?
@@ -17,17 +19,19 @@ end
17
19
 
18
20
  filters = {}
19
21
  options = {}
22
+ list_options = { :mode => :table }
23
+
20
24
  parser = OptionParser.new do |opts|
21
25
  opts.banner = <<-BANNER.gsub(/^ *\|/,'')
22
26
  |Usage:
23
- | pprof [options] [PATH|UUID]
24
- | pprof [filters]
27
+ | pprof [print_options] [PATH|UUID]
28
+ | pprof [list_options] [filters]
25
29
  |
26
30
  |Note: All filters expecting a string are interpreted as regular expressions if surrounded by slashes
27
31
  BANNER
28
32
 
29
33
  opts.separator ""
30
- opts.separator "Print options"
34
+ opts.separator "Print options (when file given)"
31
35
 
32
36
  opts.on("-i", "--info", "Print general info (default)") do
33
37
  options[:info] = true
@@ -40,9 +44,22 @@ parser = OptionParser.new do |opts|
40
44
  end
41
45
 
42
46
  opts.separator ""
43
- opts.separator "Filters"
47
+ opts.separator "List options (when no file given)"
48
+
49
+ opts.on("-l", "--list", "Print only the UUIDs, one per line (instead of an ASCII table)") do
50
+ list_options[:mode] = :list
51
+ end
52
+ opts.on("-p", "--path", "Print only the paths, one per line (instead of an ASCII table)") do
53
+ list_options[:mode] = :path
54
+ end
55
+ opts.on("-0", "--print0", "Separate each found entry by \0, to be used by `xargs -0`") do
56
+ list_options[:zero] = true
57
+ end
58
+
59
+ opts.separator ""
60
+ opts.separator "Filters (when no file given)"
44
61
 
45
- opts.on("-n", "--name NAME", "Filter by name") do |name|
62
+ opts.on("--name NAME", "Filter by name") do |name|
46
63
  filters[:name] = matcher(name)
47
64
  end
48
65
 
@@ -50,7 +67,7 @@ parser = OptionParser.new do |opts|
50
67
  filters[:appid_name] = matcher(appid_name)
51
68
  end
52
69
 
53
- opts.on("-a", "--appid APPID", "Filter by App ID") do |appid|
70
+ opts.on("--appid APPID", "Filter by App ID") do |appid|
54
71
  filters[:appid] = matcher(appid)
55
72
  end
56
73
 
@@ -58,7 +75,11 @@ parser = OptionParser.new do |opts|
58
75
  filters[:uuid] = matcher(uuid)
59
76
  end
60
77
 
61
- opts.on("-e", "--[no-]exp", "Only profiles (not) expired") do |flag|
78
+ opts.on("--team TEAM", "Filter by team name or ID") do |team|
79
+ filters[:team] = matcher(team)
80
+ end
81
+
82
+ opts.on("--[no-]exp", "Only profiles (not) expired") do |flag|
62
83
  filters[:exp] = flag
63
84
  end
64
85
 
@@ -117,7 +138,8 @@ end
117
138
  if ARGV.empty?
118
139
  # Print list of matching profiles
119
140
  o = PProf::OutputFormatter.new
120
- o.print_filtered_list(PProf::ProvisioningProfile::DEFAULT_DIR, filters)
141
+ list_options[:mode] = :path if list_options[:zero] && list_options[:mode] == :table
142
+ o.print_filtered_list(PProf::ProvisioningProfile::DEFAULT_DIR, filters, list_options)
121
143
  else
122
144
  # Print info about given profile path/UUID
123
145
  p = PProf::ProvisioningProfile.new(ARGV[0])
@@ -71,24 +71,44 @@ module PProf
71
71
  #
72
72
  # Convenience method. Calls self.print_list with a filter block build from a filter hash
73
73
  #
74
+ # @param [String] dir
75
+ # The directory to search for the provisioning profiles. Defaults to the standard directory on Mac
76
+ #
74
77
  # @param [Hash<Symbol,Any>] filters
75
78
  # The hash describing the applied filters
76
79
  #
77
- def print_filtered_list(dir = PProf::ProvisioningProfile::DEFAULT_DIR, filters = {})
78
- print_list(dir) do |p|
80
+ # @param [Hash<Symbol,Any>] list_options
81
+ # The way to print the output.
82
+ # * Valid values for key `:mode` are:
83
+ # - `:table` (for ASCII table output)
84
+ # - `:list` (for plain list of only the UUIDs, suitable for piping to `xargs`)
85
+ # - `:path` (for plain list of only the paths, suitable for piping to `xargs`)
86
+ # * Valid values for key `:zero` are `true` or `false` to decide if we print `\0` at the end of each output.
87
+ # Only used by `:list` and `:path` modes
88
+ #
89
+ def print_filtered_list(dir = PProf::ProvisioningProfile::DEFAULT_DIR, filters = {}, list_options = { :mode => :table })
90
+ filter_func = lambda do |p|
79
91
  (filters[:name].nil? || p.name =~ filters[:name]) &&
80
92
  (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&
81
93
  (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&
82
94
  (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&
95
+ (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&
83
96
  (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&
84
97
  (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&
85
98
  (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&
86
99
  (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&
87
100
  true
88
101
  end
102
+
103
+ case list_options[:mode]
104
+ when :table
105
+ print_table(dir, &filter_func)
106
+ else
107
+ print_list(dir, list_options, &filter_func)
108
+ end
89
109
  end
90
110
 
91
- # Prints the filtered list
111
+ # Prints the filtered list as a table
92
112
  #
93
113
  # @param [String] dir
94
114
  # The directory containing the mobileprovision files to list.
@@ -98,7 +118,7 @@ module PProf
98
118
  # The block is given ProvisioningProfile object and should
99
119
  # return true to display the row, false to filter it out
100
120
  #
101
- def print_list(dir = PProf::ProvisioningProfile::DEFAULT_DIR)
121
+ def print_table(dir = PProf::ProvisioningProfile::DEFAULT_DIR)
102
122
  count = 0
103
123
 
104
124
  table = PProf::OutputFormatter::ASCIITable.new(36, 60, 45, 25, 2, 10)
@@ -120,6 +140,27 @@ module PProf
120
140
  @output.puts "#{count} Provisioning Profiles found."
121
141
  end
122
142
 
143
+ # Prints the filtered list of UUIDs or Paths only
144
+ #
145
+ # @param [String] dir
146
+ # The directory containing the mobileprovision files to list.
147
+ # Defaults to '~/Library/MobileDevice/Provisioning Profiles'
148
+ #
149
+ # @yield each provisioning provile for filtering/validation
150
+ # The block is given ProvisioningProfile object and should
151
+ # return true to display the row, false to filter it out
152
+ #
153
+ def print_list(dir = PProf::ProvisioningProfile::DEFAULT_DIR, options)
154
+ Dir[dir + '/*.mobileprovision'].each do |file|
155
+ p = PProf::ProvisioningProfile.new(file)
156
+ next if block_given? && !yield(p)
157
+
158
+ @output.print options[:mode] == :uuid ? p.uuid.chomp : file.chomp
159
+ @output.print options[:zero] ? "\0" : "\n"
160
+ end
161
+ end
162
+
163
+
123
164
  private
124
165
  def self.match_aps_env(actual, expected)
125
166
  return false if actual.nil? # false if no Push entitlements
@@ -1,4 +1,4 @@
1
1
  module PProf
2
2
  # Module version
3
- VERSION = '0.3.4'
3
+ VERSION = '0.3.5'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Halligon