xrandr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xrandr.rb +10 -1
  3. data/test/output_test.rb +18 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22d9b48ee5fbeaf0c16d9d36826f9fd83bcaf292
4
- data.tar.gz: d21fc1b476c1cd301cdc0fb3d1ecc0d090c799d8
3
+ metadata.gz: 54a9da38bc2aeddeff800687a14c968a80d352ca
4
+ data.tar.gz: b45125b3deab9e42e88673e5dc46502bff82a331
5
5
  SHA512:
6
- metadata.gz: 8b2b346c588b1d3bc3dc254cb9eccd844ef2ffd84f971cf2202aae51ddeb59ef7c0839632be9c2924269a6f3554244dd27c102ce165d17091ff7e74ea0e1aa39
7
- data.tar.gz: c7a03d27ff658f5739c86c88b0fab7bbaaa9597604dac087cedfc1ccc6643103bf5572d4676ec889665a97010ec57d75a1a86262ba4aac86435535734c77bf98
6
+ metadata.gz: 7643280ba115869f60b870b7afe54e0d685a1a5cc7fc62d0b71260dc774479381b99479b0017c6cc0b86a39f272d76e7f0ca889499934567f887c613edcd0c88
7
+ data.tar.gz: ab54aa857ba5c623ac8b06c34dddd51123a4b5bb95075a8707d5c862c928fcc0aef16626be5ad95f9c818a3a0bdba816f79716e614d7b39107bd50a806a6f8a6
@@ -1,5 +1,5 @@
1
1
  module Xrandr
2
- VERSION = '0.0.2'
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
@@ -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.2
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-08-13 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler