controlio 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2decd01fc4b6db84d0855e447638883230f76888
4
- data.tar.gz: 912360f620adc5af2c511ef0d7caa802659c375d
3
+ metadata.gz: 3d8973dbe79ebc59b14c1eecd0e71053ed5363d7
4
+ data.tar.gz: f9d61d52b7188af909b38e56a010cb45588c2580
5
5
  SHA512:
6
- metadata.gz: e04a064a71468730f2a6a87289a222f62426cba1c34f8122f7d60a90951dc1e70959ed293822ea87f47bdd45680b4157ece2e8e4ce4e70770a5231b977c8ac7d
7
- data.tar.gz: c7adb4ef75f1a0642260dde20a380153ac6cc9d1616d72f049d4ee3bfba23f87c81577c1cdde5260ced0a325d2abd50c1592d141abace4142a410e6eb66bda69
6
+ metadata.gz: 81a2fa84046aa86587ee1a2a4c81dfbb08e9075e2d879d2fb45441edb626ce2f16cfa6746541f5a868196a716b4007881f5f083b7688169ee16dcad375041650
7
+ data.tar.gz: 2facf1e92d73edb5c376c872574c3da25b36ce4fd1ab699f1f97e41467f31e9fdc02c28502eb7d3c89f4dd8e17842118fbdbd8780a2ee1d7a3019d47fb4fa358
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- controlio (0.0.7)
4
+ controlio (0.0.8)
5
5
  activesupport (~> 4.1.6)
6
6
  rest_client (~> 1.7.3)
7
7
 
@@ -1,16 +1,17 @@
1
1
  require 'rest_client'
2
+ require 'tempfile'
2
3
 
3
4
  module Commands
4
5
  class Picture
5
- FILE_LOCATION = "/tmp/tmp.jpg"
6
6
 
7
7
  def initialize(args, settings)
8
8
  @api_root = settings.get('api_root')
9
+ @file = Tempfile.new(['picture', '.jpg'])
9
10
  end
10
11
 
11
12
  def go
12
- `#{File.expand_path("#{File.dirname(__FILE__)}/../../sbin/controlio-imagesnap")} -q #{FILE_LOCATION}`
13
- response = RestClient.post "#{@api_root}/upload", file: File.new(FILE_LOCATION, 'rb')
13
+ `#{File.expand_path("#{File.dirname(__FILE__)}/../../sbin/controlio-imagesnap")} -q #{@file.path}`
14
+ response = RestClient.post "#{@api_root}/upload", file: File.new(@file.path, 'rb')
14
15
  @url = JSON.load(response)['url']
15
16
  end
16
17
 
@@ -8,12 +8,12 @@ module Commands
8
8
 
9
9
  def go
10
10
  `osascript -e 'tell application "#{@app}" to launch'`
11
- sleep 1
11
+ sleep 1.5
12
12
  `osascript -e 'tell application "#{@app}" to play'`
13
13
  end
14
14
 
15
15
  def respond
16
- puts @app
16
+ sleep 5
17
17
  "Now playing: #{`osascript -e 'tell application "#{@app}" to get the name of the current track'`}".chomp rescue ""
18
18
  end
19
19
 
@@ -1,16 +1,17 @@
1
1
  require 'rest_client'
2
+ require 'tempfile'
2
3
 
3
4
  module Commands
4
5
  class Screenshot
5
- FILE_LOCATION = "/tmp/tmp.jpg"
6
6
 
7
7
  def initialize(args, settings)
8
8
  @api_root = settings.get('api_root')
9
+ @file = Tempfile.new(['screenshot', '.jpg'])
9
10
  end
10
11
 
11
12
  def go
12
- `screencapture -t jpg -x #{FILE_LOCATION}`
13
- response = RestClient.post "#{@api_root}/upload", file: File.new(FILE_LOCATION, 'rb')
13
+ `screencapture -t jpg -x #{@file.path}`
14
+ response = RestClient.post "#{@api_root}/upload", file: File.new(@file.path, 'rb')
14
15
  @url = JSON.load(response)['url']
15
16
  end
16
17
 
@@ -21,7 +21,6 @@ module Controlio
21
21
  puts "Running #{klass} (#{args})"
22
22
  instance = klass.new(args, @settings)
23
23
  spawn_and_timeout instance
24
- send instance.respond, instance.media?
25
24
  else
26
25
  send "Command '#{c['message']}' was not found!"
27
26
  end
@@ -36,6 +35,7 @@ module Controlio
36
35
  def spawn_and_timeout(instance)
37
36
  pid = fork do
38
37
  instance.go
38
+ send instance.respond, instance.media?
39
39
  end
40
40
  Process.detach pid
41
41
  pid2 = fork do
@@ -1,3 +1,3 @@
1
1
  module Controlio
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controlio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasyf Mohamedali