Skip to content

Commit

Permalink
Added volume % endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Apr 18, 2016
1 parent d5d2b2d commit a297a71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/lita/handlers/onewheel_automatic_pancake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class OnewheelAutomaticPancake < Handler
command: true,
help: {'vol down' => 'Turn it down!'}

route /^vol (\d+)/i,
:vol_change,
command: true,
help: {'vol 80%' => 'Set volume to 80%.'}

route /^playtube (.*)$/i,
:youtube,
command: true,
Expand All @@ -46,17 +51,21 @@ def kill(response)
end

def vol_up(response)
6.times do |i|
3.times do |i|
RestClient.post "#{config.pancake_server}/vol/up", {}
end
end

def vol_down(response)
6.times do |i|
3.times do |i|
RestClient.post "#{config.pancake_server}/vol/down", {}
end
end

def vol_change(response)
RestClient.post "#{config.pancake_server}/vol/#{response.matches[0][0]}", {}
end

def youtube(response)
youtube_id = response.matches[0][0]
RestClient.post "#{config.pancake_server}/youtube", {uri: youtube_id}
Expand Down
2 changes: 1 addition & 1 deletion lita-onewheel-automatic-pancake.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-automatic-pancake'
spec.version = '0.4.0'
spec.version = '0.5.0'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = %q{Lita interface to Automatic Pancake.}
Expand Down
4 changes: 4 additions & 0 deletions spec/lita/handlers/onewheel_automatic_pancake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

describe Lita::Handlers::OnewheelAutomaticPancake, lita_handler: true do
it { is_expected.to route_command('play x') }
it { is_expected.to route_command('playtube x') }
it { is_expected.to route_command('vol up') }
it { is_expected.to route_command('vol down') }
it { is_expected.to route_command('vol 50') }

# before do
# mock = File.open('spec/fixtures/baileys.html').read
Expand Down

0 comments on commit a297a71

Please sign in to comment.