pullbox 0.1.2 → 0.1.3

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: c2f534754efeeb67e20f795dc0c6593f5f7c378bc5493d0d05a53c04cc7b4207
4
- data.tar.gz: 888cbe6a7966336d76da1d273c69f98580bef9eae2d7c6218acf79417b9b3984
3
+ metadata.gz: e721acd3845f22b0cbba4fcea949777d7deeabf0d9373018ae18521196aaf66e
4
+ data.tar.gz: 1c069eb6bb2ebd32bf3b51b832ec77293a40403c2b45f688970b8ed59097e8ef
5
5
  SHA512:
6
- metadata.gz: a04bd17a33c23f78d18a4c5132b89ea46ecc9548bd3ca1ed702febcc5ca35a01768b4c3174e6d599b8599936b8989209780a27789e496c942cce40b5a519b36c
7
- data.tar.gz: d251bc033b8301038517c2fb7f93e6ff8a6631099e6efaabf811918909f800e9c3167442e3df8f6d1e80eb14bba0c424daa6688c71cf1de45d25fa4040eac05b
6
+ metadata.gz: 6f49441a2c0c98c657880982d28798e82bb5843e6eb7067cd86106006b16ccedd5515493b00b6672188644063c3d2a1465d8a2a121e535269d4af29993a5f09f
7
+ data.tar.gz: d23e5b59248593bfc0c8653f49725264cfe72073f53535cfe5be80c2e98e769a16f2ce0e4ba18e83d545dad4104f37a3029b47b983575e793679752a9930afc2
data/exe/mailmate_beta CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "english"
4
+ require "English"
5
5
  require "plist"
6
- require "pullbox/applescript"
6
+ require_relative "../lib/pullbox/applescript"
7
7
 
8
- result = Plist.parse_xml("/Applications/MailMate.app/Contents/Info.plist")
9
- raise "MailMate not installed." if result.nil?
8
+ mailmate = "/Applications/MailMate.app/Contents/Info.plist"
9
+ raise "MailMate not installed." unless File.exist? mailmate
10
+
11
+ result = Plist.parse_xml(mailmate)
12
+ raise "MailMate not properly installed." if result.nil?
10
13
 
11
14
  long_version = result["CFBundleGetInfoString"]
12
15
  version = long_version.match(/\(r(?<number>\d+)\)/i)
@@ -15,6 +18,6 @@ search_string = "MailMate_r#{following_release}.tbz"
15
18
 
16
19
  content = `curl -s https://updates.mailmate-app.com/archives/ | grep #{search_string}`
17
20
 
18
- if !content.empty? && $CHILD_STATUS.zero?
21
+ if !content.empty? && $CHILD_STATUS.exited?
19
22
  Pullbox::AppleScript.display_dialog "Update available.\nVersion: #{following_release}", "MailMate"
20
23
  end
@@ -22,41 +22,49 @@ module Pullbox
22
22
 
23
23
  def self.display_dialog(message, title, defaults = {})
24
24
  defaults = { answer: false, buttons: %w[OK] }.merge(defaults)
25
- answer = defaults[:answer] == true ? ' default answer ""' : ""
25
+ answer = defaults[:answer] ? ' default answer ""' : ""
26
+ default_button = defaults[:buttons].last
27
+ cancel_button = defaults[:buttons].first
26
28
  buttons = 'buttons {"'
27
- buttons << defaults[:buttons].join('", "')
28
- buttons << "\"} default button \"#{defaults[:buttons].last}\""
29
+ button_construct = buttons.dup
30
+ button_construct << defaults[:buttons].join('", "')
31
+ button_construct << "\"} default button \"#{default_button}\" cancel button \"#{cancel_button}\""
29
32
  applescript = <<~APS.strip
30
33
  #{intro}
31
34
  try
32
- return text returned of (display dialog "#{message}"#{buttons}#{answer} with title "#{title}")
35
+ set theReturnedValue to (display dialog "#{message}" #{button_construct}#{answer} with title "#{title}")
36
+ if button returned of theReturnedValue is "#{default_button}" then
37
+ if text returned of theReturnedValue is not "" then
38
+ return text returned of theReturnedValue
39
+ else
40
+ return
41
+ end if
42
+ end if
33
43
  on error errorMessage number errorNumber
34
44
  if errorNumber is equal to -128 -- aborted by user
35
- return ""
45
+ return
36
46
  end if
37
47
  end try
38
48
  APS
39
49
  answer = `osascript -e '#{applescript}'`.strip
40
50
 
41
- exit! if answer == ""
51
+ exit(0) if answer.empty?
42
52
 
43
53
  answer
44
54
  end
45
55
 
46
56
  def self.export_playlist(name, to, format = :xml)
47
- allowed_formats = {
57
+ formats = {
48
58
  m3u: "M3U",
49
59
  m3u8: "M3U8",
50
60
  plain_text: "plain text",
51
61
  unicode_text: "Unicode text",
52
62
  xml: "XML"
53
63
  }
54
- raise ArgumentError, "Export format not supported" unless allowed_formats.keys.include? format
55
64
 
56
- format = allowed_formats[format]
57
65
  applescript = <<~APS.strip
58
66
  #{intro}
59
- tell application "Music" to export playlist "#{name}" as #{format} to "#{to}"
67
+ tell application "Music" to export playlist "#{name}" as #{formats.fetch(format, 'XML')} to "#{to}"
60
68
  APS
61
69
  system "osascript -e '#{applescript}'"
62
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pullbox
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pullbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PuLLi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-15 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plist