pullbox 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fdf1c4144ac295541bd9d90ee7a0a63d757459c98d234d476df8b49b2a947970
4
+ data.tar.gz: 18b70bbfae8ee2b095fa1c3f133dec3f337ac750dd76ffff042fb32340ecda8b
5
+ SHA512:
6
+ metadata.gz: 654684f99ad77125c5d1b4abc088c2a6ab2a487498f0960498d516eb83386fef20f5394dc77eaf2e68fe2a29bb91c581d3fa561f9473994a0a369e24a3ef894c
7
+ data.tar.gz: 62e0550fab635e5184df8aed20f083a8f48bbe86c6200af366092afd3e2622951af3b33cafd8fa128dc040784cd8a095531b09891b27b3c9f0fcfa5bddba8d7f
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-22
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pullbox.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 PuLLi
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,33 @@
1
+ # Pullbox
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pullbox`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add pullbox
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install pullbox
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pullbox.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Library for several classes
4
+ module Pullbox
5
+ # Applescript wrapper
6
+ class AppleScript
7
+ def self.intro
8
+ <<~APS.strip
9
+ use AppleScript version "2.4" -- Yosemite (10.10) or later
10
+ use scripting additions
11
+
12
+ APS
13
+ end
14
+
15
+ def self.display_notification(message, title)
16
+ apple_script = <<~APS.strip
17
+ #{intro}
18
+ display notification "#{message}" with title "#{title}"
19
+ APS
20
+ system "osascript -e '#{apple_script}'"
21
+ end
22
+
23
+ def self.display_dialog(message, title, defaults = {})
24
+ defaults = { answer: false, buttons: %w[OK] }.merge(defaults)
25
+ answer = defaults[:answer] == true ? ' default answer ""' : ''
26
+ buttons = 'buttons {"'
27
+ buttons << defaults[:buttons].join('", "')
28
+ buttons << "\"} default button \"#{defaults[:buttons].last}\""
29
+ apple_script = <<~APS.strip
30
+ #{intro}
31
+ try
32
+ return text returned of (display dialog "#{message}"#{buttons}#{answer} with title "#{title}")
33
+ on error errorMessage number errorNumber
34
+ if errorNumber is equal to -128 -- aborted by user
35
+ return ""
36
+ end if
37
+ end try
38
+ APS
39
+ answer = `osascript -e '#{apple_script}'`.strip
40
+
41
+ exit! if answer == ''
42
+
43
+ answer
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'applescript'
4
+
5
+ # Library for several classes
6
+ module Pullbox
7
+ # DEVONthink AppleScript methods
8
+ class DEVONthink
9
+ def self.path_to_record(uuid)
10
+ applescript = <<~APS.strip
11
+ #{AppleScript.intro}
12
+ tell application id "DNtp"
13
+ set theRecord to get record with uuid "#{uuid}"
14
+ if (type of theRecord as string) is not in {"group", "smart group", "tag"} then return (path of theRecord as string)
15
+ end tell
16
+ APS
17
+
18
+ `osascript -e '#{applescript}'`.strip
19
+ end
20
+
21
+ def self.save_to_record(uuid, string)
22
+ applescript = <<~APS.strip
23
+ #{AppleScript.intro}
24
+ tell application id "DNtp"
25
+ set theRecord to get record with uuid "#{uuid}"
26
+ set plain text of theRecord to "#{string}"
27
+ end tell
28
+ APS
29
+
30
+ system "osascript -e '#{applescript}'"
31
+ end
32
+
33
+ def self.open(uuid)
34
+ system "open '#{path_to_record(uuid)}'"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pullbox
4
+ VERSION = '0.1.0'
5
+ end
data/lib/pullbox.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'pullbox/version'
4
+
5
+ # Library for several classes
6
+ module Pullbox
7
+ end
data/sig/pullbox.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Pullbox
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pullbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - PuLLi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Enables you to write ruby code for AppleScript and DEVONthink features.
14
+ email:
15
+ - the@pulli.dev
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/pullbox.rb
26
+ - lib/pullbox/applescript.rb
27
+ - lib/pullbox/devonthink.rb
28
+ - lib/pullbox/version.rb
29
+ - sig/pullbox.rbs
30
+ homepage: https://github.com/the-pulli/pullbox
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ allowed_push_host: https://rubygems.org
35
+ homepage_uri: https://github.com/the-pulli/pullbox
36
+ source_code_uri: https://github.com/the-pulli/pullbox
37
+ changelog_uri: https://github.com/the-pulli/pullbox/CHANGELOG.md
38
+ rubygems_mfa_required: 'true'
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.6.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.3.26
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Just a small toolbox for AppleScript and DEVONthink
58
+ test_files: []