i3ipc 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/Gemfile +9 -4
- data/Guardfile +5 -0
- data/lib/i3ipc/connection.rb +4 -5
- data/lib/i3ipc/protocol.rb +9 -2
- data/lib/i3ipc/reply.rb +1 -1
- data/lib/i3ipc/version.rb +1 -1
- data/spec/i3ipc/connection_spec.rb +64 -26
- data/spec/i3ipc/protocol_spec.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 307a0123538855e09af5e01c6484533407be5bc08d8352d02c6073e439abb920
|
4
|
+
data.tar.gz: 18c8fe77d241cd6d357bb90b71e4dd68f50d6bcd01be3a8328861b037ca738b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974bd5a6d1ec54be2d29807d7beb58b7d8bb65c518288efdc8a59470965a67157a8a5e463d62fe5bcf01b2d5c79ce096c1ae90291cff1908734b5335c8f56320
|
7
|
+
data.tar.gz: 94f3a38c802b40dea4f4f3e8e9164c108a714c3179ca8ebf51dfe3dfcc33c4d1641d148d512c0ec30398030318be322236124c80ac5198060eaa330f4bd96f69
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --color
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/lib/i3ipc/connection.rb
CHANGED
@@ -27,9 +27,9 @@ module I3Ipc
|
|
27
27
|
# con.close
|
28
28
|
class Connection
|
29
29
|
|
30
|
-
def initialize(
|
31
|
-
@protocol =
|
32
|
-
open
|
30
|
+
def initialize(protocol = Protocol.new, autoconnect = true)
|
31
|
+
@protocol = protocol
|
32
|
+
open if autoconnect
|
33
33
|
end
|
34
34
|
|
35
35
|
def open
|
@@ -89,7 +89,7 @@ module I3Ipc
|
|
89
89
|
|
90
90
|
private
|
91
91
|
|
92
|
-
def reply_for(type, message = nil
|
92
|
+
def reply_for(type, message = nil)
|
93
93
|
@protocol.send(type, message)
|
94
94
|
|
95
95
|
Reply.parse(@protocol.receive type)
|
@@ -106,6 +106,5 @@ module I3Ipc
|
|
106
106
|
else raise WrongEvent.new(event)
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
110
109
|
end
|
111
110
|
end
|
data/lib/i3ipc/protocol.rb
CHANGED
@@ -150,8 +150,15 @@ module I3Ipc
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def get_socketpath
|
153
|
-
|
154
|
-
|
153
|
+
cmd = if system('i3 --version')
|
154
|
+
'i3'
|
155
|
+
elsif system('sway --version')
|
156
|
+
'sway'
|
157
|
+
else
|
158
|
+
raise 'Unable to find i3 compatible window manager'
|
159
|
+
end
|
160
|
+
path = `#{cmd} --get-socketpath`.chomp!
|
161
|
+
raise 'Unable to get i3 compatible socketpath' unless path
|
155
162
|
path
|
156
163
|
end
|
157
164
|
|
data/lib/i3ipc/reply.rb
CHANGED
@@ -45,7 +45,7 @@ module I3Ipc
|
|
45
45
|
parse_data JSON.parse(response)
|
46
46
|
end
|
47
47
|
|
48
|
-
# Indicates whether this reply
|
48
|
+
# Indicates whether this reply is successful or not.
|
49
49
|
#
|
50
50
|
# @return false if this reply represents and error from i3-ipc protocol.
|
51
51
|
# Otherwise returns true, which means that request is successful and
|
data/lib/i3ipc/version.rb
CHANGED
@@ -3,43 +3,81 @@ require 'spec_helper'
|
|
3
3
|
module I3Ipc
|
4
4
|
describe Connection do
|
5
5
|
|
6
|
+
let(:protocol) { Protocol.new '' }
|
7
|
+
let(:stub_protocol) do
|
8
|
+
allow(protocol).to receive(:send)
|
9
|
+
allow(protocol).to receive(:receive)
|
10
|
+
end
|
11
|
+
subject { Connection.new protocol, false }
|
12
|
+
|
6
13
|
describe '#command' do
|
14
|
+
it 'returns i3ipc reply' do
|
15
|
+
stub_protocol.and_return('{}')
|
16
|
+
expect(subject.command('cmd')).to be_a Reply
|
17
|
+
end
|
7
18
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@protocol = Protocol.new ''
|
12
|
-
end
|
13
|
-
end
|
19
|
+
it 'sends correct command and receives success response' do
|
20
|
+
stub_protocol.and_return({ success: true }.to_json)
|
21
|
+
expect(subject.command('focus left').success?).to be true
|
14
22
|
end
|
15
23
|
|
16
|
-
it '
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
it 'sends incorrect command and receives error response' do
|
25
|
+
stub_protocol.and_return({ success: false, error: 'wrong command' }.to_json)
|
26
|
+
reply = subject.command('my command')
|
27
|
+
expect(reply.success).to be false
|
28
|
+
expect(reply.error).to eql 'wrong command'
|
29
|
+
end
|
30
|
+
end
|
20
31
|
|
21
|
-
|
32
|
+
describe '#workspaces' do
|
33
|
+
it 'returns i3ipc reply' do
|
34
|
+
stub_protocol.and_return('{}')
|
35
|
+
expect(subject.workspaces).to be_a Reply
|
22
36
|
end
|
37
|
+
end
|
23
38
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
39
|
+
describe '#outputs' do
|
40
|
+
it 'returns i3ipc reply' do
|
41
|
+
stub_protocol.and_return('{}')
|
42
|
+
expect(subject.outputs).to be_a Reply
|
43
|
+
end
|
44
|
+
end
|
28
45
|
|
29
|
-
|
30
|
-
|
31
|
-
|
46
|
+
describe '#tree' do
|
47
|
+
it 'returns i3ipc reply' do
|
48
|
+
stub_protocol.and_return('{}')
|
49
|
+
expect(subject.tree).to be_a Reply
|
32
50
|
end
|
51
|
+
end
|
33
52
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
53
|
+
describe '#marks' do
|
54
|
+
it 'returns i3ipc reply' do
|
55
|
+
stub_protocol.and_return('{}')
|
56
|
+
expect(subject.marks).to be_a Reply
|
57
|
+
end
|
58
|
+
end
|
38
59
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
expect(
|
60
|
+
describe '#bar_config' do
|
61
|
+
it 'returns i3ipc reply' do
|
62
|
+
stub_protocol.and_return('{}')
|
63
|
+
expect(subject.bar_config).to be_a Reply
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#version' do
|
68
|
+
it 'returns i3ipc reply' do
|
69
|
+
stub_protocol.and_return('{}')
|
70
|
+
expect(subject.version).to be_a Reply
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'able to parse version attributes' do
|
74
|
+
resp = { human_readable: '4.2', minor: 2, patch: 0, major: 4 }
|
75
|
+
stub_protocol.and_return(resp.to_json)
|
76
|
+
reply = subject.version
|
77
|
+
expect(reply.human_readable).to eq resp[:human_readable]
|
78
|
+
expect(reply.minor).to eq resp[:minor]
|
79
|
+
expect(reply.patch).to eq resp[:patch]
|
80
|
+
expect(reply.major).to eq resp[:major]
|
43
81
|
end
|
44
82
|
end
|
45
83
|
end
|
data/spec/i3ipc/protocol_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i3ipc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitalii Elengaupt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,9 +64,11 @@ extensions: []
|
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
66
|
- ".gitignore"
|
67
|
+
- ".rspec"
|
67
68
|
- ".travis.yml"
|
68
69
|
- ".yardopts"
|
69
70
|
- Gemfile
|
71
|
+
- Guardfile
|
70
72
|
- LICENSE.txt
|
71
73
|
- README.md
|
72
74
|
- Rakefile
|
@@ -101,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
103
|
version: '0'
|
102
104
|
requirements: []
|
103
105
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.7.6
|
105
107
|
signing_key:
|
106
108
|
specification_version: 4
|
107
109
|
summary: Interprocess communication with i3 wm
|
@@ -111,4 +113,3 @@ test_files:
|
|
111
113
|
- spec/i3ipc/protocol_spec.rb
|
112
114
|
- spec/i3ipc/reply_spec.rb
|
113
115
|
- spec/spec_helper.rb
|
114
|
-
has_rdoc:
|