send2mac 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -0
- data/README.md +27 -0
- data/Rakefile +15 -0
- data/bin/send2mac-client +11 -0
- data/lib/send2mac/listener.rb +26 -0
- data/lib/send2mac/runner.rb +37 -0
- data/lib/send2mac/version.rb +3 -0
- data/lib/send2mac.rb +5 -0
- data/send2mac.gemspec +25 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a4dec491d9fcedffcdcc8351b59bc9d56f8ec03
|
4
|
+
data.tar.gz: ecbf10b39735fbaccf0e23909541259c78a67eda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e7cf3303377b4f350ee0efffbde0389280633ec992f5df99ae30c7e3e72a47ab9888224f4a00440137562f47eb9cccc0b84ddd997f4e29417816c2204374966e
|
7
|
+
data.tar.gz: 3a700316400ec9fe7e800a38c4a1984ed71dcbe995da4c85af70c1e45051f4450782339c8c92db7ba81246ae89c062f17427cc72fa09e18098b737becd7d13ab
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.pid
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p0
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Send2Mac Client Ruby
|
2
|
+
|
3
|
+
## Synopsis
|
4
|
+
|
5
|
+
A simple [Send2Mac][0925-001] client written in Ruby. When links are received, it opens them in the default browser using [Launchy][0925-002].
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
$ send2mac start
|
10
|
+
$ send2mac restart
|
11
|
+
$ send2mac stop
|
12
|
+
|
13
|
+
## Motivation
|
14
|
+
|
15
|
+
The official Send2Mac client is written in AppleScript using a curl loop. I figured I could rewrite it in Ruby very quickly. My intention is to build upon the script to enable actions and commands, possibly chaining multiple Send2Mac API Keys together. This is pretty much a baseline for a whole lot of tinkering.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
`gem install send3mac`
|
20
|
+
|
21
|
+
## License
|
22
|
+
|
23
|
+
Licensed under the [MIT License][0925-004]
|
24
|
+
[0925-001]: http://www.send2mac.com/ "Send2Mac"
|
25
|
+
[0925-002]: https://github.com/copiousfreetime/launchy "copiousfreetime/launchy · GitHub"
|
26
|
+
[0925-003]: http://www.send2mac.com/send2mac/index.php "Send2Mac"
|
27
|
+
[0925-004]: http://opensource.org/licenses/MIT "The MIT License (MIT) | Open Source Initiative"
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'yaml'
|
3
|
+
task :init do
|
4
|
+
say("\nPlease enter your Send2Mac API Key")
|
5
|
+
puts ""
|
6
|
+
key = ask("API Key: ")
|
7
|
+
this = {api_key: key.to_s}
|
8
|
+
puts this.to_yaml
|
9
|
+
dir = %x{mkdir -p config} rescue false
|
10
|
+
|
11
|
+
config_path = File.expand_path("../config/api_key.yml", __FILE__)
|
12
|
+
File.open(config_path, "w") do |f|
|
13
|
+
f.write(this.to_yaml)
|
14
|
+
end
|
15
|
+
end
|
data/bin/send2mac-client
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require_relative '../lib/send2mac.rb'
|
4
|
+
require 'daemons'
|
5
|
+
config_path = "#{ENV['HOME']}/.send2mac"
|
6
|
+
app = Send2MacClient::Runner.new
|
7
|
+
File.file?(config_path) ? true : app.setup_api_key
|
8
|
+
|
9
|
+
Daemons.run_proc('runner.rb') do
|
10
|
+
app.run
|
11
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'launchy'
|
3
|
+
|
4
|
+
module Send2MacClient
|
5
|
+
class Listener
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@agent = Mechanize.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def listen
|
12
|
+
puts "Listening..."
|
13
|
+
loop do
|
14
|
+
url = @agent.get("http://send2mac.com/get.php?APIKey=#{$api_key}").parser.xpath("//html/body/p").text
|
15
|
+
unless (url =~ /\/\//).nil?
|
16
|
+
url = url.gsub(/\r/,"")
|
17
|
+
url = url.gsub(/\n/,"")
|
18
|
+
puts url
|
19
|
+
Launchy.open url.to_s
|
20
|
+
else
|
21
|
+
sleep 2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'launchy'
|
3
|
+
require 'yaml'
|
4
|
+
require 'highline/import'
|
5
|
+
|
6
|
+
module Send2MacClient
|
7
|
+
class Runner
|
8
|
+
attr_accessor :client
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
File.file?(config_path) ? @config = YAML.load_file(config_path) : setup_api_key
|
12
|
+
$api_key = @config[:api_key]
|
13
|
+
@client = Listener.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def config_path
|
17
|
+
File.expand_path("#{ENV['HOME']}/.send2mac", __FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_api_key
|
21
|
+
say("\nPlease enter your Send2Mac API Key")
|
22
|
+
puts ""
|
23
|
+
key = ask("API Key: ")
|
24
|
+
this = {api_key: key.to_s}
|
25
|
+
File.open(config_path, "w") do |f|
|
26
|
+
f.write(this.to_yaml)
|
27
|
+
end
|
28
|
+
@config = YAML.load_file(config_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
client.listen
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/send2mac.rb
ADDED
data/send2mac.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'send2mac/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "send2mac"
|
8
|
+
spec.version = Send2MacClient::VERSION
|
9
|
+
spec.authors = ["Nick Prokesch"]
|
10
|
+
spec.email = ["nick@prokes.ch"]
|
11
|
+
spec.summary = %q{a ruby client for Send2Mac}
|
12
|
+
spec.description = %q{A client for Send2Mac. Automatically launches received URLs in the default browser}
|
13
|
+
spec.homepage = "https://github.com/prokizzle/send2mac-client-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
spec.bindir = 'bin'
|
19
|
+
spec.executables << 'send2mac-client'
|
20
|
+
|
21
|
+
spec.add_dependency "launchy", "~> 2.3"
|
22
|
+
spec.add_dependency "mechanize", "~> 2.7"
|
23
|
+
spec.add_dependency "daemons", "~> 1.1"
|
24
|
+
spec.add_dependency "highline", "~> 1.6"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: send2mac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.9'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Prokesch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: launchy
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mechanize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: daemons
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
description: A client for Send2Mac. Automatically launches received URLs in the default
|
70
|
+
browser
|
71
|
+
email:
|
72
|
+
- nick@prokes.ch
|
73
|
+
executables:
|
74
|
+
- send2mac-client
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".ruby-version"
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/send2mac-client
|
84
|
+
- lib/send2mac.rb
|
85
|
+
- lib/send2mac/listener.rb
|
86
|
+
- lib/send2mac/runner.rb
|
87
|
+
- lib/send2mac/version.rb
|
88
|
+
- send2mac.gemspec
|
89
|
+
homepage: https://github.com/prokizzle/send2mac-client-ruby
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: a ruby client for Send2Mac
|
113
|
+
test_files: []
|