vlc_proxy 0.1.0 → 0.1.1

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: 5e1b0d3e7ac5412726b8ff9d74dc38c00f9128b5
4
- data.tar.gz: 4e39161521d48a62a363b015c0538386b1b35134
2
+ SHA256:
3
+ metadata.gz: 838c6ceedc898be9d6c1bca8c6b9811a03a5fd4baac760b841d4b192bdd09dd1
4
+ data.tar.gz: d101db097f1d8bd7a9984a5d521f25b141b0c2e7a21bf08344d2bc64a14443e9
5
5
  SHA512:
6
- metadata.gz: 6ec290b6f41b13c436159d86aaa660c176fdad255dc057f1b8838b06a90cebe7b8b5858bab4db79fd0210016e4fd7bfa64ec5cf09996ec61275a824b361b1414
7
- data.tar.gz: 6852d3b7355437ba7b7ec532ceecbb7b414f8b98bf54e6b8a35d799c7b310f8602fc1f2845ab0d99c1d0cb424f0829ccdcfb61552fa9b5ea8797f3ec5527f920
6
+ metadata.gz: c86b087a48edbdb6f5a9e891ef2e2414dfcbe7c22b9cae0940dd45184e6150bba17e0989e90411c20c33a763cd31b5313cc9bb4abd9764b2325bd6c6541b9739
7
+ data.tar.gz: 0ad2aefec8a13c60beed9376dcd546121e0d08ace35a07b0250d48f837decbf530eef7c6d9319a6409d650cf7b6bb34a797b959a8083d28830785748891b0fb3
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'spec/**/*.rb'
@@ -0,0 +1,8 @@
1
+ require 'simplecov-console'
2
+
3
+ SimpleCov.start do
4
+ formatter SimpleCov::Formatter::MultiFormatter.new([
5
+ SimpleCov::Formatter::Console,
6
+ SimpleCov::Formatter::HTMLFormatter
7
+ ])
8
+ end
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vlc_proxy (0.1.0)
5
+ nokogiri (>= 1.9.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ansi (1.5.0)
11
+ ast (2.4.1)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.4.4)
14
+ docile (1.3.2)
15
+ method_source (0.9.2)
16
+ mini_portile2 (2.4.0)
17
+ nokogiri (1.10.10)
18
+ mini_portile2 (~> 2.4.0)
19
+ parallel (1.19.2)
20
+ parser (2.7.1.4)
21
+ ast (~> 2.4.1)
22
+ pry (0.12.2)
23
+ coderay (~> 1.1.0)
24
+ method_source (~> 0.9.0)
25
+ rainbow (3.0.0)
26
+ rake (13.0.1)
27
+ regexp_parser (1.7.1)
28
+ rexml (3.2.4)
29
+ rspec (3.9.0)
30
+ rspec-core (~> 3.9.0)
31
+ rspec-expectations (~> 3.9.0)
32
+ rspec-mocks (~> 3.9.0)
33
+ rspec-core (3.9.2)
34
+ rspec-support (~> 3.9.3)
35
+ rspec-expectations (3.9.2)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-mocks (3.9.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-support (3.9.3)
42
+ rubocop (0.87.1)
43
+ parallel (~> 1.10)
44
+ parser (>= 2.7.1.1)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.7)
47
+ rexml
48
+ rubocop-ast (>= 0.1.0, < 1.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 2.0)
51
+ rubocop-ast (0.1.0)
52
+ parser (>= 2.7.0.1)
53
+ ruby-progressbar (1.10.1)
54
+ simplecov (0.18.5)
55
+ docile (~> 1.1)
56
+ simplecov-html (~> 0.11)
57
+ simplecov-console (0.7.2)
58
+ ansi
59
+ simplecov
60
+ terminal-table
61
+ simplecov-html (0.12.2)
62
+ terminal-table (1.8.0)
63
+ unicode-display_width (~> 1.1, >= 1.1.1)
64
+ unicode-display_width (1.7.0)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ pry (~> 0.12.1)
71
+ rake (~> 13.0, >= 13.0.1)
72
+ rspec (~> 3.9)
73
+ rubocop (~> 0.87.0)
74
+ simplecov (~> 0.18.5)
75
+ simplecov-console (~> 0.7.2)
76
+ vlc_proxy!
77
+
78
+ BUNDLED WITH
79
+ 2.1.4
data/Rakefile CHANGED
@@ -1,6 +1,14 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rubocop/rake_task'
3
+ require 'rspec/core/rake_task'
3
4
 
5
+ desc 'Run RSpec against the spec directory'
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ desc 'Run RuboCop on the lib directory'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task :default => [:spec, :rubocop]
@@ -1,72 +1,77 @@
1
- require 'vlc_proxy/configuration'
2
- module VlcProxy
3
- class Client
4
- attr_reader :connection
5
-
6
- def initialize(connection)
7
- @connection = connection
8
- @logger = VlcProxy.config.logger
9
- end
10
-
11
- def pause_playlist
12
- request('status', 'pl_pause')
13
- end
14
-
15
- def start_playlist
16
- request('status', 'pl_play')
17
- end
18
-
19
- def stop_playlist
20
- request('status', 'pl_stop')
21
- end
22
-
23
- def next_item
24
- request('status', 'pl_next')
25
- end
26
-
27
- def previous_item
28
- request('status', 'pl_previous')
29
- end
30
-
31
- def toggle_repeat
32
- request('status', 'pl_repeat')
33
- end
34
-
35
- def toggle_loop
36
- request('status', 'pl_loop')
37
- end
38
-
39
- def toggle_random
40
- request('status', 'pl_random')
41
- end
42
-
43
- def toggle_fullscreen
44
- request('status', 'fullscreen')
45
- end
46
-
47
- def increase_volume(value)
48
- request('status', 'volume', val: "+#{value}")
49
- end
50
-
51
- def decrease_volume(value)
52
- request('status', 'volume', val: "-#{value}")
53
- end
54
-
55
- def skip_forward(seconds)
56
- request('status', 'seek', val: "+#{seconds}S")
57
- end
58
-
59
- def skip_backward(seconds)
60
- request('status', 'seek', val: "-#{seconds}S")
61
- end
62
-
63
- private
64
-
65
- def request(action, command = '', parameters = {})
66
- @connection.execute(action, command, parameters)
67
- rescue StandardError => e
68
- @logger.error(e.message)
69
- raise e
70
- end
71
- end
72
- end
1
+ require 'vlc_proxy/configuration'
2
+
3
+ module VlcProxy
4
+ class Client
5
+ attr_reader :connection
6
+
7
+ def initialize(connection)
8
+ @connection = connection
9
+ @logger = VlcProxy.config.logger
10
+ end
11
+
12
+ def current_state
13
+ request('status')
14
+ end
15
+
16
+ def pause_playlist
17
+ request('status', 'pl_pause')
18
+ end
19
+
20
+ def start_playlist
21
+ request('status', 'pl_play')
22
+ end
23
+
24
+ def stop_playlist
25
+ request('status', 'pl_stop')
26
+ end
27
+
28
+ def next_item
29
+ request('status', 'pl_next')
30
+ end
31
+
32
+ def previous_item
33
+ request('status', 'pl_previous')
34
+ end
35
+
36
+ def toggle_repeat
37
+ request('status', 'pl_repeat')
38
+ end
39
+
40
+ def toggle_loop
41
+ request('status', 'pl_loop')
42
+ end
43
+
44
+ def toggle_random
45
+ request('status', 'pl_random')
46
+ end
47
+
48
+ def toggle_fullscreen
49
+ request('status', 'fullscreen')
50
+ end
51
+
52
+ def increase_volume(value)
53
+ request('status', 'volume', val: "+#{value.abs}")
54
+ end
55
+
56
+ def decrease_volume(value)
57
+ request('status', 'volume', val: "-#{value.abs}")
58
+ end
59
+
60
+ def skip_forward(seconds)
61
+ request('status', 'seek', val: "+#{seconds.abs}S")
62
+ end
63
+
64
+ def skip_backward(seconds)
65
+ request('status', 'seek', val: "-#{seconds.abs}S")
66
+ end
67
+
68
+ private
69
+
70
+ def request(action, command = '', parameters = {})
71
+ @connection.execute(action, command, parameters)
72
+ rescue StandardError => e
73
+ @logger.error(e.message)
74
+ raise e
75
+ end
76
+ end
77
+ end
@@ -1,21 +1,22 @@
1
- require 'logger'
2
-
3
- module VlcProxy
4
- class Configuration
5
- attr_accessor :logger, :verbose
6
-
7
- def initialize
8
- @logger = Logger.new(STDOUT)
9
- @verbose = false
10
- end
11
-
12
- def logger
13
- @logger.level = Logger::INFO if verbose? && !@logger.info?
14
- @logger
15
- end
16
-
17
- def verbose?
18
- @verbose
19
- end
20
- end
21
- end
1
+ require 'logger'
2
+
3
+ module VlcProxy
4
+ class Configuration
5
+ attr_writer :logger, :verbose
6
+
7
+ def initialize
8
+ @logger = Logger.new(STDOUT)
9
+ @verbose = false
10
+ end
11
+
12
+ def logger
13
+ @logger.level = verbose? ? Logger::INFO : Logger::WARN
14
+
15
+ @logger
16
+ end
17
+
18
+ def verbose?
19
+ @verbose
20
+ end
21
+ end
22
+ end
@@ -1,66 +1,70 @@
1
- require 'net/http'
2
- require 'nokogiri'
3
-
4
- module VlcProxy
5
- # When HTTP enabled on VLC, a LUA web server runs in background listening
6
- # on the specific port on localhost by default. VLC requires setting a
7
- # password for basic auth as well
8
- class Connection
9
- def initialize(hostname, password, port = 8080, scheme = 'http')
10
- @hostname = hostname
11
- @password = password
12
- @port = port
13
- @scheme = scheme
14
- @logger = VlcProxy.config.logger
15
- end
16
-
17
- # Test if the connection works with the connection parameters
18
- # Returns true if VLC is running and returns a response on /status
19
- # Returns false if there are any connection errors
20
- def connected?
21
- response = execute('status')
22
- parse_response(response)
23
- rescue VlcProxy::AccessDeniedError, Errno::ECONNREFUSED => e
24
- @logger.error(e.message)
25
- false
26
- end
27
-
28
- def execute(action, command = '', parameters = {})
29
- uri = build_uri(action, command, parameters)
30
- request = Net::HTTP::Get.new(uri)
31
- request.basic_auth('', @password)
32
-
33
- Net::HTTP.start(uri.hostname, uri.port) do |http|
34
- @logger.info('Starting HTTP request')
35
- http.request(request)
36
- end
37
- end
38
-
39
- private
40
-
41
- def http_success?(response)
42
- response.code == '200'
43
- end
44
-
45
- def http_unauthorized?(response)
46
- response.code == '401'
47
- end
48
-
49
- def parse_response(response)
50
- return true if http_success?(response)
51
- raise VlcProxy::AccessDeniedError if http_unauthorized?(response)
52
- false
53
- end
54
-
55
- def build_uri(action, command = '', parameters = {})
56
- base_url = "#{@scheme}://#{@hostname}:#{@port}/requests/#{action}.xml"
57
- base_url += "?command=#{command}" unless command.empty?
58
- unless parameters.empty?
59
- params = parameters.map { |key, value| "#{key}=#{value}" }.join('&')
60
- base_url += "&#{params}"
61
- end
62
- @logger.info("built uri: #{base_url}")
63
- URI(base_url)
64
- end
65
- end
66
- end
1
+ require 'net/http'
2
+ require 'nokogiri'
3
+
4
+ module VlcProxy
5
+ # When HTTP enabled on VLC, a LUA web server runs in background listening
6
+ # on the specific port on localhost by default. VLC requires setting a
7
+ # password for basic auth as well
8
+ class Connection
9
+ def initialize(hostname, password, port = 8080, scheme = 'http')
10
+ @hostname = hostname
11
+ @password = password
12
+ @port = port
13
+ @scheme = scheme
14
+ @logger = VlcProxy.config.logger
15
+ end
16
+
17
+ # Test if the connection works with the connection parameters
18
+ # Returns true if VLC is running and returns a response on /status
19
+ # Returns false if there are any connection errors
20
+ def connected?
21
+ response = execute('status')
22
+ valid_response?(response)
23
+ rescue VlcProxy::AccessDeniedError, Errno::ECONNREFUSED => e
24
+ @logger.error(e.message)
25
+ false
26
+ end
27
+
28
+ def execute(action, command = '', parameters = {})
29
+ uri = build_uri(action, command, parameters)
30
+ request = Net::HTTP::Get.new(uri)
31
+ request.basic_auth('', @password)
32
+
33
+ Net::HTTP.start(uri.hostname, uri.port) do |http|
34
+ @logger.info('Starting HTTP request')
35
+ http.request(request)
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def http_success?(response)
42
+ response.code == '200'
43
+ end
44
+
45
+ def http_unauthorized?(response)
46
+ response.code == '401'
47
+ end
48
+
49
+ def valid_response?(response)
50
+ return true if http_success?(response)
51
+
52
+ raise VlcProxy::AccessDeniedError if http_unauthorized?(response)
53
+
54
+ false
55
+ end
56
+
57
+ def build_uri(action, command = '', parameters = {})
58
+ base_url = "#{@scheme}://#{@hostname}:#{@port}/requests/#{action}.xml"
59
+ base_url += "?command=#{command}" unless command.empty?
60
+
61
+ unless parameters.empty?
62
+ params = parameters.map { |key, value| "#{key}=#{value}" }.join('&')
63
+ base_url += "&#{params}"
64
+ end
65
+
66
+ @logger.info("built uri: #{base_url}")
67
+ URI(base_url)
68
+ end
69
+ end
70
+ end
@@ -1,4 +1,4 @@
1
- # List of custom Exceptions
2
- module VlcProxy
3
- class AccessDeniedError < StandardError; end
4
- end
1
+ # List of custom Exceptions
2
+ module VlcProxy
3
+ class AccessDeniedError < StandardError; end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module VlcProxy
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -18,18 +18,21 @@ Gem::Specification.new do |spec|
18
18
  # into git
19
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
20
  `git ls-files -z`.split("\x0").reject do |f|
21
- f.match(%r{^(test|spec|features)/})
21
+ f.match(%r{^(test|spec|features)/}) || f.match(/vlc_proxy-0.1.0.gem/)
22
22
  end
23
23
  end
24
24
  spec.bindir = 'exe'
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'nokogiri', '>= 1.9.1'
28
+ # Runtime Dependencies
29
+ spec.add_runtime_dependency 'nokogiri', '>= 1.9.1'
29
30
 
30
- spec.add_development_dependency 'bundler', '~> 1.16'
31
- spec.add_development_dependency 'rake', '~> 10.0'
32
- spec.add_development_dependency 'rspec', '~> 3.7'
33
- spec.add_development_dependency 'pry', '~> 0.12.2'
34
- spec.add_development_dependency 'simplecov', '~> 0.16.1'
31
+ # Development/Test Dependencies
32
+ spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
33
+ spec.add_development_dependency 'rspec', '~> 3.9'
34
+ spec.add_development_dependency 'pry', '~> 0.12.1'
35
+ spec.add_development_dependency 'simplecov', '~> 0.18.5'
36
+ spec.add_development_dependency 'simplecov-console', '~> 0.7.2'
37
+ spec.add_development_dependency 'rubocop', '~> 0.87.0'
35
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vlc_proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zshawn Syed
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-26 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -25,75 +25,95 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.9.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '13.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 13.0.1
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '1.16'
43
+ version: '13.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 13.0.1
41
47
  - !ruby/object:Gem::Dependency
42
- name: rake
48
+ name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '10.0'
53
+ version: '3.9'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '10.0'
60
+ version: '3.9'
55
61
  - !ruby/object:Gem::Dependency
56
- name: rspec
62
+ name: pry
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '3.7'
67
+ version: 0.12.1
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '3.7'
74
+ version: 0.12.1
69
75
  - !ruby/object:Gem::Dependency
70
- name: pry
76
+ name: simplecov
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: 0.12.2
81
+ version: 0.18.5
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: 0.12.2
88
+ version: 0.18.5
83
89
  - !ruby/object:Gem::Dependency
84
- name: simplecov
90
+ name: simplecov-console
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.7.2
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.7.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
85
105
  requirement: !ruby/object:Gem::Requirement
86
106
  requirements:
87
107
  - - "~>"
88
108
  - !ruby/object:Gem::Version
89
- version: 0.16.1
109
+ version: 0.87.0
90
110
  type: :development
91
111
  prerelease: false
92
112
  version_requirements: !ruby/object:Gem::Requirement
93
113
  requirements:
94
114
  - - "~>"
95
115
  - !ruby/object:Gem::Version
96
- version: 0.16.1
116
+ version: 0.87.0
97
117
  description: Simple Ruby wrapper around the HTTP server VLC exposes
98
118
  email:
99
119
  - zsyed91@gmail.com
@@ -103,9 +123,12 @@ extra_rdoc_files: []
103
123
  files:
104
124
  - ".gitignore"
105
125
  - ".rspec"
126
+ - ".rubocop.yml"
127
+ - ".simplecov"
106
128
  - ".travis.yml"
107
129
  - CODE_OF_CONDUCT.md
108
130
  - Gemfile
131
+ - Gemfile.lock
109
132
  - LICENSE.txt
110
133
  - README.md
111
134
  - Rakefile
@@ -137,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
160
  - !ruby/object:Gem::Version
138
161
  version: '0'
139
162
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.6.8
163
+ rubygems_version: 3.0.3
142
164
  signing_key:
143
165
  specification_version: 4
144
166
  summary: Simple Ruby wrapper around the HTTP server VLC exposes