cookiedough 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cookiedough-0.1.0.gem +0 -0
- data/cookiedough.gemspec +28 -0
- data/lib/cookiedough/version.rb +3 -0
- data/lib/cookiedough.rb +155 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ea68ab23ce4c1a2032a24dfb7032edba0e4c7fa
|
4
|
+
data.tar.gz: cff155a5407a4beab948aca44694b632824cc7d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 834ce4e149f90588afb978480b06bcb99c2fd277fabc7a5d0000850c5b2f5135b3f8881f6ba3d21a68fc82e241719bfc0c0d6ef7480635a42c6c820328e20526
|
7
|
+
data.tar.gz: cd22458af86ed64b7788a97befec869520479f542f7183762e74db27a1f8fff134008bb649d00deb7782163342a0c9d24e9b3791d72d686ce9801d1ea57943c4
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nic Scott
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# CookieDough
|
2
|
+
|
3
|
+
A Ruby gem for macOS clients to report about items in the Applications folder.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cookiedough'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cookiedough
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
To see a list of availible options for CookieDough, require 'CookieDough' in file then type:
|
23
|
+
`puts CookieDough.options`
|
24
|
+
|
25
|
+
|
26
|
+
output should be similar to this:
|
27
|
+
***
|
28
|
+
- all_app_versions
|
29
|
+
- app_version
|
30
|
+
- dock_apps
|
31
|
+
- dock_bundles
|
32
|
+
- list_apps
|
33
|
+
- options
|
34
|
+
- receipts
|
35
|
+
- user_installed_apps
|
36
|
+
|
37
|
+
## Examples:
|
38
|
+
|
39
|
+
To get all applications versions: `puts CookieDough.all_app_versions`
|
40
|
+
|
41
|
+
To get a single application versions: `puts CookieDough.app_version("pathtoapplication")`
|
42
|
+
|
43
|
+
To get what applications are in the dock of the current user: `puts CookieDough.dock_apps`
|
44
|
+
|
45
|
+
To specify a user add their username as an argument, this must be run as root: `puts CookieDough.dock_apps("username")`
|
46
|
+
|
47
|
+
To get what bundleid's are in the dock of the current user: `puts CookieDough.dock_bundles`
|
48
|
+
|
49
|
+
To specify a user add their username as an argument, this must be run as root: `puts CookieDough.dock_bundles("username")`
|
50
|
+
|
51
|
+
To get what's currently in Applications folder: `puts CookieDough.list_apps`
|
52
|
+
|
53
|
+
To get what's been installed with installer recipets: `puts CookieDough.receipts`
|
54
|
+
|
55
|
+
To get what's been installed by the user. This removes base apps that ship with macOS: `puts CookieDough.user_installed_apps`
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
63
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cookiedough"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
Binary file
|
data/cookiedough.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cookiedough/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cookiedough"
|
8
|
+
spec.version = CookieDough::VERSION
|
9
|
+
spec.authors = ["Nic Scott"]
|
10
|
+
spec.email = ["nls.inbox@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A Ruby gem for macOS machines to report on Applications}
|
13
|
+
spec.homepage = "https://github.com/nlscott/cookiedough"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
+
spec.add_development_dependency "CFPropertyList", ">= 2.0.0"
|
27
|
+
|
28
|
+
end
|
data/lib/cookiedough.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
require "cookiedough/version"
|
2
|
+
require 'CFPropertyList'
|
3
|
+
require 'etc'
|
4
|
+
|
5
|
+
module CookieDough
|
6
|
+
CURRENTUSER=Etc.getlogin
|
7
|
+
|
8
|
+
#a list of default apps installed by the base macOS 10.12 system
|
9
|
+
BASEAPPS = [ "App Store.app", "Automator.app", "Calculator.app","Calendar.app", "Chess.app",
|
10
|
+
"Contacts.app", "Dashboard.app", "Dictionary.app", "DVD Player.app", "FaceTime.app",
|
11
|
+
"Font Book.app", "Game Center.app", "iBooks.app", "Image Capture.app","iTunes.app",
|
12
|
+
"Launchpad.app", "Mail.app", "Maps.app", "Messages.app", "Mission Control.app", "Notes.app",
|
13
|
+
"Photo Booth.app", "Photos.app", "Preview.app", "QuickTime Player.app", "Reminders.app", "Safari.app",
|
14
|
+
"Stickies.app", "System Preferences.app", "TextEdit.app", "Time Machine.app", "Utilities"]
|
15
|
+
|
16
|
+
#list entries in /Applications folder
|
17
|
+
def self.list_apps
|
18
|
+
apps = []
|
19
|
+
Dir.entries("/Applications").each do |appname|
|
20
|
+
if !appname.start_with?(".")
|
21
|
+
apps.push(appname)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return apps
|
25
|
+
end
|
26
|
+
|
27
|
+
#returns a list of apps installed by users ... minus the baseapps
|
28
|
+
def self.user_installed_apps
|
29
|
+
user_installed = []
|
30
|
+
for x in list_apps
|
31
|
+
if !CookieDough::BASEAPPS.include?(x)
|
32
|
+
user_installed.push(x)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
return user_installed
|
36
|
+
end
|
37
|
+
|
38
|
+
#list of apps and version numbers
|
39
|
+
def self.all_app_versions
|
40
|
+
apps_to_check = []
|
41
|
+
app_versions = []
|
42
|
+
|
43
|
+
Dir.entries("/Applications").each do |appname|
|
44
|
+
if appname.end_with?(".app")
|
45
|
+
apps_to_check.push(appname)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
for app in apps_to_check
|
50
|
+
if File.file?("/Applications/#{app}/Contents/Info.plist")
|
51
|
+
begin
|
52
|
+
plist = CFPropertyList::List.new(:file => "/Applications/#{app}/Contents/Info.plist")
|
53
|
+
results=CFPropertyList.native_types(plist.value)
|
54
|
+
rescue
|
55
|
+
puts "Error: misformed XML for '#{app}'"
|
56
|
+
else
|
57
|
+
app_versions.push("#{app} = #{results['CFBundleShortVersionString']}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
check=[]
|
62
|
+
Dir.entries("/Applications").each do |appname|
|
63
|
+
if File.directory?("/Applications/#{appname}")
|
64
|
+
if !appname.end_with?(".app")
|
65
|
+
if !appname.start_with?(".")
|
66
|
+
check.push(appname)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
check.delete("Utilities")
|
72
|
+
|
73
|
+
direcotries=[]
|
74
|
+
check.each do |appname|
|
75
|
+
Dir.entries("/Applications/#{appname}").each do |app|
|
76
|
+
if app.end_with?(".app")
|
77
|
+
if File.exist?("/Applications/#{appname}/#{app}/Contents/Info.plist")
|
78
|
+
begin
|
79
|
+
plist = CFPropertyList::List.new(:file => "/Applications/#{appname}/#{app}/Contents/Info.plist")
|
80
|
+
results=CFPropertyList.native_types(plist.value)
|
81
|
+
rescue
|
82
|
+
puts "Error: misformed XML for '#{appname}/#{app}'"
|
83
|
+
else
|
84
|
+
app_versions.push("#{appname}/#{app} = #{results['CFBundleShortVersionString']}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
return app_versions.sort
|
92
|
+
end
|
93
|
+
|
94
|
+
#list a single app version but suppling a pathname to an app
|
95
|
+
def self.app_version(appname)
|
96
|
+
if File.exist?("/Applications/#{appname}")
|
97
|
+
if File.exist?("/Applications/#{appname}/Contents/Info.plist")
|
98
|
+
plist = CFPropertyList::List.new(:file => "/Applications/#{appname}/Contents/Info.plist")
|
99
|
+
results=CFPropertyList.native_types(plist.value)
|
100
|
+
return results["CFBundleShortVersionString"]
|
101
|
+
end
|
102
|
+
else
|
103
|
+
return "Error: Appliction can't be found"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
#list the aspps in a users dock
|
108
|
+
def self.dock_apps(user = CURRENTUSER)
|
109
|
+
|
110
|
+
plist = CFPropertyList::List.new(:file => "/Users/#{user}/Library/Preferences/com.apple.dock.plist")
|
111
|
+
results=CFPropertyList.native_types(plist.value)
|
112
|
+
apps=[]
|
113
|
+
for key, value in results['persistent-apps']
|
114
|
+
for key, value in key
|
115
|
+
if value.class == Hash
|
116
|
+
for x, y in value
|
117
|
+
if x == "file-label"
|
118
|
+
apps.push(y)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
return apps
|
125
|
+
end
|
126
|
+
|
127
|
+
#list the apps bundle ids in the users dock
|
128
|
+
def self.dock_bundles(user = CURRENTUSER)
|
129
|
+
plist = CFPropertyList::List.new(:file => "/Users/#{user}/Library/Preferences/com.apple.dock.plist")
|
130
|
+
results=CFPropertyList.native_types(plist.value)
|
131
|
+
apps=[]
|
132
|
+
for key, value in results['persistent-apps']
|
133
|
+
for key, value in key
|
134
|
+
if value.class == Hash
|
135
|
+
for x, y in value
|
136
|
+
if x == "bundle-identifier"
|
137
|
+
apps.push(y)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
return apps
|
144
|
+
end
|
145
|
+
|
146
|
+
#list the receipts for apps that were installed
|
147
|
+
def self.receipts
|
148
|
+
results=`pkgutil --pkgs`.lines
|
149
|
+
end
|
150
|
+
|
151
|
+
#list options
|
152
|
+
def self.options
|
153
|
+
return CookieDough.methods(false).sort
|
154
|
+
end
|
155
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cookiedough
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nic Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: CFPropertyList
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.0
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- nls.inbox@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- cookiedough-0.1.0.gem
|
86
|
+
- cookiedough.gemspec
|
87
|
+
- lib/cookiedough.rb
|
88
|
+
- lib/cookiedough/version.rb
|
89
|
+
homepage: https://github.com/nlscott/cookiedough
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.0.14.1
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: A Ruby gem for macOS machines to report on Applications
|
113
|
+
test_files: []
|