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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 719afa93b7a4faddb701be1378360054ee6cc3f8
4
- data.tar.gz: 0b1bcc95053547eb357114164f94f90a0fc4181e
2
+ SHA256:
3
+ metadata.gz: 84d3609bcbf7bd4228608fd4185f899278186039b407ea8afd43b39c6424d851
4
+ data.tar.gz: 232d7de780bd3da50af7ad945dc0db053249d67842c81a59490f4a45b3365815
5
5
  SHA512:
6
- metadata.gz: 5806aa4ccb91ee8ca67666cad3d7ee74e9de5649d58875dc3198d14ad29e89a422a537f4fd13ab47a845476a2f76f6e0fcf612877be3e6bbf6a6f4425cca9015
7
- data.tar.gz: 6e2ad71c81fb861dd07b971c8359a2a9e03d9a94e076aec159580b3be0cb03d5a0ae14c5fcd6fac79524c565356be3a54cb4afbcf82ccd0bc077185f9f5e582a
6
+ metadata.gz: 50c2fe12402815d65da455484ebebdafccc99d7e652d01bf192144b00c38f8024cfc0b2f152d1b21c1509f004cae64adf19108801b5b3bef1b52f082c6faf099
7
+ data.tar.gz: b9700299416ef10d5b5aa0eb39baff1305656d18ed68ee6e2b8c82aebe035425c509f02ee7286f23477ab999e7a6e5a5844d3014829820a625c16560815c56e9
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [linjunpop]
@@ -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
- * Make it possible to run imessage standalone.
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
- * Fixes fail to send messages without attachment. [#3](https://github.com/linjunpop/imessage/issues/3)
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
- * Now imessage can send attachment with `-a`.
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
- * Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
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
- * Implement send iMessage.
37
+ - Implement send iMessage.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Jun Lin
1
+ Copyright (c) 2013-2018 Jun Lin
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,13 +2,18 @@
2
2
 
3
3
  Command line tool to send iMessage.
4
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
-
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 Develier message to these CONTACTS
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
- ## Contributing
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
- 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
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
- 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
+ # 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
- 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")
6
+ RSpec::Core::RakeTask.new(:spec)
13
7
 
14
- f.puts File.read("bin/imessage")
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
- desc "Install standalone script"
22
- task :install => :standalone do
23
- prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
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
- FileUtils.mkdir_p "#{prefix}/bin"
26
- FileUtils.cp "build/imessage", "#{prefix}/bin"
27
- end
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
@@ -0,0 +1,10 @@
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
+ require 'irb'
10
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
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
File without changes
data/imessage.gemspec CHANGED
@@ -1,25 +1,23 @@
1
- # coding: utf-8
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 = "imessage"
6
+ spec.name = 'imessage'
8
7
  spec.version = Imessage::VERSION
9
- spec.authors = ["Jun Lin"]
10
- spec.email = ["linjunpop@gmail.com"]
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.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)/})
19
- spec.require_paths = ["lib"]
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.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", '~> 2.14'
24
- spec.add_development_dependency "pry"
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
@@ -0,0 +1,7 @@
1
+ on run argv
2
+ set toAddress to first item of argv
3
+ set message to second item of argv
4
+ tell application "Messages"
5
+ send message to buddy toAddress of (service 1 whose service type is iMessage)
6
+ end tell
7
+ end run
@@ -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,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
- 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}'`
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module Imessage
2
- VERSION = "0.2.0"
2
+ VERSION = '0.3.2'
3
3
  end
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.0
4
+ version: 0.3.2
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: 2022-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
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: '1.3'
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: '2.14'
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: '2.14'
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
- - ".travis.yml"
53
+ - ".tool-versions"
80
54
  - CHANGELOG.md
81
55
  - Gemfile
82
56
  - LICENSE.txt
83
57
  - README.md
84
58
  - Rakefile
85
- - Rakefile.dev
86
- - bin/imessage
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
- rubyforge_project:
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
@@ -1,6 +0,0 @@
1
- language: ruby
2
- script: "bundle exec rake -f Rakefile.dev"
3
- rvm:
4
- - 2.0.0
5
- - ruby-head
6
-
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
-