imessage 0.2.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/test.yml +28 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +19 -5
- data/LICENSE.txt +1 -1
- data/README.md +17 -11
- data/Rakefile +34 -22
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/{bin → exe}/imessage +0 -0
- data/imessage.gemspec +15 -17
- data/lib/imessage/apple_scripts/send_attachment.applescript +15 -0
- data/lib/imessage/apple_scripts/send_text.applescript +7 -0
- data/lib/imessage/parser.rb +1 -1
- data/lib/imessage/sender.rb +39 -31
- data/lib/imessage/version.rb +1 -1
- metadata +18 -45
- data/.travis.yml +0 -6
- data/Rakefile.dev +0 -6
- data/spec/spec_helper.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84d3609bcbf7bd4228608fd4185f899278186039b407ea8afd43b39c6424d851
|
4
|
+
data.tar.gz: 232d7de780bd3da50af7ad945dc0db053249d67842c81a59490f4a45b3365815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50c2fe12402815d65da455484ebebdafccc99d7e652d01bf192144b00c38f8024cfc0b2f152d1b21c1509f004cae64adf19108801b5b3bef1b52f082c6faf099
|
7
|
+
data.tar.gz: b9700299416ef10d5b5aa0eb39baff1305656d18ed68ee6e2b8c82aebe035425c509f02ee7286f23477ab999e7a6e5a5844d3014829820a625c16560815c56e9
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: macos-latest
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby-version: ['2.3', '2.4', '2.6', '2.7', '3.0']
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake spec
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.6.9
|
data/CHANGELOG.md
CHANGED
@@ -2,22 +2,36 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## [v0.3.2](https://github.com/linjunpop/imessage/tree/v0.3.2)
|
6
|
+
|
7
|
+
- Fixes Unable to send the single quote(') in message body. [#13](https://github.com/linjunpop/imessage/issues/13)
|
8
|
+
|
9
|
+
## [v0.3.1](https://github.com/linjunpop/imessage/tree/v0.3.1)
|
10
|
+
|
11
|
+
- Skip dev tasks when being installed by Homebrew
|
12
|
+
|
13
|
+
## [v0.3.0](https://github.com/linjunpop/imessage/tree/v0.3.0)
|
14
|
+
|
15
|
+
- Raise error if no contacts specified.
|
16
|
+
- Update project structure for better development experience.
|
17
|
+
- Fixes typo in help message [@bfontaine](https://github.com/bfontaine)
|
18
|
+
|
5
19
|
## [v0.2.0](https://github.com/linjunpop/imessage/tree/v0.2.0)
|
6
20
|
|
7
|
-
|
21
|
+
- Make it possible to run imessage standalone.
|
8
22
|
|
9
23
|
## [v0.1.1](https://github.com/linjunpop/imessage/tree/v0.1.1)
|
10
24
|
|
11
|
-
|
25
|
+
- Fixes fail to send messages without attachment. [#3](https://github.com/linjunpop/imessage/issues/3)
|
12
26
|
|
13
27
|
## [v0.1.0](https://github.com/linjunpop/imessage/tree/v0.1.0)
|
14
28
|
|
15
|
-
|
29
|
+
- Now imessage can send attachment with `-a`.
|
16
30
|
|
17
31
|
## [v0.0.2](https://github.com/linjunpop/imessage/tree/v0.0.2)
|
18
32
|
|
19
|
-
|
33
|
+
- Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
|
20
34
|
|
21
35
|
## [v0.0.1](https://github.com/linjunpop/imessage/tree/v0.0.1)
|
22
36
|
|
23
|
-
|
37
|
+
- Implement send iMessage.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,13 +2,18 @@
|
|
2
2
|
|
3
3
|
Command line tool to send iMessage.
|
4
4
|
|
5
|
-
|
6
|
-
[![Gem Version](https://
|
7
|
-
[![
|
8
|
-
|
5
|
+
![Tests](https://github.com/linjunpop/imessage/actions/workflows/test.yml/badge.svg)
|
6
|
+
[![Gem Version](https://img.shields.io/gem/v/imessage.svg)](https://rubygems.org/gems/imessage)
|
7
|
+
[![codebeat badge](https://codebeat.co/badges/69f6f8ee-8ddd-4355-aa7c-0cd4ac369718)](https://codebeat.co/projects/github-com-linjunpop-imessage-master)
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
11
|
+
### As a Homebrew(http://brew.sh) package
|
12
|
+
|
13
|
+
$ brew install imessage-ruby
|
14
|
+
|
15
|
+
### As a gem
|
16
|
+
|
12
17
|
Add this line to your application's Gemfile:
|
13
18
|
|
14
19
|
gem 'imessage'
|
@@ -29,7 +34,7 @@ Usage: imessage [options]
|
|
29
34
|
Specific options:
|
30
35
|
-t, --text [TEXT] The TEXT to deliver
|
31
36
|
-a, --attachment [ATTACHMENT] Add an attachment
|
32
|
-
-c, --contacts x,y,z
|
37
|
+
-c, --contacts x,y,z Deliver message to these CONTACTS
|
33
38
|
|
34
39
|
Common options:
|
35
40
|
-h, --help Prints this help
|
@@ -44,11 +49,12 @@ $ imessage --text "hello" --contacts "foo@example.com" --attachment 'bar.png'
|
|
44
49
|
|
45
50
|
## [Changelog](CHANGELOG.md)
|
46
51
|
|
47
|
-
##
|
52
|
+
## Development
|
53
|
+
|
54
|
+
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.
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
-
5. Create new Pull Request
|
56
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
54
59
|
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/linjunpop/imessage.
|
data/Rakefile
CHANGED
@@ -1,27 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
f.puts "#!/usr/bin/env ruby"
|
6
|
-
f.puts "# This file is generated from https://github.com/linjunpop/imessage using `rake standalone`"
|
7
|
-
f.puts "# any changes will be overwritten."
|
1
|
+
# Skip these tasks when being installed by Homebrew
|
2
|
+
unless ENV['HOMEBREW_BREW_FILE']
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require 'rspec/core/rake_task'
|
8
5
|
|
9
|
-
|
10
|
-
f.puts File.read("lib/imessage/version.rb")
|
11
|
-
f.puts File.read("lib/imessage/parser.rb")
|
12
|
-
f.puts File.read("lib/imessage/sender.rb")
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
7
|
|
14
|
-
|
15
|
-
.gsub(/^require_relative.*\n/, '')
|
16
|
-
.gsub(%r{#!/usr/bin/env ruby}, '')
|
17
|
-
end
|
18
|
-
sh 'chmod +x build/imessage'
|
8
|
+
task :default => :spec
|
19
9
|
end
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
namespace :standalone do
|
12
|
+
desc "Build standalone version of imessage"
|
13
|
+
task :build do
|
14
|
+
mkdir_p "build"
|
15
|
+
File.open("build/imessage", "w") do |f|
|
16
|
+
f.puts "#!/usr/bin/env ruby"
|
17
|
+
f.puts "# This file is generated from https://github.com/linjunpop/imessage using `rake standalone:build`"
|
18
|
+
f.puts "# any changes will be overwritten."
|
19
|
+
|
20
|
+
f.puts File.read("lib/imessage.rb").gsub(/^require_relative.*\n/, '')
|
21
|
+
f.puts File.read("lib/imessage/version.rb")
|
22
|
+
f.puts File.read("lib/imessage/parser.rb")
|
23
|
+
f.puts File.read("lib/imessage/sender.rb")
|
24
|
+
|
25
|
+
f.puts File.read("exe/imessage")
|
26
|
+
.gsub(/^require_relative.*\n/, '')
|
27
|
+
.gsub(%r{#!/usr/bin/env ruby}, '')
|
28
|
+
end
|
29
|
+
sh 'chmod +x build/imessage'
|
30
|
+
end
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
32
|
+
desc "Install standalone script"
|
33
|
+
task :install => :build do
|
34
|
+
prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
|
35
|
+
|
36
|
+
FileUtils.mkdir_p "#{prefix}/bin"
|
37
|
+
FileUtils.cp "build/imessage", "#{prefix}/bin"
|
38
|
+
end
|
39
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/{bin → exe}/imessage
RENAMED
File without changes
|
data/imessage.gemspec
CHANGED
@@ -1,25 +1,23 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'imessage/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'imessage'
|
8
7
|
spec.version = Imessage::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description = "Command line tool to send iMessage."
|
12
|
-
spec.summary = "Command line tool to send iMessage."
|
13
|
-
spec.homepage = "https://github.com/linjunpop/imessage"
|
14
|
-
spec.license = "MIT"
|
8
|
+
spec.authors = ['Jun Lin']
|
9
|
+
spec.email = ['linjunpop@gmail.com']
|
15
10
|
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.
|
11
|
+
spec.summary = 'Command line tool to send iMessage.'
|
12
|
+
spec.description = 'Command line tool to send iMessage.'
|
13
|
+
spec.homepage = 'https://github.com/linjunpop/imessage'
|
14
|
+
spec.license = 'MIT'
|
20
15
|
|
21
|
-
spec.
|
22
|
-
spec.
|
23
|
-
spec.
|
24
|
-
spec.
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
25
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
on run argv
|
2
|
+
set toAddress to first item of argv
|
3
|
+
set theFilePath to second item of argv
|
4
|
+
set theFile to POSIX file theFilePath
|
5
|
+
|
6
|
+
tell application "System Events"
|
7
|
+
if exists file theFilePath then
|
8
|
+
tell application "Messages"
|
9
|
+
send theFile to buddy toAddress of (service 1 whose service type is iMessage)
|
10
|
+
end tell
|
11
|
+
else
|
12
|
+
error "File not exist."
|
13
|
+
end if
|
14
|
+
end tell
|
15
|
+
end run
|
data/lib/imessage/parser.rb
CHANGED
@@ -37,7 +37,7 @@ module Imessage
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
opts.on("-c", "--contacts x,y,z", Array, "
|
40
|
+
opts.on("-c", "--contacts x,y,z", Array, "Deliver message to these CONTACTS") do |contacts|
|
41
41
|
args.contacts = contacts
|
42
42
|
end
|
43
43
|
|
data/lib/imessage/sender.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module Imessage
|
2
4
|
class Sender
|
3
|
-
def deliver(options = {text:nil, attachment:nil, contacts: []})
|
5
|
+
def deliver(options = { text: nil, attachment: nil, contacts: [] })
|
6
|
+
raise 'You must specific at least a text or attachment.' if options[:text].nil? && options[:attachment].nil?
|
7
|
+
|
8
|
+
raise 'You must specific at least one contact' if options[:contacts].empty?
|
9
|
+
|
4
10
|
options[:contacts].each do |contact|
|
5
11
|
_deliver(options[:text], options[:attachment], contact)
|
6
12
|
end
|
@@ -9,38 +15,40 @@ module Imessage
|
|
9
15
|
private
|
10
16
|
|
11
17
|
def _deliver(text, attachment, contact)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
send message to buddy toAddress of (service 1 whose service type is iMessage)
|
19
|
-
end tell
|
20
|
-
end run
|
21
|
-
SCRIPT
|
22
|
-
`osascript -e '#{script}' '#{contact}' '#{text}'`
|
18
|
+
if text && attachment
|
19
|
+
deliver_text_and_attachment(text, attachment, contact)
|
20
|
+
elsif text
|
21
|
+
deliver_text(text, contact)
|
22
|
+
elsif attachment
|
23
|
+
deliver_attachment(attachment, contact)
|
23
24
|
end
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
def deliver_text_and_attachment(text, attachment, contact)
|
28
|
+
deliver_text(text, contact)
|
29
|
+
deliver_attachment(attachment, contact)
|
30
|
+
end
|
31
|
+
|
32
|
+
def deliver_attachment(attachment, contact)
|
33
|
+
apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_attachment.applescript')
|
34
|
+
|
35
|
+
cmd = <<~CMD.strip
|
36
|
+
osascript #{apple_script_file} "#{contact}" "#{attachment}"
|
37
|
+
CMD
|
38
|
+
|
39
|
+
system cmd
|
40
|
+
end
|
41
|
+
|
42
|
+
def deliver_text(text, contact)
|
43
|
+
apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'apple_scripts/send_text.applescript')
|
44
|
+
|
45
|
+
cmd = <<~CMD.strip
|
46
|
+
osascript #{apple_script_file} "#{contact}" "#{text}"
|
47
|
+
CMD
|
48
|
+
|
49
|
+
puts cmd
|
50
|
+
|
51
|
+
system cmd
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
data/lib/imessage/version.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imessage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Lin
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '13.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: '13.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '3.3'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
40
|
+
version: '3.3'
|
69
41
|
description: Command line tool to send iMessage.
|
70
42
|
email:
|
71
43
|
- linjunpop@gmail.com
|
@@ -74,22 +46,26 @@ executables:
|
|
74
46
|
extensions: []
|
75
47
|
extra_rdoc_files: []
|
76
48
|
files:
|
49
|
+
- ".github/FUNDING.yml"
|
50
|
+
- ".github/workflows/test.yml"
|
77
51
|
- ".gitignore"
|
78
52
|
- ".rspec"
|
79
|
-
- ".
|
53
|
+
- ".tool-versions"
|
80
54
|
- CHANGELOG.md
|
81
55
|
- Gemfile
|
82
56
|
- LICENSE.txt
|
83
57
|
- README.md
|
84
58
|
- Rakefile
|
85
|
-
-
|
86
|
-
- bin/
|
59
|
+
- bin/console
|
60
|
+
- bin/setup
|
61
|
+
- exe/imessage
|
87
62
|
- imessage.gemspec
|
88
63
|
- lib/imessage.rb
|
64
|
+
- lib/imessage/apple_scripts/send_attachment.applescript
|
65
|
+
- lib/imessage/apple_scripts/send_text.applescript
|
89
66
|
- lib/imessage/parser.rb
|
90
67
|
- lib/imessage/sender.rb
|
91
68
|
- lib/imessage/version.rb
|
92
|
-
- spec/spec_helper.rb
|
93
69
|
homepage: https://github.com/linjunpop/imessage
|
94
70
|
licenses:
|
95
71
|
- MIT
|
@@ -109,11 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
85
|
- !ruby/object:Gem::Version
|
110
86
|
version: '0'
|
111
87
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.4.5
|
88
|
+
rubygems_version: 3.0.3.1
|
114
89
|
signing_key:
|
115
90
|
specification_version: 4
|
116
91
|
summary: Command line tool to send iMessage.
|
117
|
-
test_files:
|
118
|
-
- spec/spec_helper.rb
|
119
|
-
has_rdoc:
|
92
|
+
test_files: []
|
data/.travis.yml
DELETED
data/Rakefile.dev
DELETED
data/spec/spec_helper.rb
DELETED