imessage 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/exe/imessage +4 -4
- data/lib/imessage/apple_scripts/send_attachment.applescript +15 -0
- data/lib/imessage/apple_scripts/send_text.applescript +7 -0
- data/lib/imessage/sender.rb +24 -34
- data/lib/imessage/version.rb +1 -1
- metadata +9 -62
- data/.gitignore +0 -18
- data/.rspec +0 -1
- data/.travis.yml +0 -8
- data/CHANGELOG.md +0 -29
- data/Gemfile +0 -3
- data/LICENSE.txt +0 -22
- data/README.md +0 -62
- data/Rakefile +0 -36
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/imessage.gemspec +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3f558b44d1c0a21dd1d9b00bab2985d2009c292c58c774555e7410080e664f5
|
4
|
+
data.tar.gz: f2432de70abf34c00d85be02ae95f57d2198e8f8c2b953694ddcdf7a5a5c2962
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7a871c5bff7ad01527a274e27c5e2d5aeee399d556dd70f332c66769f6c3f754a8c60c9f8c0e40bfde76405b1fec113d37d4f0933bef26729fa9ec8ba5c58c
|
7
|
+
data.tar.gz: 293a1e548cdd5a35cbdbbb2a2512385bffb6310c137ec2ad350add83c715b0658baaaca08e643e3a473d6291a06938b95c5f8964374f7bd3ab8c2dc3e61662c3
|
data/exe/imessage
CHANGED
@@ -8,7 +8,7 @@ options = Imessage::Parser.parse(ARGV)
|
|
8
8
|
|
9
9
|
sender = Imessage::Sender.new
|
10
10
|
sender.deliver({
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
})
|
11
|
+
text: options.text,
|
12
|
+
attachment: options.attachment,
|
13
|
+
contacts: options.contacts
|
14
|
+
})
|
@@ -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/sender.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Imessage
|
2
4
|
class Sender
|
3
|
-
def deliver(options = {text:nil, attachment:nil, contacts: []})
|
4
|
-
if options[:text].nil? && options[:attachment].nil?
|
5
|
-
raise "You must specific at least a text or attachment."
|
6
|
-
end
|
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
7
|
|
8
|
-
if options[:contacts].empty?
|
9
|
-
raise "You must specific at least one contact"
|
10
|
-
end
|
8
|
+
raise 'You must specific at least one contact' if options[:contacts].empty?
|
11
9
|
|
12
10
|
options[:contacts].each do |contact|
|
13
11
|
_deliver(options[:text], options[:attachment], contact)
|
@@ -32,36 +30,28 @@ module Imessage
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def deliver_attachment(attachment, contact)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
tell application "Messages"
|
43
|
-
send theFile to buddy toAddress of (service 1 whose service type is iMessage)
|
44
|
-
end tell
|
45
|
-
else
|
46
|
-
error "File not exist."
|
47
|
-
end if
|
48
|
-
end tell
|
49
|
-
end run
|
50
|
-
SCRIPT
|
51
|
-
`osascript -e'#{script}' '#{contact}' '#{attachment}'`
|
33
|
+
apple_script_file_path = build_apple_script_file_path('send_attachment')
|
34
|
+
|
35
|
+
cmd = <<~CMD.strip
|
36
|
+
osascript #{apple_script_file_path} "#{contact}" "#{attachment}"
|
37
|
+
CMD
|
38
|
+
|
39
|
+
system cmd
|
52
40
|
end
|
53
41
|
|
54
42
|
def deliver_text(text, contact)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
43
|
+
apple_script_file_path = build_apple_script_file_path('send_text')
|
44
|
+
|
45
|
+
cmd = <<~CMD.strip
|
46
|
+
osascript #{apple_script_file_path} "#{contact}" "#{text}"
|
47
|
+
CMD
|
48
|
+
|
49
|
+
system cmd
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_apple_script_file_path(filename)
|
53
|
+
filepath = File.dirname(Pathname.new(__FILE__).realpath)
|
54
|
+
File.join(filepath, "apple_scripts/#{filename}.applescript")
|
65
55
|
end
|
66
56
|
end
|
67
57
|
end
|
data/lib/imessage/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imessage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.10'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.10'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
19
|
+
version: '13.0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
26
|
+
version: '13.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,35 +38,7 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '3.3'
|
55
|
-
|
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'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-doc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
description: Command line tool to send iMessage.
|
41
|
+
description: A command line tool to send text and attachment in Message.app.
|
84
42
|
email:
|
85
43
|
- linjunpop@gmail.com
|
86
44
|
executables:
|
@@ -88,19 +46,10 @@ executables:
|
|
88
46
|
extensions: []
|
89
47
|
extra_rdoc_files: []
|
90
48
|
files:
|
91
|
-
- ".gitignore"
|
92
|
-
- ".rspec"
|
93
|
-
- ".travis.yml"
|
94
|
-
- CHANGELOG.md
|
95
|
-
- Gemfile
|
96
|
-
- LICENSE.txt
|
97
|
-
- README.md
|
98
|
-
- Rakefile
|
99
|
-
- bin/console
|
100
|
-
- bin/setup
|
101
49
|
- exe/imessage
|
102
|
-
- imessage.gemspec
|
103
50
|
- lib/imessage.rb
|
51
|
+
- lib/imessage/apple_scripts/send_attachment.applescript
|
52
|
+
- lib/imessage/apple_scripts/send_text.applescript
|
104
53
|
- lib/imessage/parser.rb
|
105
54
|
- lib/imessage/sender.rb
|
106
55
|
- lib/imessage/version.rb
|
@@ -123,10 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
72
|
- !ruby/object:Gem::Version
|
124
73
|
version: '0'
|
125
74
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.4.8
|
75
|
+
rubygems_version: 3.0.3.1
|
128
76
|
signing_key:
|
129
77
|
specification_version: 4
|
130
|
-
summary:
|
78
|
+
summary: Send text and attachment in Message.app on macOS.
|
131
79
|
test_files: []
|
132
|
-
has_rdoc:
|
data/.gitignore
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# CHANGELOG
|
2
|
-
|
3
|
-
## master
|
4
|
-
|
5
|
-
## [v0.3.0](https://github.com/linjunpop/imessage/tree/v0.3.0)
|
6
|
-
|
7
|
-
* Raise error if no contacts specified.
|
8
|
-
* Update project structure for better development experience.
|
9
|
-
* Fixes typo in help message [@bfontaine](https://github.com/bfontaine)
|
10
|
-
|
11
|
-
## [v0.2.0](https://github.com/linjunpop/imessage/tree/v0.2.0)
|
12
|
-
|
13
|
-
* Make it possible to run imessage standalone.
|
14
|
-
|
15
|
-
## [v0.1.1](https://github.com/linjunpop/imessage/tree/v0.1.1)
|
16
|
-
|
17
|
-
* Fixes fail to send messages without attachment. [#3](https://github.com/linjunpop/imessage/issues/3)
|
18
|
-
|
19
|
-
## [v0.1.0](https://github.com/linjunpop/imessage/tree/v0.1.0)
|
20
|
-
|
21
|
-
* Now imessage can send attachment with `-a`.
|
22
|
-
|
23
|
-
## [v0.0.2](https://github.com/linjunpop/imessage/tree/v0.0.2)
|
24
|
-
|
25
|
-
* Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
|
26
|
-
|
27
|
-
## [v0.0.1](https://github.com/linjunpop/imessage/tree/v0.0.1)
|
28
|
-
|
29
|
-
* Implement send iMessage.
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2015 Jun Lin
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# imessage
|
2
|
-
|
3
|
-
Command line tool to send iMessage.
|
4
|
-
|
5
|
-
[![Build Status](https://travis-ci.org/linjunpop/imessage.png?branch=master)](https://travis-ci.org/linjunpop/imessage)
|
6
|
-
[![Gem Version](https://badge.fury.io/rb/imessage.png)](http://badge.fury.io/rb/imessage)
|
7
|
-
[![Code Climate](https://codeclimate.com/github/linjunpop/imessage.png)](https://codeclimate.com/github/linjunpop/imessage)
|
8
|
-
|
9
|
-
|
10
|
-
## Installation
|
11
|
-
|
12
|
-
### As a Homebrew(http://brew.sh) package
|
13
|
-
|
14
|
-
$ brew install imessage-ruby
|
15
|
-
|
16
|
-
### As a gem
|
17
|
-
|
18
|
-
Add this line to your application's Gemfile:
|
19
|
-
|
20
|
-
gem 'imessage'
|
21
|
-
|
22
|
-
And then execute:
|
23
|
-
|
24
|
-
$ bundle
|
25
|
-
|
26
|
-
Or install it yourself as:
|
27
|
-
|
28
|
-
$ gem install imessage
|
29
|
-
|
30
|
-
## Usage
|
31
|
-
|
32
|
-
```shell
|
33
|
-
Usage: imessage [options]
|
34
|
-
|
35
|
-
Specific options:
|
36
|
-
-t, --text [TEXT] The TEXT to deliver
|
37
|
-
-a, --attachment [ATTACHMENT] Add an attachment
|
38
|
-
-c, --contacts x,y,z Deliver message to these CONTACTS
|
39
|
-
|
40
|
-
Common options:
|
41
|
-
-h, --help Prints this help
|
42
|
-
--version Show version
|
43
|
-
```
|
44
|
-
|
45
|
-
## Example
|
46
|
-
|
47
|
-
```
|
48
|
-
$ imessage --text "hello" --contacts "foo@example.com" --attachment 'bar.png'
|
49
|
-
```
|
50
|
-
|
51
|
-
## [Changelog](CHANGELOG.md)
|
52
|
-
|
53
|
-
## Development
|
54
|
-
|
55
|
-
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.
|
56
|
-
|
57
|
-
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).
|
58
|
-
|
59
|
-
## Contributing
|
60
|
-
|
61
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/linjunpop/imessage.
|
62
|
-
|
data/Rakefile
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
namespace :standalone do
|
7
|
-
desc "Build standalone version of imessage"
|
8
|
-
task :build do
|
9
|
-
mkdir_p "build"
|
10
|
-
File.open("build/imessage", "w") do |f|
|
11
|
-
f.puts "#!/usr/bin/env ruby"
|
12
|
-
f.puts "# This file is generated from https://github.com/linjunpop/imessage using `rake standalone:build`"
|
13
|
-
f.puts "# any changes will be overwritten."
|
14
|
-
|
15
|
-
f.puts File.read("lib/imessage.rb").gsub(/^require_relative.*\n/, '')
|
16
|
-
f.puts File.read("lib/imessage/version.rb")
|
17
|
-
f.puts File.read("lib/imessage/parser.rb")
|
18
|
-
f.puts File.read("lib/imessage/sender.rb")
|
19
|
-
|
20
|
-
f.puts File.read("exe/imessage")
|
21
|
-
.gsub(/^require_relative.*\n/, '')
|
22
|
-
.gsub(%r{#!/usr/bin/env ruby}, '')
|
23
|
-
end
|
24
|
-
sh 'chmod +x build/imessage'
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "Install standalone script"
|
28
|
-
task :install => :build do
|
29
|
-
prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
|
30
|
-
|
31
|
-
FileUtils.mkdir_p "#{prefix}/bin"
|
32
|
-
FileUtils.cp "build/imessage", "#{prefix}/bin"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
task default: :spec
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "imessage"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
require "pry"
|
11
|
-
Pry.start
|
12
|
-
|
13
|
-
# require "irb"
|
14
|
-
# IRB.start
|
15
|
-
|
data/bin/setup
DELETED
data/imessage.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'imessage/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "imessage"
|
8
|
-
spec.version = Imessage::VERSION
|
9
|
-
spec.authors = ["Jun Lin"]
|
10
|
-
spec.email = ["linjunpop@gmail.com"]
|
11
|
-
|
12
|
-
spec.summary = "Command line tool to send iMessage."
|
13
|
-
spec.description = "Command line tool to send iMessage."
|
14
|
-
spec.homepage = "https://github.com/linjunpop/imessage"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "exe"
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "rspec", '~> 3.3'
|
25
|
-
spec.add_development_dependency "pry"
|
26
|
-
spec.add_development_dependency "pry-doc"
|
27
|
-
end
|