TokiCLI 0.0.6 → 0.0.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
  SHA1:
3
- metadata.gz: f75f8a7b54a3176511c5589d7cfd13fb3de6afa7
4
- data.tar.gz: 9edcdb6869e30b35f59b6406a1e71644b20da9dc
3
+ metadata.gz: 540ff62bc17ff6dba3312cf62395d76ba46ac522
4
+ data.tar.gz: a5281bcc5f82f6ba5ba7300b34a4eb5e9922fda1
5
5
  SHA512:
6
- metadata.gz: 938f6f3406004255d4bc7ba5ad5671585dff565b47a6c607e67989a6a39cac1e6a1393408befff8f7f1ea63f5b952e475c8f40f7adbf8f581700b20c5970f2ee
7
- data.tar.gz: fde21a595247b54df7a72ab5edc2358a4cddb6ef4562e80f0051fdad1e9e11a81400f5c53bba3bb24971e8c57154072d03406ba4ba99a0b68eb67e9087b45c95
6
+ metadata.gz: b934a2c4969dfefbf0128a7b19c84f4b279c1fef7aa0249e3b45f3cc620b740f8e3820df360c40caa2a76faa3e906d6e1bffaf6470837ec02f783ef1c7be11c8
7
+ data.tar.gz: 99ae0bf882c9b2c98cb1264a031542ee99a16949fd657f39b9373c548f5278c9e53eec59e0fe3ace15f0f05e80f76211c511937e7ad7ad06f1c80af04d890b33
@@ -1,3 +1,8 @@
1
+ # 0.0.7
2
+
3
+ - Scan for apps name
4
+ - Display apps name in results if apps have been scanned
5
+
1
6
  # 0.0.6
2
7
 
3
8
  - Fix paths
data/README.md CHANGED
@@ -4,7 +4,7 @@ Toki.app command-line client.
4
4
 
5
5
  Access your Toki data from the local database or from the App.net backup channel.
6
6
 
7
- ![TokiCLI](https://files.app.net/21krs3SJm.png)
7
+ ![TokiCLI](https://files.app.net/2dxzh_bHz.png)
8
8
 
9
9
 
10
10
  ## Installation
@@ -59,6 +59,14 @@ The dates you type have to be formatted like this: year-month-day and separated
59
59
 
60
60
  `toki range 2014-04-17 2014-04-19`
61
61
 
62
+ ### Scan
63
+
64
+ Scan for apps name.
65
+
66
+ Will crawl the Applications folder and try to resolve app names from bundle identifiers.
67
+
68
+ Toki will display apps names in results if apps have been scanned.
69
+
62
70
  ### Auth
63
71
 
64
72
  In order to be able to access your ADN channel (optional), TokiCLI has to obtain a "token" (secret code) from App.net.
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 1.9.3'
22
22
 
23
- spec.add_dependency "thor", ">= 0.18"
24
- spec.add_dependency "rest-client", ">= 1.6"
25
- spec.add_dependency "amalgalite", ">= 1.3"
26
- spec.add_dependency "terminal-table", ">= 1.4"
23
+ spec.add_dependency "thor", "~> 0.18"
24
+ spec.add_dependency "rest-client", "~> 1.6"
25
+ spec.add_dependency "amalgalite", "~> 1.3"
26
+ spec.add_dependency "terminal-table", "~> 1.4"
27
+ spec.add_dependency "CFPropertyList", "~> 2.2.8"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.6"
29
30
  spec.add_development_dependency "rake"
@@ -4,6 +4,18 @@ module TokiCLI
4
4
  package_name "TokiCLI"
5
5
  %w{get_messages search_messages get_channels module status view authorize}.each {|r| require_relative "#{r}"}
6
6
 
7
+ desc "scan", "Scan /Applications to resolve app names"
8
+ def scan
9
+ toki = create_toki(options)
10
+ bundle_ids = toki.get_bundle_ids
11
+ path = "#{Dir.home}/.toki_cli"
12
+ Dir.mkdir path unless Dir.exist? path
13
+ f = File.new "#{path}/apps.json", "w"
14
+ f.write bundle_ids.to_json
15
+ f.close
16
+ puts "\nDone.\n\n"
17
+ end
18
+
7
19
  desc "total", "Shows the total usage of all apps"
8
20
  option :adn, aliases: '-a', type: :boolean, desc: 'Select ADN channel as source (toki total -a)'
9
21
  option :json, aliases: '-j', type: :boolean, desc: 'Export the results as a JSON file'
@@ -175,7 +187,8 @@ module TokiCLI
175
187
  end
176
188
 
177
189
  def get_all(t, options)
178
- t.all_data(t.get_content(options))
190
+ content = t.get_content(options)
191
+ t.all_data(content)
179
192
  end
180
193
  end
181
194
  end
@@ -10,7 +10,7 @@ module ADNChannels
10
10
  args = {:count => 200, :before_id => nil}
11
11
  messages = []
12
12
  @index = 1
13
- puts "Downloading synced objects (~1MB/page):\n\n"
13
+ puts "Downloading synced objects (200/page):\n\n"
14
14
  loop do
15
15
  puts "--Downloading from page #{@index}...\n"
16
16
  @url = "#{@base_url}/channels/#{channel_id}/messages?access_token=#{@token}&include_machine=1&include_message_annotations=1&include_deleted=0&include_html=0&count=#{args[:count]}&before_id=#{args[:before_id]}"
@@ -5,11 +5,31 @@ module TokiCLI
5
5
  CLIENT_ID = 'm6AccJFM56ENCn58Vde9cSg3uSpbvAAs'
6
6
  CALLBACK_URL = 'http://aya.io/toki_cli/auth.html'
7
7
 
8
+ attr_reader :bundles
9
+
8
10
  def initialize(token, channel_id)
9
11
  @token = token
10
12
  @channel_id = channel_id
13
+ if File.exist? "#{Dir.home}/.toki_cli/apps.json"
14
+ @bundles = JSON.parse(File.read("#{Dir.home}/.toki_cli/apps.json"))
15
+ end
16
+ end
17
+
18
+ def get_bundle_ids
19
+ puts "Analyzing apps in /Applications\n\n"
20
+ require 'CFPropertyList'
21
+ files = get_plists "/Applications/*/Contents/*"
22
+ utils = get_plists "/Applications/Utilities/*/Contents/*"
23
+ home = get_plists "#{Dir.home}/Applications/*/Contents/*"
24
+ @infos = {}
25
+ get_bundles files
26
+ get_bundles utils
27
+ get_bundles home
28
+ @infos
11
29
  end
12
30
 
31
+
32
+
13
33
  def get_content(options)
14
34
  if options[:adn]
15
35
  get_adn_data.reverse.map {|obj| make_obj_from_adn(obj)}
@@ -136,7 +156,7 @@ module TokiCLI
136
156
  usr[:id] = obj['user']['id']
137
157
  app[:id] = d['id']
138
158
  app[:uuid] = d['UUID']
139
- app[:name] = d['bundleIdentifier']
159
+ app[:name] = make_app_name [nil, d['bundleIdentifier']]
140
160
  app[:active_to] = d['activeTo']
141
161
  app[:active_from] = d['activeFrom']
142
162
  app[:total] = d['totalSeconds']
@@ -157,15 +177,48 @@ module TokiCLI
157
177
  usr[:id] = obj[5]
158
178
  app[:id] = msg[:id]
159
179
  app[:uuid] = obj[5]
160
- app[:name] = obj[1]
180
+ app[:name] = make_app_name obj
161
181
  app[:active_to] = obj[3]
162
182
  app[:active_from] = obj[2]
163
183
  app[:total] = obj[4]
164
184
  OpenStruct.new(app: app, msg: msg, usr: usr)
165
185
  end
166
186
 
187
+ def make_app_name obj
188
+ if @bundles[obj[1]]
189
+ @bundles[obj[1]]
190
+ else
191
+ obj[1]
192
+ end
193
+ end
194
+
167
195
  def parsed_date(string)
168
196
  "#{string[0...10]} #{string[11...19]}"
169
197
  end
198
+
199
+ def get_plists path
200
+ Dir.glob(path).select {|f| (File.split f).last == 'Info.plist'}
201
+ end
202
+
203
+ def get_bundles plists
204
+ plists.each do |obj|
205
+ puts "Analyzing #{obj} ...\n"
206
+ begin
207
+ pl = CFPropertyList::List.new(:file => obj)
208
+ rescue CFFormatError
209
+ puts "Unable to read the file, skipping...\n"
210
+ next
211
+ end
212
+ data = CFPropertyList.native_types(pl.value)
213
+ name = data['CFBundleName']
214
+ bundle_id = data['CFBundleIdentifier']
215
+ if name.nil?
216
+ name = data['CFBundleExecutable']
217
+ end
218
+ next if name.nil?
219
+ next if bundle_id.nil? || bundle_id.empty?
220
+ @infos[bundle_id] = name
221
+ end
222
+ end
170
223
  end
171
224
  end
@@ -1,3 +1,3 @@
1
1
  module TokiCLI
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TokiCLI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: amalgalite
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: terminal-table
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: CFPropertyList
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.2.8
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.2.8
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement