imessage 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 719afa93b7a4faddb701be1378360054ee6cc3f8
4
- data.tar.gz: 0b1bcc95053547eb357114164f94f90a0fc4181e
3
+ metadata.gz: f347abd1cf7c3ed181adce4ce1106fc6ff423a0f
4
+ data.tar.gz: 0a7021ff287bac344c360bdf038247ae6285fb4e
5
5
  SHA512:
6
- metadata.gz: 5806aa4ccb91ee8ca67666cad3d7ee74e9de5649d58875dc3198d14ad29e89a422a537f4fd13ab47a845476a2f76f6e0fcf612877be3e6bbf6a6f4425cca9015
7
- data.tar.gz: 6e2ad71c81fb861dd07b971c8359a2a9e03d9a94e076aec159580b3be0cb03d5a0ae14c5fcd6fac79524c565356be3a54cb4afbcf82ccd0bc077185f9f5e582a
6
+ metadata.gz: 92d19e5cd27006f4d2806163a1ed942161da786927311d9daa9b00a99388871dce57c3d01a87fa6fd7de73d0efdf15a797e40b1ae32eaaf333ec506cb61f1c31
7
+ data.tar.gz: 82aa289b2706f74d2c2318b112c63a1c28828b170c409f7705148ba61ef48c39bb1bc2c4024fd9df23560d5c82f8416660f960d3989935b3889dbf15ca920dfb
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  script: "bundle exec rake -f Rakefile.dev"
3
3
  rvm:
4
+ - 1.9.2
5
+ - 1.9.3
4
6
  - 2.0.0
5
7
  - ruby-head
6
8
 
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Jun Lin
1
+ Copyright (c) 2015 Jun Lin
2
2
 
3
3
  MIT License
4
4
 
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 Develier message to these CONTACTS
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
- 1. Fork it
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
- desc "Build standalone version of imessage"
2
- task :standalone do
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
- f.puts File.read("lib/imessage.rb").gsub(/^require_relative.*\n/, '')
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
- f.puts File.read("bin/imessage")
15
- .gsub(/^require_relative.*\n/, '')
16
- .gsub(%r{#!/usr/bin/env ruby}, '')
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 => :standalone do
23
- prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
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
- FileUtils.mkdir_p "#{prefix}/bin"
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
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
8
+
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
- spec.description = "Command line tool to send iMessage."
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.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
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.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", '~> 2.14'
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
@@ -37,7 +37,7 @@ module Imessage
37
37
  end
38
38
  end
39
39
 
40
- opts.on("-c", "--contacts x,y,z", Array, "Develier message to these CONTACTS") do |contacts|
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
 
@@ -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
- unless text.nil?
13
- script = <<-SCRIPT
14
- on run argv
15
- set toAddress to first item of argv
16
- set message to second item of argv
17
- tell application "Messages"
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
- unless attachment.nil?
26
- script = <<-SCRIPT
27
- on run argv
28
- set toAddress to first item of argv
29
- set theFilePath to second item of argv
30
- set theFile to POSIX file theFilePath
31
- tell application "System Events"
32
- if exists file theFilePath then
33
- tell application "Messages"
34
- send theFile to buddy toAddress of (service 1 whose service type is iMessage)
35
- end tell
36
- else
37
- error "File not exist."
38
- end if
39
- end tell
40
- end run
41
- SCRIPT
42
- `osascript -e'#{script}' '#{contact}' '#{attachment}'`
43
- end
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
@@ -1,3 +1,3 @@
1
1
  module Imessage
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jun Lin
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
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.3'
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.3'
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: '2.14'
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: '2.14'
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
- - Rakefile.dev
86
- - bin/imessage
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.5
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
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/spec/spec_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'rspec/autorun'
2
- require 'imessage'
3
-