openhab-jrubyscripting 5.0.0.rc4 → 5.0.0.rc6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab/core/actions.rb +21 -9
  3. data/lib/openhab/core/dependency_tracking.rb +34 -0
  4. data/lib/openhab/core/entity_lookup.rb +132 -78
  5. data/lib/openhab/core/events/item_channel_link.rb +2 -2
  6. data/lib/openhab/core/events/item_command_event.rb +1 -1
  7. data/lib/openhab/core/events/item_event.rb +2 -2
  8. data/lib/openhab/core/events/item_state_changed_event.rb +1 -1
  9. data/lib/openhab/core/events/thing.rb +1 -1
  10. data/lib/openhab/core/items/accepted_data_types.rb +2 -2
  11. data/lib/openhab/core/items/contact_item.rb +1 -1
  12. data/lib/openhab/core/items/dimmer_item.rb +2 -2
  13. data/lib/openhab/core/items/generic_item.rb +45 -224
  14. data/lib/openhab/core/items/group_item.rb +5 -3
  15. data/lib/openhab/core/items/image_item.rb +2 -2
  16. data/lib/openhab/core/items/item.rb +219 -0
  17. data/lib/openhab/core/items/metadata/hash.rb +1 -1
  18. data/lib/openhab/core/items/metadata/namespace_hash.rb +1 -1
  19. data/lib/openhab/core/items/persistence.rb +19 -10
  20. data/lib/openhab/core/items/provider.rb +2 -2
  21. data/lib/openhab/core/items/proxy.rb +68 -7
  22. data/lib/openhab/core/items/registry.rb +6 -6
  23. data/lib/openhab/core/items/semantics/enumerable.rb +6 -6
  24. data/lib/openhab/core/items/semantics.rb +8 -7
  25. data/lib/openhab/core/items.rb +3 -2
  26. data/lib/openhab/core/provider.rb +14 -7
  27. data/lib/openhab/core/rules/registry.rb +2 -2
  28. data/lib/openhab/core/rules.rb +1 -1
  29. data/lib/openhab/core/script_handling.rb +6 -6
  30. data/lib/openhab/core/things/channel.rb +1 -1
  31. data/lib/openhab/core/things/channel_uid.rb +2 -2
  32. data/lib/openhab/core/things/item_channel_link.rb +2 -2
  33. data/lib/openhab/core/things/links/provider.rb +2 -2
  34. data/lib/openhab/core/things/profile_callback.rb +1 -1
  35. data/lib/openhab/core/things/registry.rb +1 -1
  36. data/lib/openhab/core/things/thing.rb +1 -1
  37. data/lib/openhab/core/timer.rb +21 -10
  38. data/lib/openhab/core/types/date_time_type.rb +4 -4
  39. data/lib/openhab/core/types/hsb_type.rb +2 -2
  40. data/lib/openhab/core/types/point_type.rb +1 -1
  41. data/lib/openhab/core/types/quantity_type.rb +1 -1
  42. data/lib/openhab/core/types.rb +1 -1
  43. data/lib/openhab/core/uid.rb +1 -1
  44. data/lib/openhab/core/value_cache.rb +188 -0
  45. data/lib/openhab/core.rb +57 -15
  46. data/lib/openhab/core_ext/between.rb +32 -0
  47. data/lib/openhab/core_ext/java/duration.rb +1 -0
  48. data/lib/openhab/core_ext/java/local_date.rb +1 -0
  49. data/lib/openhab/core_ext/java/local_time.rb +1 -0
  50. data/lib/openhab/core_ext/java/month.rb +12 -1
  51. data/lib/openhab/core_ext/java/month_day.rb +2 -0
  52. data/lib/openhab/core_ext/java/zoned_date_time.rb +4 -4
  53. data/lib/openhab/core_ext/ruby/date.rb +3 -1
  54. data/lib/openhab/core_ext/ruby/date_time.rb +1 -0
  55. data/lib/openhab/core_ext/ruby/symbol.rb +7 -0
  56. data/lib/openhab/core_ext/ruby/time.rb +1 -0
  57. data/lib/openhab/dsl/items/builder.rb +17 -10
  58. data/lib/openhab/dsl/items/ensure.rb +5 -5
  59. data/lib/openhab/dsl/items/timed_command.rb +5 -5
  60. data/lib/openhab/dsl/rules/automation_rule.rb +54 -40
  61. data/lib/openhab/dsl/rules/builder.rb +128 -79
  62. data/lib/openhab/dsl/rules/guard.rb +5 -5
  63. data/lib/openhab/dsl/rules/name_inference.rb +21 -2
  64. data/lib/openhab/dsl/rules/rule_triggers.rb +3 -3
  65. data/lib/openhab/dsl/rules/terse.rb +1 -0
  66. data/lib/openhab/dsl/rules/triggers/changed.rb +27 -24
  67. data/lib/openhab/dsl/rules/triggers/command.rb +6 -5
  68. data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +3 -3
  69. data/lib/openhab/dsl/rules/triggers/cron/cron.rb +2 -2
  70. data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +6 -6
  71. data/lib/openhab/dsl/rules/triggers/updated.rb +5 -5
  72. data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +11 -12
  73. data/lib/openhab/dsl/things/builder.rb +73 -14
  74. data/lib/openhab/dsl/version.rb +2 -2
  75. data/lib/openhab/dsl.rb +45 -17
  76. data/lib/openhab/log.rb +5 -5
  77. data/lib/openhab/rspec/configuration.rb +5 -5
  78. data/lib/openhab/rspec/example_group.rb +1 -1
  79. data/lib/openhab/rspec/helpers.rb +5 -5
  80. data/lib/openhab/rspec/hooks.rb +19 -1
  81. data/lib/openhab/rspec/karaf.rb +13 -21
  82. data/lib/openhab/rspec/mocks/persistence_service.rb +15 -0
  83. data/lib/openhab/rspec/mocks/thing_handler.rb +2 -2
  84. data/lib/openhab/rspec/suspend_rules.rb +2 -1
  85. data/lib/openhab/yard/base_helper.rb +46 -0
  86. data/lib/openhab/yard/html_helper.rb +3 -3
  87. data/lib/openhab/yard/markdown_directive.rb +125 -0
  88. data/lib/openhab/yard/markdown_helper.rb +99 -0
  89. metadata +15 -7
@@ -0,0 +1,99 @@
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-jrubyscripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc4
4
+ version: 5.0.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2022-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '7.1'
75
+ version: '8.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '7.1'
82
+ version: '8.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: cuke_linter
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '12.0'
201
+ version: '13.0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '12.0'
208
+ version: '13.0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rspec
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -327,6 +327,7 @@ extra_rdoc_files: []
327
327
  files:
328
328
  - lib/openhab/core.rb
329
329
  - lib/openhab/core/actions.rb
330
+ - lib/openhab/core/dependency_tracking.rb
330
331
  - lib/openhab/core/entity_lookup.rb
331
332
  - lib/openhab/core/events.rb
332
333
  - lib/openhab/core/events/abstract_event.rb
@@ -346,6 +347,7 @@ files:
346
347
  - lib/openhab/core/items/generic_item.rb
347
348
  - lib/openhab/core/items/group_item.rb
348
349
  - lib/openhab/core/items/image_item.rb
350
+ - lib/openhab/core/items/item.rb
349
351
  - lib/openhab/core/items/location_item.rb
350
352
  - lib/openhab/core/items/metadata.rb
351
353
  - lib/openhab/core/items/metadata/hash.rb
@@ -408,7 +410,9 @@ files:
408
410
  - lib/openhab/core/types/un_def_type.rb
409
411
  - lib/openhab/core/types/up_down_type.rb
410
412
  - lib/openhab/core/uid.rb
413
+ - lib/openhab/core/value_cache.rb
411
414
  - lib/openhab/core_ext.rb
415
+ - lib/openhab/core_ext/between.rb
412
416
  - lib/openhab/core_ext/java/class.rb
413
417
  - lib/openhab/core_ext/java/duration.rb
414
418
  - lib/openhab/core_ext/java/list.rb
@@ -428,6 +432,7 @@ files:
428
432
  - lib/openhab/core_ext/ruby/date_time.rb
429
433
  - lib/openhab/core_ext/ruby/numeric.rb
430
434
  - lib/openhab/core_ext/ruby/range.rb
435
+ - lib/openhab/core_ext/ruby/symbol.rb
431
436
  - lib/openhab/core_ext/ruby/time.rb
432
437
  - lib/openhab/dsl.rb
433
438
  - lib/openhab/dsl/events.rb
@@ -483,6 +488,7 @@ files:
483
488
  - lib/openhab/rspec/shell.rb
484
489
  - lib/openhab/rspec/suspend_rules.rb
485
490
  - lib/openhab/yard.rb
491
+ - lib/openhab/yard/base_helper.rb
486
492
  - lib/openhab/yard/cli/stats.rb
487
493
  - lib/openhab/yard/code_objects/group_object.rb
488
494
  - lib/openhab/yard/code_objects/java/base.rb
@@ -497,6 +503,8 @@ files:
497
503
  - lib/openhab/yard/handlers/jruby/java_import_handler.rb
498
504
  - lib/openhab/yard/handlers/jruby/mixin_handler.rb
499
505
  - lib/openhab/yard/html_helper.rb
506
+ - lib/openhab/yard/markdown_directive.rb
507
+ - lib/openhab/yard/markdown_helper.rb
500
508
  - lib/openhab/yard/tags/constant_directive.rb
501
509
  - lib/openhab/yard/tags/group_directive.rb
502
510
  - lib/openhab/yard/tags/library.rb
@@ -527,5 +535,5 @@ requirements: []
527
535
  rubygems_version: 3.3.7
528
536
  signing_key:
529
537
  specification_version: 4
530
- summary: JRuby Helper Libraries for OpenHAB Scripting
538
+ summary: JRuby Helper Libraries for openHAB Scripting
531
539
  test_files: []