openhab-jrubyscripting 5.0.0.rc6 → 5.0.0.rc9

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: '073238949bf5ae76587de8f6bfedc6ef15c2e3ab86303fe6f7c1ca8ec874c33e'
4
- data.tar.gz: 4846aaca23d7f772f558777ab8703cb6ea7d4e6b307c47a8f507fe468963620c
3
+ metadata.gz: b818f8062ce950e265819455075b42fd1cf2d1fc6270b57f547b3e93f19f0656
4
+ data.tar.gz: '08c396633d12172da0751719196247319731205b9ee6704ea4844bd3709321aa'
5
5
  SHA512:
6
- metadata.gz: 2a89863d588557b92642b12ba341c12c101b39079c18035cfec040b02172ee8b789d03c3b6f8bd7a636e9b72be6379819b654b19ec90dc6edfa7c2d4f738a515
7
- data.tar.gz: a1c2906913f3578c75ee806aa45ded0017610a5e582280bc8bf19fc08316e2dfc539b0aa2829128ed65de24cf07f038d67faa259d3dd8847f3e9aaec05a60ea2
6
+ metadata.gz: ac9760ebe37190c941c973a4526ec8b8a7a2b1584585f324f80c531849f879f7cb471bcbac1beae02f3412fb6822fbb7e50e343e6e015e5ddbb9f5b552712a70
7
+ data.tar.gz: bc0ec52bafce17c3f090984370d98695fa49bfc1799293d1d6f421764f7a8ecfbe814c6d2b7bd6b03f023c0daefa517f3595bebcd7c0af53d0ce53ee153d4360
data/lib/openhab/core.rb CHANGED
@@ -88,7 +88,7 @@ module OpenHAB
88
88
  end
89
89
  end
90
90
 
91
- import_default_presets
91
+ import_default_presets unless defined?($ir)
92
92
  end
93
93
  end
94
94
 
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.0.0.rc6"
7
+ VERSION = "5.0.0.rc9"
8
8
  end
9
9
  end
@@ -184,7 +184,7 @@ module OpenHAB
184
184
  def autorequires
185
185
  ENV["RUBYLIB"] ||= ""
186
186
  ENV["RUBYLIB"] += ":" unless ENV["RUBYLIB"].empty?
187
- ENV["RUBYLIB"] += rubylib_dir
187
+ ENV["RUBYLIB"] += rubylib_dirs.join(":")
188
188
 
189
189
  $LOAD_PATH.unshift(*ENV["RUBYLIB"]
190
190
  .split(File::PATH_SEPARATOR)
@@ -265,10 +265,15 @@ module OpenHAB
265
265
  # @return [void]
266
266
  #
267
267
  def load_rules
268
- automation_path = "#{org.openhab.core.OpenHAB.config_folder}/automation/jsr223"
268
+ automation_path = "#{org.openhab.core.OpenHAB.config_folder}/automation/ruby"
269
+ lib_dirs = rubylib_dirs.map { |d| File.join(d, "") }
270
+ lib_dirs << File.join(gem_home, "")
269
271
 
270
272
  SuspendRules.suspend_rules do
271
273
  files = Dir["#{automation_path}/**/*.rb"]
274
+ files.reject! do |f|
275
+ lib_dirs.any? { |l| f.start_with?(l) }
276
+ end
272
277
  files.sort_by { |f| [get_start_level(f), f] }.each do |f|
273
278
  load f
274
279
  rescue Exception => e
@@ -376,8 +381,17 @@ module OpenHAB
376
381
  ca.get_configuration("org.openhab.automation.jrubyscripting", nil)&.properties
377
382
  end
378
383
 
379
- def rubylib_dir
380
- jrubyscripting_config&.get("rubylib") || "#{org.openhab.core.OpenHAB.config_folder}/automation/lib/ruby"
384
+ def gem_home
385
+ gem_home = jrubyscripting_config&.get("gem_home")
386
+ return "#{org.openhab.core.OpenHAB.config_folder}/automation/ruby/.gem" unless gem_home
387
+
388
+ # strip everything after the first {
389
+ gem_home.split("{", 2).first
390
+ end
391
+
392
+ def rubylib_dirs
393
+ jrubyscripting_config&.get("rubylib")&.split(File::PATH_SEPARATOR) ||
394
+ ["#{org.openhab.core.OpenHAB.config_folder}/automation/ruby/lib"]
381
395
  end
382
396
 
383
397
  def get_start_level(file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-jrubyscripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc6
4
+ version: 5.0.0.rc9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -488,7 +488,6 @@ files:
488
488
  - lib/openhab/rspec/shell.rb
489
489
  - lib/openhab/rspec/suspend_rules.rb
490
490
  - lib/openhab/yard.rb
491
- - lib/openhab/yard/base_helper.rb
492
491
  - lib/openhab/yard/cli/stats.rb
493
492
  - lib/openhab/yard/code_objects/group_object.rb
494
493
  - lib/openhab/yard/code_objects/java/base.rb
@@ -503,8 +502,6 @@ files:
503
502
  - lib/openhab/yard/handlers/jruby/java_import_handler.rb
504
503
  - lib/openhab/yard/handlers/jruby/mixin_handler.rb
505
504
  - lib/openhab/yard/html_helper.rb
506
- - lib/openhab/yard/markdown_directive.rb
507
- - lib/openhab/yard/markdown_helper.rb
508
505
  - lib/openhab/yard/tags/constant_directive.rb
509
506
  - lib/openhab/yard/tags/group_directive.rb
510
507
  - lib/openhab/yard/tags/library.rb
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "nokogiri"
4
-
5
- module OpenHAB
6
- module YARD
7
- # @!visibility private
8
- module BaseHelper
9
- def preprocess(text)
10
- html = Nokogiri::HTML5.fragment(text)
11
-
12
- context = if ENV["ADDON"]
13
- :addon
14
- else
15
- :yard
16
- end
17
-
18
- # process directives on which content is supposed to be included in this context
19
- node = html.children.first
20
- loop do
21
- break unless node
22
-
23
- next_node = node.next
24
-
25
- if node.comment? && (directive = MarkdownDirective.new(node)).directive?
26
- next_node = directive.process(context) || next_node
27
- end
28
- node = next_node
29
- end
30
-
31
- html.to_s
32
- end
33
-
34
- def link_object(obj, title = nil, *)
35
- ::YARD::Handlers::JRuby::Base.infer_java_class(obj) if obj.is_a?(String)
36
- obj = ::YARD::Registry.resolve(object, obj, true, true) if obj.is_a?(String)
37
- if obj.is_a?(::YARD::CodeObjects::Java::Base) && (see = obj.docstring.tag(:see))
38
- # link to the first see tag
39
- return linkify(see.name, title&.to_s || see.text)
40
- end
41
-
42
- super
43
- end
44
- end
45
- end
46
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "nokogiri"
4
-
5
- module OpenHAB
6
- module YARD
7
- # @!visibility private
8
- class MarkdownDirective
9
- attr_reader :comment, :context
10
-
11
- def initialize(comment)
12
- @comment = comment
13
- @lines = comment.text.split("\n")
14
- directive_text = @lines.first.strip
15
-
16
- @multiline = @lines.length > 1
17
- @directive = false
18
- return unless (match = directive_text.match(%r{^<(/)?(!)?([a-z]+)-only>$}))
19
-
20
- @closing = match[1]
21
- @context = match[3].to_sym
22
- @inverted = match[2]
23
-
24
- if closing? && multiline?
25
- log.warn "In file `#{file}':#{line}: Multiline closing directives are not allowed (#{directive_text})."
26
- return
27
- end
28
- @directive = true
29
- end
30
-
31
- def directive?
32
- @directive
33
- end
34
-
35
- def multiline?
36
- @multiline
37
- end
38
-
39
- def closing?
40
- @closing
41
- end
42
-
43
- def inverted?
44
- @inverted
45
- end
46
-
47
- def match?(context)
48
- result = context == self.context
49
- result = !result if inverted?
50
- result
51
- end
52
-
53
- def closing_directive
54
- return nil if multiline?
55
-
56
- unless instance_variable_defined?(:@closing_directive)
57
- next_node = @comment.next
58
- loop do
59
- return @closing_directive = nil unless next_node
60
-
61
- if next_node.comment?
62
- directive = MarkdownDirective.new(next_node)
63
- if directive.directive? &&
64
- directive.closing? &&
65
- directive.context == context &&
66
- directive.inverted? == inverted?
67
- return @closing_directive = next_node
68
- end
69
- end
70
-
71
- next_node = next_node.next
72
- end
73
- end
74
- @closing_directive
75
- end
76
-
77
- def process(context)
78
- return unless directive?
79
- return if closing?
80
-
81
- matched = match?(context)
82
-
83
- # if it's a matched multiline, extract the contents and insert them directly,
84
- # and remove the comment
85
- if multiline?
86
- result = comment.next
87
- comment.before(Nokogiri::HTML5.fragment(@lines[1..].join("\n"))) if matched
88
- comment.remove
89
- return result
90
- end
91
-
92
- unless closing_directive
93
- log.warn "In file `#{file}':#{line}: Unmatched directive <#{"!" if inverted?}#{context}-only>."
94
- return
95
- end
96
-
97
- result = closing_directive.next
98
-
99
- unless matched
100
- # remove all nodes between the opening and closing directives
101
- comment.next.remove while comment.next != closing_directive
102
- end
103
- # now remove the directives themselves
104
- closing_directive.remove
105
- comment.remove
106
- result
107
- end
108
-
109
- def file
110
- ((defined?(@file) && @file) ? @file.filename : object.file) || "(unknown)"
111
- end
112
-
113
- def line
114
- return @line if instance_variable_defined?(@line)
115
-
116
- @line = (if defined?(@file) && @file
117
- 1
118
- else
119
- (object.docstring.line_range ? object.docstring.line_range.first : 1)
120
- end) + (match ? $`.count("\n") : 0)
121
- @line += comment.line - 1
122
- end
123
- end
124
- end
125
- end
@@ -1,99 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "nokogiri"
4
-
5
- module OpenHAB
6
- module YARD
7
- # @!visibility private
8
- module MarkdownHelper
9
- # @group Linking Objects and URLs
10
-
11
- def diskfile
12
- preprocess(super)
13
- end
14
-
15
- # mostly copied from HTMLHelper
16
- def resolve_links(text)
17
- blockquotes = false
18
- text.gsub(%r{(```)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+</|$)}m) do |str|
19
- blockquote = $1
20
- escape = $2
21
- name = $3
22
- title = $4
23
- match = $&
24
- if blockquote
25
- blockquotes = !blockquotes
26
- next str
27
- end
28
- next str if blockquotes
29
-
30
- next(match[1..-1]) if escape
31
-
32
- next(match) if name[0, 1] == '|'
33
-
34
- if object.is_a?(String)
35
- object
36
- else
37
- link = linkify(name, title)
38
- if (link == name || link == title) && (name + ' ' + link !~ /\A<a\s.*>/)
39
- match = /(.+)?(\{#{Regexp.quote name}(?:\s.*?)?\})(.+)?/.match(text)
40
- file = (defined?(@file) && @file ? @file.filename : object.file) || '(unknown)'
41
- line = (defined?(@file) && @file ? 1 : (object.docstring.line_range ? object.docstring.line_range.first : 1)) + (match ? $`.count("\n") : 0)
42
- log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text" + (match ? ":" : ".") +
43
- "\n\t" + (match[1] ? '...' : '') + match[2].delete("\n") + (match[3] ? '...' : '') if match
44
- end
45
-
46
- link
47
- end
48
- end
49
- end
50
-
51
- # mostly copied from HTMLHelper
52
- def link_object(obj, title = nil, anchor = nil, relative = true)
53
- return title if obj.nil?
54
-
55
- obj = Registry.resolve(object, obj, true, true) if obj.is_a?(String)
56
-
57
- was_const = false
58
- # Re-link references to constants that are aliases to their target. But keep
59
- # their current title.
60
- while obj.is_a?(CodeObjects::ConstantObject) && obj.target
61
- title ||= h(object.relative_path(obj)).to_s
62
- was_const = true
63
- obj = obj.target
64
- end
65
- return link_object(obj, title, anchor, relative) if was_const
66
-
67
- title = if title
68
- title.to_s
69
- elsif object.is_a?(CodeObjects::Base)
70
- # Check if we're linking to a class method in the current
71
- # object. If we are, create a title in the format of
72
- # "CurrentClass.method_name"
73
- if obj.is_a?(CodeObjects::MethodObject) && obj.scope == :class && obj.parent == object
74
- h([object.name, obj.sep, obj.name].join)
75
- elsif obj.title != obj.path
76
- h(obj.title)
77
- else
78
- h(object.relative_path(obj))
79
- end
80
- else
81
- h(obj.title)
82
- end
83
- return title unless serializer
84
- return title if obj.is_a?(CodeObjects::Proxy)
85
-
86
- link = url_for(obj, anchor, relative)
87
- link ? link_url(link, title, title: h("#{obj.title} (#{obj.type})")) : title
88
- rescue Parser::UndocumentableError
89
- log.warn "The namespace of link #{obj.inspect} is a constant or invalid."
90
- title || obj.to_s
91
- end
92
-
93
- def link_url(url, title = nil, _params = nil)
94
- title ||= url
95
- "[#{title}](#{url})"
96
- end
97
- end
98
- end
99
- end