pullbox 0.1.1 → 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: ea371944eac7d4d47ece3f3932696e6c786e66115a022916361e828edb673228
4
- data.tar.gz: dd9f473f57cfa7996e8f16a3d31198f15867c6a6417b7e10ebfeb2cb4ea81e38
3
+ metadata.gz: e721acd3845f22b0cbba4fcea949777d7deeabf0d9373018ae18521196aaf66e
4
+ data.tar.gz: 1c069eb6bb2ebd32bf3b51b832ec77293a40403c2b45f688970b8ed59097e8ef
5
5
  SHA512:
6
- metadata.gz: c269ed5af6653c5a57bcc9436386872b00596ec25a9c4d421c7dbc7f34ff116519ae93b15646151116bfc9fd71eba5d7ad237e21ded430836b91b258790f66ad
7
- data.tar.gz: a30b0cde3a70d4f99eeb5f63ab22923733899b8e5ec7ce9bf3ed4be3be4be15a33654ca94ed149b369f6ad8101dd44c7cb66f57728088308fb325917425032a7
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
@@ -13,34 +13,60 @@ module Pullbox
13
13
  end
14
14
 
15
15
  def self.display_notification(message, title)
16
- apple_script = <<~APS.strip
16
+ applescript = <<~APS.strip
17
17
  #{intro}
18
18
  display notification "#{message}" with title "#{title}"
19
19
  APS
20
- system "osascript -e '#{apple_script}'"
20
+ system "osascript -e '#{applescript}'"
21
21
  end
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
- apple_script = <<~APS.strip
29
+ button_construct = buttons.dup
30
+ button_construct << defaults[:buttons].join('", "')
31
+ button_construct << "\"} default button \"#{default_button}\" cancel button \"#{cancel_button}\""
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
- answer = `osascript -e '#{apple_script}'`.strip
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
55
+
56
+ def self.export_playlist(name, to, format = :xml)
57
+ formats = {
58
+ m3u: "M3U",
59
+ m3u8: "M3U8",
60
+ plain_text: "plain text",
61
+ unicode_text: "Unicode text",
62
+ xml: "XML"
63
+ }
64
+
65
+ applescript = <<~APS.strip
66
+ #{intro}
67
+ tell application "Music" to export playlist "#{name}" as #{formats.fetch(format, 'XML')} to "#{to}"
68
+ APS
69
+ system "osascript -e '#{applescript}'"
70
+ end
45
71
  end
46
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pullbox
4
- VERSION = "0.1.1"
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.1
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: 2022-12-26 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
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.3.26
72
+ rubygems_version: 3.4.1
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Just a small toolbox for AppleScript, DEVONthink and MailMate