rmonitor 1.0.1 → 2.0.0

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +49 -40
  4. data/bin/rmonitor +38 -100
  5. data/lib/rmonitor.rb +17 -20
  6. data/lib/rmonitor/actions.rb +30 -0
  7. data/lib/rmonitor/actions/builder.rb +15 -0
  8. data/lib/rmonitor/actions/dsl.rb +23 -0
  9. data/lib/rmonitor/cache.rb +12 -0
  10. data/lib/rmonitor/capabilities.rb +38 -0
  11. data/lib/rmonitor/capabilities/builder.rb +15 -0
  12. data/lib/rmonitor/capabilities/dsl.rb +15 -0
  13. data/lib/rmonitor/commands/cl/base.rb +13 -0
  14. data/lib/rmonitor/commands/cl/invoke.rb +22 -0
  15. data/lib/rmonitor/commands/cl/list.rb +43 -0
  16. data/lib/rmonitor/commands/cl/update.rb +20 -0
  17. data/lib/rmonitor/commands/invoke.rb +23 -0
  18. data/lib/rmonitor/commands/list.rb +13 -0
  19. data/lib/rmonitor/commands/update.rb +18 -0
  20. data/lib/rmonitor/config.rb +27 -0
  21. data/lib/rmonitor/config/builder.rb +21 -0
  22. data/lib/rmonitor/config/dsl.rb +25 -0
  23. data/lib/rmonitor/invoker.rb +9 -0
  24. data/lib/rmonitor/matcher.rb +32 -0
  25. data/lib/rmonitor/profile/builder.rb +15 -0
  26. data/lib/rmonitor/profile/dsl.rb +15 -0
  27. data/lib/rmonitor/selector.rb +14 -0
  28. data/lib/rmonitor/strategies/base.rb +10 -0
  29. data/lib/rmonitor/strategies/optimistic.rb +15 -0
  30. data/lib/rmonitor/strategies/pessimistic.rb +17 -0
  31. data/lib/rmonitor/transformer.rb +38 -0
  32. data/lib/rmonitor/version.rb +1 -1
  33. data/lib/rmonitor/xrandr.rb +16 -0
  34. data/test/actions/builder_test.rb +27 -0
  35. data/test/actions_test.rb +60 -0
  36. data/test/cache_test.rb +30 -0
  37. data/test/capabilities/builder_test.rb +23 -0
  38. data/test/capabilities_test.rb +114 -0
  39. data/test/commands/cl/invoke_test.rb +38 -0
  40. data/test/commands/cl/list_test.rb +36 -0
  41. data/test/commands/cl/update_test.rb +24 -0
  42. data/test/commands/invoke_test.rb +86 -0
  43. data/test/commands/list_test.rb +50 -0
  44. data/test/commands/update_test.rb +67 -0
  45. data/test/config/builder_test.rb +51 -0
  46. data/test/config_test.rb +68 -0
  47. data/test/matcher_test.rb +90 -0
  48. data/test/profile/builder_test.rb +26 -0
  49. data/test/selector_test.rb +30 -0
  50. data/test/strategies/optimistic_test.rb +24 -0
  51. data/test/strategies/pessimistic_test.rb +26 -0
  52. data/test/test_helper.rb +19 -0
  53. data/test/transformer_test.rb +159 -0
  54. data/test/xrandr_test.rb +76 -0
  55. metadata +178 -28
  56. data/.rspec +0 -1
  57. data/Gemfile +0 -3
  58. data/Gemfile.lock +0 -24
  59. data/lib/rmonitor/devices.rb +0 -29
  60. data/lib/rmonitor/helpers/dsl_helpers.rb +0 -38
  61. data/lib/rmonitor/helpers/profile_helpers.rb +0 -48
  62. data/lib/rmonitor/helpers/xrandr_read_helpers.rb +0 -75
  63. data/lib/rmonitor/helpers/xrandr_write_helpers.rb +0 -55
  64. data/lib/rmonitor/profiles.rb +0 -51
  65. data/rmonitor.gemspec +0 -44
  66. data/spec/lib/helpers/dsl_helper_spec.rb +0 -29
  67. data/spec/lib/helpers/profile_helpers_spec.rb +0 -138
  68. data/spec/lib/helpers/xrandr_read_helpers_spec.rb +0 -259
  69. data/spec/lib/helpers/xrandr_write_helpers_spec.rb +0 -158
  70. data/spec/support/device_helper.rb +0 -3
  71. data/spec/support/profile_helper.rb +0 -3
  72. data/spec/support/string_helpers.rb +0 -25
@@ -0,0 +1,159 @@
1
+ require "test_helper"
2
+
3
+ describe RMonitor::Transformer do
4
+
5
+ describe "#transform" do
6
+
7
+ it "should transform the :name option" do
8
+ actions = RMonitor::Actions::Builder.define do
9
+ on "HDMI1"
10
+ end
11
+
12
+ transformation = RMonitor::Transformer.new.transform(actions.first)
13
+
14
+ assert_equal ["--output", "HDMI1"], transformation
15
+ end
16
+
17
+ it "should transform the :mode option" do
18
+ actions = RMonitor::Actions::Builder.define do
19
+ on "HDMI1", :mode => "1920x1080"
20
+ end
21
+
22
+ transformation = RMonitor::Transformer.new.transform(actions.first)
23
+
24
+ assert_equal ["--output", "HDMI1", "--mode", "1920x1080"], transformation
25
+ end
26
+
27
+ it "should transform the :rate option" do
28
+ actions = RMonitor::Actions::Builder.define do
29
+ on "HDMI1", :rate => "60.0"
30
+ end
31
+
32
+ transformation = RMonitor::Transformer.new.transform(actions.first)
33
+
34
+ assert_equal ["--output", "HDMI1", "--rate", "60.0"], transformation
35
+ end
36
+
37
+ it "should transform the :primary option" do
38
+ actions = RMonitor::Actions::Builder.define do
39
+ on "HDMI1", :primary => true
40
+ end
41
+
42
+ transformation = RMonitor::Transformer.new.transform(actions.first)
43
+
44
+ assert_equal ["--output", "HDMI1", "--primary"], transformation
45
+ end
46
+
47
+ it "should transform the :pos option" do
48
+ actions = RMonitor::Actions::Builder.define do
49
+ on "HDMI1", :pos => "1920x0"
50
+ end
51
+
52
+ transformation = RMonitor::Transformer.new.transform(actions.first)
53
+
54
+ assert_equal ["--output", "HDMI1", "--pos", "1920x0"], transformation
55
+ end
56
+
57
+ it "should transform the :left_of option" do
58
+ actions = RMonitor::Actions::Builder.define do
59
+ on "HDMI1", :left_of => "HDMI2"
60
+ end
61
+
62
+ transformation = RMonitor::Transformer.new.transform(actions.first)
63
+
64
+ assert_equal ["--output", "HDMI1", "--left-of", "HDMI2"], transformation
65
+ end
66
+
67
+ it "should transform the :right_of option" do
68
+ actions = RMonitor::Actions::Builder.define do
69
+ on "HDMI1", :right_of => "HDMI2"
70
+ end
71
+
72
+ transformation = RMonitor::Transformer.new.transform(actions.first)
73
+
74
+ assert_equal ["--output", "HDMI1", "--right-of", "HDMI2"], transformation
75
+ end
76
+
77
+ it "should transform the :above option" do
78
+ actions = RMonitor::Actions::Builder.define do
79
+ on "HDMI1", :above => "HDMI2"
80
+ end
81
+
82
+ transformation = RMonitor::Transformer.new.transform(actions.first)
83
+
84
+ assert_equal ["--output", "HDMI1", "--above", "HDMI2"], transformation
85
+ end
86
+
87
+ it "should transform the :below option" do
88
+ actions = RMonitor::Actions::Builder.define do
89
+ on "HDMI1", :below => "HDMI2"
90
+ end
91
+
92
+ transformation = RMonitor::Transformer.new.transform(actions.first)
93
+
94
+ assert_equal ["--output", "HDMI1", "--below", "HDMI2"], transformation
95
+ end
96
+
97
+ it "should transform the :same_as option" do
98
+ actions = RMonitor::Actions::Builder.define do
99
+ on "HDMI1", :same_as => "HDMI2"
100
+ end
101
+
102
+ transformation = RMonitor::Transformer.new.transform(actions.first)
103
+
104
+ assert_equal ["--output", "HDMI1", "--same-as", "HDMI2"], transformation
105
+ end
106
+
107
+ it "should transform the :transform option" do
108
+ actions = RMonitor::Actions::Builder.define do
109
+ on "HDMI1", :transform => :normal
110
+ end
111
+
112
+ transformation = RMonitor::Transformer.new.transform(actions.first)
113
+
114
+ assert_equal ["--output", "HDMI1", "--transform", "normal"], transformation
115
+ end
116
+
117
+ it "should transform the :rotate option" do
118
+ actions = RMonitor::Actions::Builder.define do
119
+ on "HDMI1", :rotate => :normal
120
+ end
121
+
122
+ transformation = RMonitor::Transformer.new.transform(actions.first)
123
+
124
+ assert_equal ["--output", "HDMI1", "--rotate", "normal"], transformation
125
+ end
126
+
127
+ it "should transform the :reflect option" do
128
+ actions = RMonitor::Actions::Builder.define do
129
+ on "HDMI1", :reflect => :normal
130
+ end
131
+
132
+ transformation = RMonitor::Transformer.new.transform(actions.first)
133
+
134
+ assert_equal ["--output", "HDMI1", "--reflect", "normal"], transformation
135
+ end
136
+
137
+ it "should transform the global :dpi option" do
138
+ actions = RMonitor::Actions::Builder.define do
139
+ dpi 96
140
+ end
141
+
142
+ transformation = RMonitor::Transformer.new.transform(actions.first)
143
+
144
+ assert_equal ["--dpi", "96"], transformation
145
+ end
146
+
147
+ it "should transform actions of type :off" do
148
+ actions = RMonitor::Actions::Builder.define do
149
+ off "HDMI1"
150
+ end
151
+
152
+ transformation = RMonitor::Transformer.new.transform(actions.first)
153
+
154
+ assert_equal ["--output", "HDMI1", "--off"], transformation
155
+ end
156
+
157
+ end
158
+
159
+ end
@@ -0,0 +1,76 @@
1
+ require "test_helper"
2
+ require "stringio"
3
+
4
+ describe RMonitor::XRandR do
5
+
6
+ describe "#invoke" do
7
+
8
+ describe "when :dry_run is false" do
9
+
10
+ it "should call the system invoker with xrandr and the argument concatenation" do
11
+ invoker = MiniTest::Mock.new
12
+ invoker.expect :invoke, nil, ["xrandr --output HDMI1 --auto"]
13
+
14
+ RMonitor::XRandR.new(:invoker => invoker, :dry_run => false).invoke("--output", "HDMI1", "--auto")
15
+
16
+ invoker.verify
17
+ end
18
+
19
+ end
20
+
21
+ describe "when :dry_run is true and given no arguments" do
22
+
23
+ it "should call the system invoker with xrandr" do
24
+ invoker = MiniTest::Mock.new
25
+ invoker.expect :invoke, nil, ["xrandr"]
26
+
27
+ RMonitor::XRandR.new(:invoker => invoker, :dry_run => true).invoke
28
+
29
+ invoker.verify
30
+ end
31
+
32
+ end
33
+
34
+ describe "when :dry_run is true and given ssome arguments" do
35
+
36
+ it "should not call the system invoker" do
37
+ invoker = MiniTest::Mock.new # No expectations
38
+
39
+ RMonitor::XRandR.new(:invoker => invoker, :dry_run => true).invoke("--output", "HDMI1", "--auto")
40
+
41
+ invoker.verify
42
+ end
43
+
44
+ end
45
+
46
+ describe "when :verbose is false" do
47
+
48
+ it "should not output anything" do
49
+ out = StringIO.new
50
+ invoker = MiniTest::Mock.new
51
+ invoker.expect :invoke, nil, ["xrandr --output HDMI1 --auto"]
52
+
53
+ RMonitor::XRandR.new(:invoker => invoker, :verbose => false, :out => out).invoke("--output", "HDMI1", "--auto")
54
+
55
+ assert_equal "", out.string
56
+ end
57
+
58
+ end
59
+
60
+ describe "when :verbose is true" do
61
+
62
+ it "should output the command" do
63
+ out = StringIO.new
64
+ invoker = MiniTest::Mock.new
65
+ invoker.expect :invoke, nil, ["xrandr --output HDMI1 --auto"]
66
+
67
+ RMonitor::XRandR.new(:invoker => invoker, :verbose => true, :out => out).invoke("--output", "HDMI1", "--auto")
68
+
69
+ assert_equal "xrandr --output HDMI1 --auto\n", out.string
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
76
+ end
metadata CHANGED
@@ -1,30 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmonitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Amundsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: commander
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.3.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 4.3.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.7
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: fakefs
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 5.5.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 5.5.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.13.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.13.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.4
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 10.4.2
20
118
  type: :development
21
119
  prerelease: false
22
120
  version_requirements: !ruby/object:Gem::Requirement
23
121
  requirements:
24
- - - ">="
122
+ - - '='
25
123
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: RMonitor is a tool for creating monitor profiles that are easily invoked.
124
+ version: 10.4.2
125
+ description: RMonitor is a tool for defining monitor profiles that can be invoked.
28
126
  This is useful when you often find yourself in situations with different monitor
29
127
  configurations.
30
128
  email:
@@ -34,28 +132,59 @@ executables:
34
132
  extensions: []
35
133
  extra_rdoc_files: []
36
134
  files:
37
- - ".rspec"
38
- - Gemfile
39
- - Gemfile.lock
40
135
  - LICENSE
41
136
  - README.md
42
137
  - bin/rmonitor
43
138
  - lib/rmonitor.rb
44
- - lib/rmonitor/devices.rb
45
- - lib/rmonitor/helpers/dsl_helpers.rb
46
- - lib/rmonitor/helpers/profile_helpers.rb
47
- - lib/rmonitor/helpers/xrandr_read_helpers.rb
48
- - lib/rmonitor/helpers/xrandr_write_helpers.rb
49
- - lib/rmonitor/profiles.rb
139
+ - lib/rmonitor/actions.rb
140
+ - lib/rmonitor/actions/builder.rb
141
+ - lib/rmonitor/actions/dsl.rb
142
+ - lib/rmonitor/cache.rb
143
+ - lib/rmonitor/capabilities.rb
144
+ - lib/rmonitor/capabilities/builder.rb
145
+ - lib/rmonitor/capabilities/dsl.rb
146
+ - lib/rmonitor/commands/cl/base.rb
147
+ - lib/rmonitor/commands/cl/invoke.rb
148
+ - lib/rmonitor/commands/cl/list.rb
149
+ - lib/rmonitor/commands/cl/update.rb
150
+ - lib/rmonitor/commands/invoke.rb
151
+ - lib/rmonitor/commands/list.rb
152
+ - lib/rmonitor/commands/update.rb
153
+ - lib/rmonitor/config.rb
154
+ - lib/rmonitor/config/builder.rb
155
+ - lib/rmonitor/config/dsl.rb
156
+ - lib/rmonitor/invoker.rb
157
+ - lib/rmonitor/matcher.rb
158
+ - lib/rmonitor/profile/builder.rb
159
+ - lib/rmonitor/profile/dsl.rb
160
+ - lib/rmonitor/selector.rb
161
+ - lib/rmonitor/strategies/base.rb
162
+ - lib/rmonitor/strategies/optimistic.rb
163
+ - lib/rmonitor/strategies/pessimistic.rb
164
+ - lib/rmonitor/transformer.rb
50
165
  - lib/rmonitor/version.rb
51
- - rmonitor.gemspec
52
- - spec/lib/helpers/dsl_helper_spec.rb
53
- - spec/lib/helpers/profile_helpers_spec.rb
54
- - spec/lib/helpers/xrandr_read_helpers_spec.rb
55
- - spec/lib/helpers/xrandr_write_helpers_spec.rb
56
- - spec/support/device_helper.rb
57
- - spec/support/profile_helper.rb
58
- - spec/support/string_helpers.rb
166
+ - lib/rmonitor/xrandr.rb
167
+ - test/actions/builder_test.rb
168
+ - test/actions_test.rb
169
+ - test/cache_test.rb
170
+ - test/capabilities/builder_test.rb
171
+ - test/capabilities_test.rb
172
+ - test/commands/cl/invoke_test.rb
173
+ - test/commands/cl/list_test.rb
174
+ - test/commands/cl/update_test.rb
175
+ - test/commands/invoke_test.rb
176
+ - test/commands/list_test.rb
177
+ - test/commands/update_test.rb
178
+ - test/config/builder_test.rb
179
+ - test/config_test.rb
180
+ - test/matcher_test.rb
181
+ - test/profile/builder_test.rb
182
+ - test/selector_test.rb
183
+ - test/strategies/optimistic_test.rb
184
+ - test/strategies/pessimistic_test.rb
185
+ - test/test_helper.rb
186
+ - test/transformer_test.rb
187
+ - test/xrandr_test.rb
59
188
  homepage: https://github.com/badeball/rmonitor
60
189
  licenses:
61
190
  - MIT
@@ -76,8 +205,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
205
  version: '0'
77
206
  requirements: []
78
207
  rubyforge_project:
79
- rubygems_version: 2.2.2
208
+ rubygems_version: 2.4.5
80
209
  signing_key:
81
210
  specification_version: 4
82
- summary: A tool for creating monitor profiles that are easily invoked.
83
- test_files: []
211
+ summary: A tool for defining monitor profiles that are easily invoked.
212
+ test_files:
213
+ - test/config/builder_test.rb
214
+ - test/capabilities_test.rb
215
+ - test/xrandr_test.rb
216
+ - test/actions/builder_test.rb
217
+ - test/capabilities/builder_test.rb
218
+ - test/actions_test.rb
219
+ - test/cache_test.rb
220
+ - test/strategies/optimistic_test.rb
221
+ - test/strategies/pessimistic_test.rb
222
+ - test/selector_test.rb
223
+ - test/profile/builder_test.rb
224
+ - test/config_test.rb
225
+ - test/transformer_test.rb
226
+ - test/commands/update_test.rb
227
+ - test/commands/invoke_test.rb
228
+ - test/commands/cl/update_test.rb
229
+ - test/commands/cl/invoke_test.rb
230
+ - test/commands/cl/list_test.rb
231
+ - test/commands/list_test.rb
232
+ - test/test_helper.rb
233
+ - test/matcher_test.rb