rspec-openhab-scripting 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88c81621c9a862e81d978ad293b6c3855e802c6f178484e10261a1c50033e152
4
- data.tar.gz: 1dd7de9a0358d08e5006e208870af61f9d9c7b777e20cccccfb946b131b577bd
3
+ metadata.gz: 116f3664ed9d88e87a4030cf7006dc82c3c517b7b6f54b2611989f5aa48f7988
4
+ data.tar.gz: d257ff1821dad6bca67eaa1cb848d3cc55b1a05f7cb02d5f20e9e34d2b2c3c17
5
5
  SHA512:
6
- metadata.gz: af8b2b36147936afff2729ce7050e2779910547cc91dc7e6463bf9fd8653b019f9db23b08cbfb526157dd46f02cff7b49defdb17de6aafa4e39c553d12dd551c
7
- data.tar.gz: 2672ed326d2c88e5a10cd3144524383da703d48e16e79eda5c44ac7a9eaf6045e5266405458855fa124a5043a0ed14e2fc5a39f31f45a2202bd7877b0bee2906
6
+ metadata.gz: c29fdc081461392dcad67246de4b784c012c0963d971acc1ca4f2c4f78e9229698ef36c7c1946c1b14e290b7bf11c77977f4d20a0e39b41fa950b3e2609663b6
7
+ data.tar.gz: 859f14916f43496a242adf17896a2d8bb5cd46027d101c5e3da70ebc215fba5bcecf9f71d0dd4eb41b9022e8879d427af3cbb4624a909af33864f5011ccdaeee
@@ -145,10 +145,11 @@ module RSpec
145
145
  end
146
146
 
147
147
  def load_rules
148
- automation_path = "#{org.openhab.core.OpenHAB.config_folder}/automation/jsr223/ruby/personal"
148
+ automation_path = "#{org.openhab.core.OpenHAB.config_folder}/automation/jsr223"
149
149
 
150
150
  RSpec::OpenHAB::SuspendRules.suspend_rules do
151
- Dir["#{automation_path}/*.rb"].each do |f|
151
+ files = Dir["#{automation_path}/**/*.rb"]
152
+ files.sort_by { |f| [get_start_level(f), f] }.each do |f|
152
153
  load f
153
154
  rescue Exception => e
154
155
  warn "Failed loading #{f}: #{e.inspect}"
@@ -184,6 +185,12 @@ module RSpec
184
185
  jrubyscripting_config&.get("rubylib") || "#{org.openhab.core.OpenHAB.config_folder}/automation/lib/ruby"
185
186
  end
186
187
 
188
+ def get_start_level(file)
189
+ return ($1 || $2).to_i if file =~ %r{/sl(\d{2})/[^/]+$|\.sl(\d{2})\.[^/.]+$}
190
+
191
+ 50
192
+ end
193
+
187
194
  EMACS_MODELINE_REGEXP = /# -\*-(.+)-\*-/.freeze
188
195
 
189
196
  def parse_emacs_modeline(line)
@@ -35,6 +35,8 @@ module RSpec
35
35
  end
36
36
 
37
37
  config.before do
38
+ next unless defined?(::OpenHAB::DSL::Items::ItemProvider)
39
+
38
40
  @item_provider = ::OpenHAB::DSL::Items::ItemProvider.send(:new)
39
41
  allow(::OpenHAB::DSL::Items::ItemProvider).to receive(:instance).and_return(@item_provider)
40
42
  end
@@ -44,7 +46,7 @@ module RSpec
44
46
  (::OpenHAB::Core.rule_registry.all.map(&:uid) - @known_rules).each do |uid|
45
47
  ::OpenHAB::Core.rule_registry.remove(uid)
46
48
  end
47
- $ir.remove_provider(@item_provider) if @item_provider
49
+ $ir.remove_provider(@item_provider) if instance_variable_defined?(:@item_provider) && @item_provider
48
50
  ::OpenHAB::DSL::Timers.timer_manager.cancel_all
49
51
  Timecop.return
50
52
  restore_autoupdate_items
@@ -705,6 +705,18 @@ module RSpec
705
705
  # workaround for https://github.com/openhab/openhab-core/pull/3092
706
706
  def reset_start_level_service
707
707
  sls = ::OpenHAB::Core::OSGI.service("org.openhab.core.service.StartLevelService")
708
+
709
+ unless sls
710
+ # try a different (hacky!) way to get it, since in OpenHAB 3.2.0 it's not exposed as a service
711
+ scr = ::OpenHAB::Core::OSGI.service("org.osgi.service.component.runtime.ServiceComponentRuntime")
712
+ scr.class.field_reader :componentRegistry
713
+ cr = scr.componentRegistry
714
+
715
+ oh_core_bundle = org.osgi.framework.FrameworkUtil.get_bundle(org.openhab.core.OpenHAB)
716
+ ch = cr.get_component_holder(oh_core_bundle, "org.openhab.core.service.StartLevelService")
717
+ sls = ch&.components&.first&.component_instance&.instance
718
+ end
719
+
708
720
  # no SLS yet? then we couldn't have hit the bug
709
721
  return unless sls
710
722
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OpenHAB
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,184 +1,184 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: faraday
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: '2.3'
19
- name: faraday
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: net-http-persistent
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - "~>"
31
32
  - !ruby/object:Gem::Version
32
33
  version: '4.0'
33
- name: net-http-persistent
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: openhab-scripting
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - "~>"
45
46
  - !ruby/object:Gem::Version
46
47
  version: '4.42'
47
- name: openhab-scripting
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.42'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: rspec-core
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
61
  version: '3.11'
61
- name: rspec-core
62
- prerelease: false
63
62
  type: :runtime
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.11'
69
69
  - !ruby/object:Gem::Dependency
70
+ name: timecop
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - "~>"
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0.9'
75
- name: timecop
76
- prerelease: false
77
76
  type: :runtime
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
+ name: irb
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - "~>"
87
88
  - !ruby/object:Gem::Version
88
89
  version: '1.4'
89
- name: irb
90
- prerelease: false
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.4'
97
97
  - !ruby/object:Gem::Dependency
98
+ name: rake
98
99
  requirement: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - "~>"
101
102
  - !ruby/object:Gem::Version
102
103
  version: '13.0'
103
- name: rake
104
- prerelease: false
105
104
  type: :development
105
+ prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '13.0'
111
111
  - !ruby/object:Gem::Dependency
112
+ name: rspec
112
113
  requirement: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - "~>"
115
116
  - !ruby/object:Gem::Version
116
117
  version: '3.11'
117
- name: rspec
118
- prerelease: false
119
118
  type: :development
119
+ prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.11'
125
125
  - !ruby/object:Gem::Dependency
126
+ name: rubocop
126
127
  requirement: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - "~>"
129
130
  - !ruby/object:Gem::Version
130
131
  version: '1.23'
131
- name: rubocop
132
- prerelease: false
133
132
  type: :development
133
+ prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.23'
139
139
  - !ruby/object:Gem::Dependency
140
+ name: rubocop-performance
140
141
  requirement: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - "~>"
143
144
  - !ruby/object:Gem::Version
144
145
  version: '1.12'
145
- name: rubocop-performance
146
- prerelease: false
147
146
  type: :development
147
+ prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '1.12'
153
153
  - !ruby/object:Gem::Dependency
154
+ name: rubocop-rake
154
155
  requirement: !ruby/object:Gem::Requirement
155
156
  requirements:
156
157
  - - "~>"
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0.6'
159
- name: rubocop-rake
160
- prerelease: false
161
160
  type: :development
161
+ prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.6'
167
167
  - !ruby/object:Gem::Dependency
168
+ name: rubocop-rspec
168
169
  requirement: !ruby/object:Gem::Requirement
169
170
  requirements:
170
171
  - - "~>"
171
172
  - !ruby/object:Gem::Version
172
173
  version: '2.11'
173
- name: rubocop-rspec
174
- prerelease: false
175
174
  type: :development
175
+ prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '2.11'
181
- description:
181
+ description:
182
182
  email: cody@cutrer.us'
183
183
  executables: []
184
184
  extensions: []
@@ -210,7 +210,7 @@ licenses:
210
210
  - MIT
211
211
  metadata:
212
212
  rubygems_mfa_required: 'true'
213
- post_install_message:
213
+ post_install_message:
214
214
  rdoc_options: []
215
215
  require_paths:
216
216
  - lib
@@ -225,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  - !ruby/object:Gem::Version
226
226
  version: '0'
227
227
  requirements: []
228
- rubygems_version: 3.2.29
229
- signing_key:
228
+ rubygems_version: 3.3.7
229
+ signing_key:
230
230
  specification_version: 4
231
231
  summary: Library testing OpenHAB ruby rules with rspec.
232
232
  test_files: []