shortlook 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 39c4e2416a0b5eb48a0e2c3ffa656c603524f470ea4660536abe8d3af2613564
4
- data.tar.gz: 2cf9a40a98b3bccbfca78df8ff0f2da3aa984cd21d3f8a15e73a92fd97ea0d58
3
+ metadata.gz: 344cd5490ad33700a75197a6a67fa2b6e4544f099890a2966ea0d2ea821bff07
4
+ data.tar.gz: 3628d2ecdd6a482d0486e7e9ca8687447e1cfc96587eced2f657dc5e868d7be4
5
5
  SHA512:
6
- metadata.gz: 86b9b3372fa056cafb57415d3ffd37a1021efed59a934172f74c934044f9330a111dc813b8088b0499dfdda6aad5bf88bd12f584c993c1d804f1c2008c621868
7
- data.tar.gz: f831d627b0916574ad243383a1d1aadcbe7bfbb51e05d05ef8cca61721fe75c17a1c50abc17d8c1d3b814f39be1e0e8e93a5dd5d1ff1e294c422e5443f254a1a
6
+ metadata.gz: 85d52a0e40da40072bdbd5d416e78789544160849514a95ba5543c455b803a09a69f63738e28b4158d37c23979948a61a4df090830fe16478fd09554c05a1718
7
+ data.tar.gz: bbeb16afa998551d5d66d971eae14f99eb966c96feded213c5ca195331a9a75c333a1fad136ebd73bc0e44eb3854b31e2c1d8368a1ec723092dc158b21996655
data/README.md CHANGED
@@ -2,21 +2,22 @@
2
2
 
3
3
  This is a CLI for scaffolding a ShortLook Provider
4
4
 
5
- ## Installation
5
+ Learn more about ShortLook itself [here](https://dynastic.co/shortlook).
6
6
 
7
- Add this line to your application's Gemfile:
7
+ If you are looking for ShortLook providers you can find them [here](https://github.com/marcoroth?utf8=✓&tab=repositories&q=ShortLook-&type=&language=objective-c) or [here](https://repo.dynastic.co).
8
8
 
9
- ```ruby
10
- gem 'shortlook'
11
- ```
9
+ ## Installation
12
10
 
13
- And then execute:
11
+ This CLI runs on Ruby. Ensure you have Ruby installed before executing the following command:
14
12
 
15
- $ bundle
13
+ $ gem install shortlook
16
14
 
17
- Or install it yourself as:
15
+ You can check if Ruby is installed with the following command
18
16
 
19
- $ gem install shortlook
17
+ ```
18
+ $ ruby -v
19
+ ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
20
+ ```
20
21
 
21
22
  ## Usage
22
23
 
@@ -33,7 +34,7 @@ Commands:
33
34
 
34
35
  To start the Provider generator use the `provider` command followed by the search term of the app you want to build a provider for:
35
36
 
36
- ```bash
37
+ ```
37
38
  $ shortlook provider whatsapp
38
39
 
39
40
  ( ● ) Fetching Apps for 'whatsapp'
@@ -14,64 +14,70 @@ module Shortlook
14
14
  class Provider < Shortlook::Command
15
15
  include Thor::Actions
16
16
 
17
+ TYPES = [
18
+ { name: 'Contact Photo', value: { name: 'ContactPhoto', display: 'Contact Photos', key: 'contact-photo' } },
19
+ { name: 'Profile Picture', value: { name: 'ProfilePicture', display: 'Profile Pictures', key: 'profile-picture' } },
20
+ { name: 'Photo', value: { name: 'Photo', display: 'Photos', key: 'photos' } },
21
+ { name: 'Cover', value: { name: 'Cover', display: 'Covers', key: 'covers' } }
22
+ ].freeze
23
+
17
24
  def initialize(name)
18
25
  @name = name
19
- end
26
+ @config = TTY::Config.new
27
+ @config.append_path(Dir.home)
28
+
29
+ begin
30
+ @config.read("#{Dir.home}/.shortlook.yml")
31
+ @author = @config.fetch(:author)
32
+ @bundle_prefix = @config.fetch(:bundle_prefix)
33
+ rescue TTY::Config::ReadError
34
+ @config.filename = '.shortlook'
35
+ @author = ENV['USER']
36
+ @bundle_prefix = 'ch.marcoroth'
37
+ end
20
38
 
21
- def execute(*)
22
- config = TTY::Config.new
23
- config.append_path(Dir.home)
24
-
25
39
  spinner = TTY::Spinner.new(":spinner Fetching Apps for '#{@name}'", format: :bouncing_ball)
26
40
  spinner.auto_spin
27
41
 
28
42
  url = "https://itunes.apple.com/search?limit=10&media=software&term=#{@name}"
29
43
  results = JSON.parse(LHC.get(url).body)['results']
30
- choices = results.map { |r| { name: "#{r['trackName']} (#{r['bundleId']})", value: r } }
31
-
32
- types = [
33
- { name: 'Contact Photo', value: { name: 'ContactPhoto', display: 'Contact Photos', key: 'contact-photo' } },
34
- { name: 'Profile Picture', value: { name: 'ProfilePicture', display: 'Profile Pictures', key: 'profile-picture' } },
35
- { name: 'Photo', value: { name: 'Photo', display: 'Photos', key: 'photos' } },
36
- { name: 'Cover', value: { name: 'Cover', display: 'Covers', key: 'covers' } }
37
- ]
38
-
44
+ @choices = results.map { |r| { name: "#{r['trackName']} (#{r['bundleId']})", value: r } }
39
45
  spinner.stop
46
+ end
40
47
 
41
- begin
42
- config.read("#{Dir.home}/.shortlook.yml")
43
- author = config.fetch(:author)
44
- bundle_prefix = config.fetch(:bundle_prefix)
45
- rescue TTY::Config::ReadError
46
- config.filename = '.shortlook'
47
- author = ENV['USER']
48
- bundle_prefix = 'ch.marcoroth'
49
- end
50
-
51
- selected = prompt.select('Select the App you want to create a Provider for:', choices)
52
- name = prompt.ask('What\'s the name of your provider:', default: selected['trackName'])
53
- type = prompt.select('Select the type of the provider:', types)
54
- author = prompt.ask('What\'s your name?', default: author)
55
- bundle_prefix = prompt.ask('What\'s your bundle identifier prefix:', default: bundle_prefix)
56
-
57
- config.set(:author, value: author)
58
- config.set(:bundle_prefix, value: bundle_prefix)
59
- config.write(force: true)
48
+ def execute(*)
49
+ selected = prompt.select('Select the App you want to create a Provider for:', @choices)
50
+ full_name = prompt.ask('What\'s the name of your provider:', default: selected['trackName'])
51
+ type = prompt.select('Select the type of the provider:', TYPES)
52
+ @author = prompt.ask('What\'s your name?', default: @author)
53
+ @bundle_prefix = prompt.ask('What\'s your bundle identifier prefix:', default: @bundle_prefix)
60
54
 
55
+ name = full_name.gsub(/\W/, '')
61
56
  bundle_id = selected['bundleId']
62
- provider_name = "ShortLook-#{name.delete(' ')}"
63
- class_name = "#{name.delete(' ')}#{type[:name]}Provider"
64
- provider_bundle_id = "#{bundle_prefix}.shortlook.plugin.#{type[:key]}.#{name.downcase.delete(' ')}"
57
+ provider_name = "ShortLook-#{name}"
58
+ class_name = "#{name}#{type[:name]}Provider"
59
+ provider_bundle_id = "#{@bundle_prefix}.shortlook.plugin.#{type[:key]}.#{name.downcase}"
60
+
61
+ save_config
65
62
 
66
63
  {
67
- name: name,
64
+ name: full_name,
68
65
  provider_name: provider_name,
69
66
  class_name: class_name,
70
- author: author,
67
+ author: @author,
71
68
  type: type,
72
69
  bundle_id: bundle_id,
73
70
  provider_bundle_id: provider_bundle_id
74
71
  }
72
+ rescue TTY::Reader::InputInterrupt
73
+ puts "\nAborting..."
74
+ exit(0)
75
+ end
76
+
77
+ def save_config
78
+ @config.set(:author, value: @author)
79
+ @config.set(:bundle_prefix, value: @bundle_prefix)
80
+ @config.write(force: true)
75
81
  end
76
82
  end
77
83
  end
@@ -1,3 +1,3 @@
1
1
  module Shortlook
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shortlook
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
  - Marco Roth