i3ipc 0.2.0 → 0.4.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.
- 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 +15 -3
- 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 +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7e3d2c510024a85232a57b5f85b746e2048ecb7d502c7143c45e7288cbe0733
|
4
|
+
data.tar.gz: '059d5c94bb5cf00a0b9d2faaa01a96e27099fc2c5d9c9971382bf0d05152e0e7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea322a9f4842087079a18be0cdc56a287e0891de881bd6cff69f955bbdeac2f28f39100ce44af4aca887ffdf346ea7279d7251785d3c29ceecce8be47c8f1aca
|
7
|
+
data.tar.gz: 487a918c2b6aa1b108ede111df9725477a3ea49fc8c9ae1a294b30f47d983d27c6790d50e3c2f0c2844c6104b68c955606f37267d3835ad8cf888706634358d4
|
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,9 +150,21 @@ module I3Ipc
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def get_socketpath
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
if !ENV['I3SOCK'].nil?
|
154
|
+
ENV['I3SOCK']
|
155
|
+
else
|
156
|
+
cmd = if system('i3 --version')
|
157
|
+
'i3'
|
158
|
+
elsif system('sway --version')
|
159
|
+
'sway'
|
160
|
+
else
|
161
|
+
raise 'Unable to find i3 compatible window manager'
|
162
|
+
end
|
163
|
+
|
164
|
+
path = `#{cmd} --get-socketpath`.chomp!
|
165
|
+
raise 'Unable to get i3 compatible socketpath' unless path
|
166
|
+
path
|
167
|
+
end
|
156
168
|
end
|
157
169
|
|
158
170
|
def check_connected
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitalii Elengaupt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-24 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
|
@@ -85,7 +87,7 @@ homepage: https://github.com/veelenga/i3ipc-ruby
|
|
85
87
|
licenses:
|
86
88
|
- MIT
|
87
89
|
metadata: {}
|
88
|
-
post_install_message:
|
90
|
+
post_install_message:
|
89
91
|
rdoc_options: []
|
90
92
|
require_paths:
|
91
93
|
- lib
|
@@ -100,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
- !ruby/object:Gem::Version
|
101
103
|
version: '0'
|
102
104
|
requirements: []
|
103
|
-
|
104
|
-
|
105
|
-
signing_key:
|
105
|
+
rubygems_version: 3.2.32
|
106
|
+
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: Interprocess communication with i3 wm
|
108
109
|
test_files:
|
@@ -111,4 +112,3 @@ test_files:
|
|
111
112
|
- spec/i3ipc/protocol_spec.rb
|
112
113
|
- spec/i3ipc/reply_spec.rb
|
113
114
|
- spec/spec_helper.rb
|
114
|
-
has_rdoc:
|