imessage 0.0.2 → 0.1.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: f6cf5426042fec1c49faecd4ea46b6404ef29349
4
- data.tar.gz: eb55547a8b3358406170c98af0d438555d6dd383
3
+ metadata.gz: c4fa9051a3ac20744feaf5430e2630d587d80964
4
+ data.tar.gz: 8aaafb2a16d83a42838ea369f61b717a6deed0a8
5
5
  SHA512:
6
- metadata.gz: 32043fc2f745498153959bcd28557555cb50bd59c1831835b860543f56c4876e9a311723cde19b0bb652186220b6372d7b44bf30006c82564a0fb3baa2bcf2fe
7
- data.tar.gz: 4e74da22f25c00703c45005a6c2c00798890713ebb644a411664ebdb44c451e18572187bc9122c87564681e4cb794e7f3b3e518675a8c0f8b25c21015ee10329
6
+ metadata.gz: b00e4d7697dde2ff635ae8b54fa10c233363100f756ca24d724b63552e955dc07661a19468ab364ec6761234b171f37db189341743c5943ca082b1333be110cf
7
+ data.tar.gz: f1e1b8e0db34eaf7e3e0fc9904cf3a0a29f52639d960b91b47b2df31833202d492a575ba788873bcf9334a9b1c000b063cd95f5e6a6ffd9f4e91022f3bff5cd7
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## [v0.1.0](https://github.com/linjunpop/imessage/tree/v0.1.0)
6
+
7
+ * Now imessage can send attachment with `-a`.
8
+
5
9
  ## [v0.0.2](https://github.com/linjunpop/imessage/tree/v0.0.2)
6
10
 
7
11
  * Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
@@ -10,19 +10,29 @@ version Imessage::VERSION
10
10
 
11
11
  desc 'Send iMessage'
12
12
  long_desc <<-EOS
13
- Example: $ imessage send "hello" --to "foo@example.com"
13
+ Example: $ imessage send "hello" --to "foo@example.com" --attachment 'oh.png'
14
14
  EOS
15
15
 
16
16
  command :send do |c|
17
17
  c.desc 'Contacts'
18
18
  c.flag [:to, :contacts], type: Array
19
+ c.flag [:a, :attachment], type: String
19
20
 
20
21
  c.action do |global_options, options, args|
21
- help_now!('Message is required') if args.empty?
22
+ help_now!('Message or Attachment is required') if !options[:attachment] && args.empty?
22
23
  help_now!('Contacts is required') unless options[:contacts]
23
24
 
24
- Imessage::Sender.send(
25
- message: args.first,
25
+ attachment = options[:attachment]
26
+ if File.exists?(attachment)
27
+ attachment = File.expand_path(attachment)
28
+ else
29
+ exit_now!("Can not find file #{attachment}")
30
+ end
31
+
32
+ sender = Imessage::Sender.new
33
+ sender.deliver(
34
+ text: args.first,
35
+ attachment: attachment,
26
36
  contacts: options[:contacts]
27
37
  )
28
38
  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
@@ -1,9 +1,24 @@
1
1
  module Imessage
2
2
  class Sender
3
- def self.send(options = {message:'', contacts: []})
3
+ TYPES = [:text, :attachment]
4
+
5
+ def deliver(options = {text:nil, attachment:nil, contacts: []})
4
6
  options[:contacts].each do |contact|
5
- apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_imessage.applescript')
6
- `osascript #{apple_script_file} '#{contact}' '#{options[:message]}'`
7
+ _deliver(options[:text], options[:attachment], contact)
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def _deliver(text, attachment, contact)
14
+ unless text.nil?
15
+ apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_text.applescript')
16
+ `osascript #{apple_script_file} '#{contact}' '#{text}'`
17
+ end
18
+
19
+ unless attachment.nil?
20
+ apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_attachment.applescript')
21
+ `osascript #{apple_script_file} '#{contact}' '#{attachment}'`
7
22
  end
8
23
  end
9
24
  end
@@ -1,3 +1,3 @@
1
1
  module Imessage
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.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.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jun Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,7 +85,8 @@ files:
85
85
  - bin/imessage
86
86
  - imessage.gemspec
87
87
  - lib/imessage.rb
88
- - lib/imessage/scripts/send_imessage.applescript
88
+ - lib/imessage/scripts/send_attachment.applescript
89
+ - lib/imessage/scripts/send_text.applescript
89
90
  - lib/imessage/sender.rb
90
91
  - lib/imessage/version.rb
91
92
  - spec/spec_helper.rb
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.2.2
113
+ rubygems_version: 2.4.6
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: Command line tool to send iMessage.