xrandr 0.0.2 → 0.0.3
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 +4 -4
- data/lib/xrandr.rb +10 -1
- data/test/output_test.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a9da38bc2aeddeff800687a14c968a80d352ca
|
4
|
+
data.tar.gz: b45125b3deab9e42e88673e5dc46502bff82a331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7643280ba115869f60b870b7afe54e0d685a1a5cc7fc62d0b71260dc774479381b99479b0017c6cc0b86a39f272d76e7f0ca889499934567f887c613edcd0c88
|
7
|
+
data.tar.gz: ab54aa857ba5c623ac8b06c34dddd51123a4b5bb95075a8707d5c862c928fcc0aef16626be5ad95f9c818a3a0bdba816f79716e614d7b39107bd50a806a6f8a6
|
data/lib/xrandr.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Xrandr
|
2
|
-
VERSION = '0.0.
|
2
|
+
VERSION = '0.0.3'
|
3
3
|
|
4
4
|
class Control
|
5
5
|
attr_reader :screens, :outputs, :command
|
@@ -112,6 +112,10 @@ module Xrandr
|
|
112
112
|
class Output
|
113
113
|
attr_reader :name, :connected, :primary, :resolution, :position, :info, :dimensions, :modes
|
114
114
|
|
115
|
+
ON = 'on'.freeze
|
116
|
+
OFF = 'off'.freeze
|
117
|
+
DISCONNECTED = 'disconnected'.freeze
|
118
|
+
|
115
119
|
def initialize(name:, connected:, primary: false, resolution: nil, position: nil, info: '', dimensions: '', modes: [])
|
116
120
|
raise ArgumentError, "must provide a name for the output" unless name
|
117
121
|
raise ArgumentError, "connected cant be nil" unless connected == true || connected == false
|
@@ -132,6 +136,11 @@ module Xrandr
|
|
132
136
|
def preferred
|
133
137
|
modes.detect(&:preferred)
|
134
138
|
end
|
139
|
+
|
140
|
+
def status
|
141
|
+
return DISCONNECTED unless connected
|
142
|
+
current ? ON : OFF
|
143
|
+
end
|
135
144
|
end
|
136
145
|
|
137
146
|
class Mode
|
data/test/output_test.rb
CHANGED
@@ -14,5 +14,23 @@ module Xrandr
|
|
14
14
|
Output.new name: 'o'
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def test_status_returns_disconnected_when_output_is_not_connected
|
19
|
+
o = Output.new name: 'out1', connected: false
|
20
|
+
|
21
|
+
assert_equal 'disconnected', o.status
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_status_returns_on_when_output_has_current_mode_set
|
25
|
+
o = Output.new name: 'out1', connected: true, modes: [ Mode.new(current: true, rate: '60hz', preferred: true, resolution: '1920x1080') ]
|
26
|
+
|
27
|
+
assert_equal 'on', o.status
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_status_returns_off_when_output_has_no_current_mode_set
|
31
|
+
o = Output.new name: 'out1', connected: true, modes: [ Mode.new(current: false, rate: '60hz', preferred: false, resolution: '1920x1080') ]
|
32
|
+
|
33
|
+
assert_equal 'off', o.status
|
34
|
+
end
|
17
35
|
end
|
18
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrandr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Martínez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|