ims 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +37 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +39 -0
- data/bin/imsg +14 -0
- data/imsg.gemspec +27 -0
- data/lib/ims/parser.rb +55 -0
- data/lib/ims/sender.rb +57 -0
- data/lib/ims/version.rb +3 -0
- data/lib/ims.rb +6 -0
- data/script/console +14 -0
- data/script/setup +8 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6128c3d6278cd38bf8e84812414171f49e8eb63e
|
4
|
+
data.tar.gz: 94c0362c3ab6c6ca33d051826a94eb8cd703d455
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b98ccbc3c429561c960fc36e30539736319f12f40201d0fe736205ce3331501fb3e6788bb056447f0576167ede01370ce7c43e30f2503fffbac26cfc62c314d
|
7
|
+
data.tar.gz: 57482da3d9651253183ccd899a3074fd728db7a0f0400d3e151d0d14296586fa3b4cb856d7eb229b860582598a0008cabda72c4f7e4ea9d449c083e5e489bbe9
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## master
|
4
|
+
|
5
|
+
## [v0.8.0](https://github.com/lodestone/ims/tree/v0.8.0)
|
6
|
+
|
7
|
+
* Initial revamp and retooling of this code.
|
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
|
+
|
19
|
+
## [v0.2.0](https://github.com/linjunpop/imessage/tree/v0.2.0)
|
20
|
+
|
21
|
+
* Make it possible to run imessage standalone.
|
22
|
+
|
23
|
+
## [v0.1.1](https://github.com/linjunpop/imessage/tree/v0.1.1)
|
24
|
+
|
25
|
+
* Fixes fail to send messages without attachment. [#3](https://github.com/linjunpop/imessage/issues/3)
|
26
|
+
|
27
|
+
## [v0.1.0](https://github.com/linjunpop/imessage/tree/v0.1.0)
|
28
|
+
|
29
|
+
* Now imessage can send attachment with `-a`.
|
30
|
+
|
31
|
+
## [v0.0.2](https://github.com/linjunpop/imessage/tree/v0.0.2)
|
32
|
+
|
33
|
+
* Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
|
34
|
+
|
35
|
+
## [v0.0.1](https://github.com/linjunpop/imessage/tree/v0.0.1)
|
36
|
+
|
37
|
+
* Implement send iMessage.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Matt Petty
|
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
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# imessage
|
2
|
+
|
3
|
+
Command line tool to send iMessage.
|
4
|
+
|
5
|
+
*(This is a fork of https://github.com/linjunpop/imessage)*
|
6
|
+
|
7
|
+
<!--
|
8
|
+
[![Build Status](https://travis-ci.org/linjunpop/imessage.png?branch=master)](https://travis-ci.org/linjunpop/imessage)
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/imessage.png)](http://badge.fury.io/rb/imessage)
|
10
|
+
[![Code Climate](https://codeclimate.com/github/linjunpop/imessage.png)](https://codeclimate.com/github/linjunpop/imessage)
|
11
|
+
-->
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
<!--
|
16
|
+
### As a Homebrew(http://brew.sh) package
|
17
|
+
|
18
|
+
$ brew install imessage-ruby
|
19
|
+
-->
|
20
|
+
|
21
|
+
### As a gem
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
gem 'ims'
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install ims
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
```shell
|
38
|
+
Usage: ims [options]
|
39
|
+
|
40
|
+
Specific options:
|
41
|
+
-m, --message [MESSSAGE|ATTACHMENT] The MESSAGE to deliver
|
42
|
+
-t, --to x,y,z Deliver message TO these contacts
|
43
|
+
|
44
|
+
Common options:
|
45
|
+
-h, --help Prints this help
|
46
|
+
--version Show version
|
47
|
+
```
|
48
|
+
|
49
|
+
## Example
|
50
|
+
|
51
|
+
```
|
52
|
+
$ ims -m "hello" -t "foo@example.com"
|
53
|
+
$ ims --message '/path/to/bar.png' --to "foo@example.com,+15555555555"
|
54
|
+
```
|
55
|
+
|
56
|
+
## [Changelog](CHANGELOG.md)
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lodestone/ims.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
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'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
end
|
10
|
+
|
11
|
+
# namespace :standalone do
|
12
|
+
# desc "Build standalone version of imessage"
|
13
|
+
# task :build do
|
14
|
+
# mkdir_p "build"
|
15
|
+
# File.open("build/imsg", "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
|
31
|
+
#
|
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/imsg
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/imsg'
|
4
|
+
|
5
|
+
ARGV << '--help' if ARGV.empty?
|
6
|
+
|
7
|
+
options = Imsg::Parser.parse(ARGV)
|
8
|
+
|
9
|
+
sender = Imsg::Sender.new
|
10
|
+
sender.deliver({
|
11
|
+
text: options.text,
|
12
|
+
attachment: options.attachment,
|
13
|
+
contacts: options.contacts
|
14
|
+
})
|
data/imsg.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ims/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ims"
|
8
|
+
spec.version = Ims::VERSION
|
9
|
+
spec.authors = ["Matt Petty"]
|
10
|
+
spec.email = ["matt@kizmeta.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/lodestone/ims"
|
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 = "bin"
|
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
|
data/lib/ims/parser.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Ims
|
5
|
+
class Parser
|
6
|
+
class << self
|
7
|
+
def parse(options)
|
8
|
+
OpenStruct.new.tap do |args|
|
9
|
+
args.contacts = []
|
10
|
+
args.text = nil
|
11
|
+
args.attachment = nil
|
12
|
+
args.verbose = false
|
13
|
+
|
14
|
+
opt_parser(args).parse!(options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def opt_parser(args)
|
21
|
+
OptionParser.new do |opts|
|
22
|
+
opts.banner = "Usage: ims [options]"
|
23
|
+
|
24
|
+
opts.separator ""
|
25
|
+
opts.separator "Specific options:"
|
26
|
+
|
27
|
+
opts.on("-t", "--to x,y,z", Array, "Deliver message TO these contacts") do |contacts|
|
28
|
+
args.contacts = contacts
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-m", "--message [MESSAGE]", String, "The MESSAGE to deliver") do |mesg|
|
32
|
+
if File.exists?(mesg)
|
33
|
+
args.attachment = File.expand_path(mesg)
|
34
|
+
else
|
35
|
+
args.text = mesg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.separator ""
|
40
|
+
opts.separator "Common options:"
|
41
|
+
|
42
|
+
opts.on("-v", "--version", "Show version") do
|
43
|
+
puts "ims v#{Imsg::VERSION}"
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("-h", "--help", "Prints this help") do
|
48
|
+
puts opts
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/ims/sender.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module Ims
|
2
|
+
class Sender
|
3
|
+
def deliver(options = {text:nil, attachment:nil, contacts: []})
|
4
|
+
if options[:text].nil? && options[:attachment].nil?
|
5
|
+
raise "You must specific a message, either a text or file attachment."
|
6
|
+
end
|
7
|
+
|
8
|
+
if options[:contacts].empty?
|
9
|
+
raise "You must specific at least one contact"
|
10
|
+
end
|
11
|
+
|
12
|
+
options[:contacts].each do |contact|
|
13
|
+
_deliver(options[:text], options[:attachment], contact)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def _deliver(text, attachment, contact)
|
20
|
+
deliver_text(text, contact) if text
|
21
|
+
deliver_attachment(attachment, contact) if attachment
|
22
|
+
end
|
23
|
+
|
24
|
+
def deliver_attachment(attachment, contact)
|
25
|
+
script = <<-SCRIPT
|
26
|
+
on run argv
|
27
|
+
set toAddress to first item of argv
|
28
|
+
set theFilePath to second item of argv
|
29
|
+
set theFile to POSIX file theFilePath
|
30
|
+
tell application "System Events"
|
31
|
+
if exists file theFilePath then
|
32
|
+
tell application "Messages"
|
33
|
+
send theFile to buddy toAddress of (service 1 whose service type is iMessage)
|
34
|
+
end tell
|
35
|
+
else
|
36
|
+
error "File not exist."
|
37
|
+
end if
|
38
|
+
end tell
|
39
|
+
end run
|
40
|
+
SCRIPT
|
41
|
+
`osascript -e'#{script}' '#{contact}' '#{attachment}'`
|
42
|
+
end
|
43
|
+
|
44
|
+
def deliver_text(text, contact)
|
45
|
+
script = <<-SCRIPT
|
46
|
+
on run argv
|
47
|
+
set toAddress to first item of argv
|
48
|
+
set message to second item of argv
|
49
|
+
tell application "Messages"
|
50
|
+
send message to buddy toAddress of (service 1 whose service type is iMessage)
|
51
|
+
end tell
|
52
|
+
end run
|
53
|
+
SCRIPT
|
54
|
+
`osascript -e '#{script}' '#{contact}' '#{text}'`
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/ims/version.rb
ADDED
data/lib/ims.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ims"
|
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
|
data/script/setup
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ims
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Petty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
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'
|
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.
|
84
|
+
email:
|
85
|
+
- matt@kizmeta.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/imsg
|
99
|
+
- imsg.gemspec
|
100
|
+
- lib/ims.rb
|
101
|
+
- lib/ims/parser.rb
|
102
|
+
- lib/ims/sender.rb
|
103
|
+
- lib/ims/version.rb
|
104
|
+
- script/console
|
105
|
+
- script/setup
|
106
|
+
homepage: https://github.com/lodestone/ims
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.5.0
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Command line tool to send iMessage.
|
130
|
+
test_files: []
|
131
|
+
has_rdoc:
|