imessage 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +1 -1
- data/README.md +14 -6
- data/Rakefile +31 -22
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/{bin → exe}/imessage +0 -0
- data/imessage.gemspec +9 -7
- data/lib/imessage/parser.rb +1 -1
- data/lib/imessage/sender.rb +51 -30
- data/lib/imessage/version.rb +1 -1
- metadata +30 -17
- data/Rakefile.dev +0 -6
- data/spec/spec_helper.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f347abd1cf7c3ed181adce4ce1106fc6ff423a0f
|
4
|
+
data.tar.gz: 0a7021ff287bac344c360bdf038247ae6285fb4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d19e5cd27006f4d2806163a1ed942161da786927311d9daa9b00a99388871dce57c3d01a87fa6fd7de73d0efdf15a797e40b1ae32eaaf333ec506cb61f1c31
|
7
|
+
data.tar.gz: 82aa289b2706f74d2c2318b112c63a1c28828b170c409f7705148ba61ef48c39bb1bc2c4024fd9df23560d5c82f8416660f960d3989935b3889dbf15ca920dfb
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master
|
4
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
|
+
|
5
11
|
## [v0.2.0](https://github.com/linjunpop/imessage/tree/v0.2.0)
|
6
12
|
|
7
13
|
* Make it possible to run imessage standalone.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,12 @@ Command line tool to send iMessage.
|
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
+
### As a Homebrew(http://brew.sh) package
|
13
|
+
|
14
|
+
$ brew install imessage-ruby
|
15
|
+
|
16
|
+
### As a gem
|
17
|
+
|
12
18
|
Add this line to your application's Gemfile:
|
13
19
|
|
14
20
|
gem 'imessage'
|
@@ -29,7 +35,7 @@ Usage: imessage [options]
|
|
29
35
|
Specific options:
|
30
36
|
-t, --text [TEXT] The TEXT to deliver
|
31
37
|
-a, --attachment [ATTACHMENT] Add an attachment
|
32
|
-
-c, --contacts x,y,z
|
38
|
+
-c, --contacts x,y,z Deliver message to these CONTACTS
|
33
39
|
|
34
40
|
Common options:
|
35
41
|
-h, --help Prints this help
|
@@ -44,11 +50,13 @@ $ imessage --text "hello" --contacts "foo@example.com" --attachment 'bar.png'
|
|
44
50
|
|
45
51
|
## [Changelog](CHANGELOG.md)
|
46
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
|
+
|
47
59
|
## Contributing
|
48
60
|
|
49
|
-
|
50
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
-
5. Create new Pull Request
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/linjunpop/imessage.
|
54
62
|
|
data/Rakefile
CHANGED
@@ -1,27 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
mkdir_p "build"
|
4
|
-
File.open("build/imessage", "w") do |f|
|
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
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
8
3
|
|
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")
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
|
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'
|
17
25
|
end
|
18
|
-
sh 'chmod +x build/imessage'
|
19
|
-
end
|
20
26
|
|
21
|
-
desc "Install standalone script"
|
22
|
-
task :install => :
|
23
|
-
|
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
|
24
35
|
|
25
|
-
|
26
|
-
FileUtils.cp "build/imessage", "#{prefix}/bin"
|
27
|
-
end
|
36
|
+
task default: :spec
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
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
ADDED
data/{bin → exe}/imessage
RENAMED
File without changes
|
data/imessage.gemspec
CHANGED
@@ -8,18 +8,20 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Imessage::VERSION
|
9
9
|
spec.authors = ["Jun Lin"]
|
10
10
|
spec.email = ["linjunpop@gmail.com"]
|
11
|
-
|
11
|
+
|
12
12
|
spec.summary = "Command line tool to send iMessage."
|
13
|
+
spec.description = "Command line tool to send iMessage."
|
13
14
|
spec.homepage = "https://github.com/linjunpop/imessage"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
-
spec.
|
18
|
-
spec.
|
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) }
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec", '~>
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", '~> 3.3'
|
24
25
|
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "pry-doc"
|
25
27
|
end
|
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,14 @@
|
|
1
1
|
module Imessage
|
2
2
|
class Sender
|
3
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
|
7
|
+
|
8
|
+
if options[:contacts].empty?
|
9
|
+
raise "You must specific at least one contact"
|
10
|
+
end
|
11
|
+
|
4
12
|
options[:contacts].each do |contact|
|
5
13
|
_deliver(options[:text], options[:attachment], contact)
|
6
14
|
end
|
@@ -9,38 +17,51 @@ module Imessage
|
|
9
17
|
private
|
10
18
|
|
11
19
|
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}'`
|
20
|
+
if text && attachment
|
21
|
+
deliver_text_and_attachment(text, attachment, contact)
|
22
|
+
elsif text
|
23
|
+
deliver_text(text, contact)
|
24
|
+
elsif attachment
|
25
|
+
deliver_attachment(attachment, contact)
|
23
26
|
end
|
27
|
+
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
29
|
+
def deliver_text_and_attachment(text, attachment, contact)
|
30
|
+
deliver_text(text, contact)
|
31
|
+
deliver_attachment(attachment, contact)
|
32
|
+
end
|
33
|
+
|
34
|
+
def deliver_attachment(attachment, contact)
|
35
|
+
script = <<-SCRIPT
|
36
|
+
on run argv
|
37
|
+
set toAddress to first item of argv
|
38
|
+
set theFilePath to second item of argv
|
39
|
+
set theFile to POSIX file theFilePath
|
40
|
+
tell application "System Events"
|
41
|
+
if exists file theFilePath then
|
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}'`
|
52
|
+
end
|
53
|
+
|
54
|
+
def deliver_text(text, contact)
|
55
|
+
script = <<-SCRIPT
|
56
|
+
on run argv
|
57
|
+
set toAddress to first item of argv
|
58
|
+
set message to second item of argv
|
59
|
+
tell application "Messages"
|
60
|
+
send message to buddy toAddress of (service 1 whose service type is iMessage)
|
61
|
+
end tell
|
62
|
+
end run
|
63
|
+
SCRIPT
|
64
|
+
`osascript -e '#{script}' '#{contact}' '#{text}'`
|
44
65
|
end
|
45
66
|
end
|
46
67
|
end
|
data/lib/imessage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imessage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.10'
|
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: '1.
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
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'
|
69
83
|
description: Command line tool to send iMessage.
|
70
84
|
email:
|
71
85
|
- linjunpop@gmail.com
|
@@ -82,14 +96,14 @@ files:
|
|
82
96
|
- LICENSE.txt
|
83
97
|
- README.md
|
84
98
|
- Rakefile
|
85
|
-
-
|
86
|
-
- bin/
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- exe/imessage
|
87
102
|
- imessage.gemspec
|
88
103
|
- lib/imessage.rb
|
89
104
|
- lib/imessage/parser.rb
|
90
105
|
- lib/imessage/sender.rb
|
91
106
|
- lib/imessage/version.rb
|
92
|
-
- spec/spec_helper.rb
|
93
107
|
homepage: https://github.com/linjunpop/imessage
|
94
108
|
licenses:
|
95
109
|
- MIT
|
@@ -110,10 +124,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
124
|
version: '0'
|
111
125
|
requirements: []
|
112
126
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.4.
|
127
|
+
rubygems_version: 2.4.8
|
114
128
|
signing_key:
|
115
129
|
specification_version: 4
|
116
130
|
summary: Command line tool to send iMessage.
|
117
|
-
test_files:
|
118
|
-
- spec/spec_helper.rb
|
131
|
+
test_files: []
|
119
132
|
has_rdoc:
|
data/Rakefile.dev
DELETED
data/spec/spec_helper.rb
DELETED