openhab-jrubyscripting 5.0.0.rc10 → 5.0.0.rc11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab/core/actions/audio.rb +47 -0
  3. data/lib/openhab/core/actions/ephemeris.rb +39 -0
  4. data/lib/openhab/core/actions/exec.rb +51 -0
  5. data/lib/openhab/core/actions/http.rb +80 -0
  6. data/lib/openhab/core/actions/ping.rb +30 -0
  7. data/lib/openhab/core/actions/transformation.rb +32 -0
  8. data/lib/openhab/core/actions/voice.rb +36 -0
  9. data/lib/openhab/core/actions.rb +23 -120
  10. data/lib/openhab/core/{events → dto}/item_channel_link.rb +1 -4
  11. data/lib/openhab/core/{events → dto}/thing.rb +10 -12
  12. data/lib/openhab/core/dto.rb +11 -0
  13. data/lib/openhab/core/entity_lookup.rb +1 -1
  14. data/lib/openhab/core/events/abstract_event.rb +1 -0
  15. data/lib/openhab/core/events/abstract_item_registry_event.rb +36 -0
  16. data/lib/openhab/core/events/abstract_thing_registry_event.rb +40 -0
  17. data/lib/openhab/core/events/item_command_event.rb +1 -1
  18. data/lib/openhab/core/events/item_state_changed_event.rb +6 -6
  19. data/lib/openhab/core/events/item_state_event.rb +6 -6
  20. data/lib/openhab/core/events/thing_status_info_event.rb +8 -6
  21. data/lib/openhab/core/items/generic_item.rb +2 -1
  22. data/lib/openhab/core/items/persistence.rb +52 -18
  23. data/lib/openhab/core/items/player_item.rb +1 -1
  24. data/lib/openhab/core/items/proxy.rb +20 -14
  25. data/lib/openhab/core/items/registry.rb +2 -0
  26. data/lib/openhab/core/items.rb +3 -3
  27. data/lib/openhab/core/profile_factory.rb +3 -1
  28. data/lib/openhab/core/proxy.rb +125 -0
  29. data/lib/openhab/core/things/links/provider.rb +1 -1
  30. data/lib/openhab/core/things/proxy.rb +8 -0
  31. data/lib/openhab/core/types/date_time_type.rb +2 -1
  32. data/lib/openhab/core/types/decimal_type.rb +1 -1
  33. data/lib/openhab/core/types/un_def_type.rb +2 -2
  34. data/lib/openhab/core/value_cache.rb +1 -1
  35. data/lib/openhab/core_ext/ephemeris.rb +53 -0
  36. data/lib/openhab/core_ext/java/class.rb +1 -1
  37. data/lib/openhab/core_ext/java/duration.rb +25 -1
  38. data/lib/openhab/core_ext/java/local_date.rb +2 -0
  39. data/lib/openhab/core_ext/java/month_day.rb +2 -0
  40. data/lib/openhab/core_ext/java/zoned_date_time.rb +85 -0
  41. data/lib/openhab/core_ext/ruby/date.rb +2 -0
  42. data/lib/openhab/core_ext/ruby/date_time.rb +1 -0
  43. data/lib/openhab/core_ext/ruby/time.rb +1 -0
  44. data/lib/openhab/dsl/debouncer.rb +259 -0
  45. data/lib/openhab/dsl/items/builder.rb +4 -2
  46. data/lib/openhab/dsl/items/timed_command.rb +31 -13
  47. data/lib/openhab/dsl/rules/automation_rule.rb +28 -21
  48. data/lib/openhab/dsl/rules/builder.rb +357 -37
  49. data/lib/openhab/dsl/rules/guard.rb +12 -54
  50. data/lib/openhab/dsl/rules/name_inference.rb +11 -0
  51. data/lib/openhab/dsl/rules/property.rb +3 -4
  52. data/lib/openhab/dsl/rules/terse.rb +4 -1
  53. data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +5 -6
  54. data/lib/openhab/dsl/rules/triggers/cron/cron.rb +1 -0
  55. data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +19 -31
  56. data/lib/openhab/dsl/rules/triggers/watch/watch.rb +1 -0
  57. data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +22 -30
  58. data/lib/openhab/dsl/things/builder.rb +1 -1
  59. data/lib/openhab/dsl/thread_local.rb +1 -0
  60. data/lib/openhab/dsl/version.rb +1 -1
  61. data/lib/openhab/dsl.rb +224 -3
  62. data/lib/openhab/rspec/hooks.rb +5 -2
  63. data/lib/openhab/rspec/karaf.rb +7 -0
  64. data/lib/openhab/rspec/mocks/instance_method_stasher.rb +22 -0
  65. data/lib/openhab/rspec/mocks/space.rb +23 -0
  66. data/lib/openhab/rspec/openhab/core/actions.rb +16 -4
  67. data/lib/openhab/rspec/openhab/core/items/proxy.rb +1 -13
  68. data/lib/openhab/rspec/suspend_rules.rb +1 -14
  69. data/lib/openhab/yard/base_helper.rb +19 -0
  70. data/lib/openhab/yard/code_objects/group_object.rb +9 -3
  71. data/lib/openhab/yard/coderay.rb +17 -0
  72. data/lib/openhab/yard/handlers/jruby/base.rb +10 -1
  73. data/lib/openhab/yard/handlers/jruby/java_import_handler.rb +3 -0
  74. data/lib/openhab/yard/html_helper.rb +49 -15
  75. data/lib/openhab/yard/markdown_helper.rb +135 -0
  76. data/lib/openhab/yard.rb +6 -0
  77. metadata +36 -4
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenHAB
4
+ module YARD
5
+ # @!visibility private
6
+ module MarkdownHelper
7
+ include ::YARD::Templates::Helpers::HtmlHelper
8
+ # @group Linking Objects and URLs
9
+
10
+ def diskfile
11
+ resolve_links(super)
12
+ end
13
+
14
+ # mostly copied from HTMLHelper
15
+ def resolve_links(text)
16
+ blockquotes = false
17
+ text.gsub(%r{(```)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+</|$)}m) do |str|
18
+ blockquote = $1
19
+ escape = $2
20
+ name = $3
21
+ title = $4
22
+ match = $&
23
+ if blockquote
24
+ blockquotes = !blockquotes
25
+ next str
26
+ end
27
+ next str if blockquotes
28
+
29
+ next(match[1..]) if escape
30
+
31
+ next(match) if name[0, 1] == "|"
32
+
33
+ if object.is_a?(String)
34
+ object
35
+ else
36
+ link = linkify(name, title)
37
+ if (link == name || link == title) && ("#{name} #{link}" !~ /\A<a\s.*>/)
38
+ match = /(.+)?(\{#{Regexp.quote name}(?:\s.*?)?\})(.+)?/.match(text)
39
+ file = ((defined?(@file) && @file) ? @file.filename : object.file) || "(unknown)"
40
+ line = (if defined?(@file) && @file
41
+ 1
42
+ else
43
+ (object.docstring.line_range ? object.docstring.line_range.first : 1)
44
+ end) + (match ? $`.count("\n") : 0)
45
+ if match
46
+ log.warn "In file `#{file}':#{line}: Cannot resolve link to #{name} from text#{match ? ":" : "."}\n" \
47
+ "\t#{match[1] ? "..." : ""}#{match[2].delete("\n")}#{match[3] ? "..." : ""}"
48
+ end
49
+ end
50
+
51
+ link
52
+ end
53
+ end
54
+ end
55
+
56
+ # mostly copied from HTMLHelper
57
+ def link_object(obj, title = nil, anchor = nil, relative = true) # rubocop:disable Style/OptionalBooleanParameter
58
+ return title if obj.nil?
59
+
60
+ obj = ::YARD::Registry.resolve(object, obj, true, true) if obj.is_a?(String)
61
+
62
+ was_const = false
63
+ # Re-link references to constants that are aliases to their target. But keep
64
+ # their current title.
65
+ while obj.is_a?(::YARD::CodeObjects::ConstantObject) && obj.target
66
+ title ||= h(object.relative_path(obj)).to_s
67
+ was_const = true
68
+ obj = obj.target
69
+ end
70
+ return link_object(obj, title, anchor, relative) if was_const
71
+
72
+ title = if title
73
+ title.to_s
74
+ elsif object.is_a?(::YARD::CodeObjects::Base)
75
+ # Check if we're linking to a class method in the current
76
+ # object. If we are, create a title in the format of
77
+ # "CurrentClass.method_name"
78
+ if obj.is_a?(::YARD::CodeObjects::MethodObject) && obj.scope == :class && obj.parent == object
79
+ h([object.name, obj.sep, obj.name].join)
80
+ elsif obj.title != obj.path
81
+ h(obj.title)
82
+ else
83
+ h(object.relative_path(obj))
84
+ end
85
+ else
86
+ h(obj.title)
87
+ end
88
+ return title unless serializer
89
+ return title if obj.is_a?(::YARD::CodeObjects::Proxy)
90
+
91
+ link = url_for(obj, anchor, relative)
92
+ link ? link_url(link, title, title: h("#{obj.title} (#{obj.type})")) : title
93
+ rescue ::YARD::Parser::UndocumentableError
94
+ log.warn "The namespace of link #{obj.inspect} is a constant or invalid."
95
+ title || obj.to_s
96
+ end
97
+
98
+ def url_for(obj, anchor = nil, relative = true) # rubocop:disable Style/OptionalBooleanParameter
99
+ link = nil
100
+ return link unless serializer
101
+ return link if obj.is_a?(::YARD::CodeObjects::Base) && run_verifier([obj]).empty?
102
+
103
+ if obj.is_a?(::YARD::CodeObjects::Base) && !obj.is_a?(::YARD::CodeObjects::NamespaceObject)
104
+ # If the obj is not a namespace obj make it the anchor.
105
+ anchor = obj
106
+ obj = obj.namespace
107
+ end
108
+
109
+ objpath = serializer.serialized_path(obj)
110
+ return link unless objpath
111
+
112
+ relative = false if object == ::YARD::Registry.root
113
+ if relative
114
+ fromobj = object
115
+ if object.is_a?(::YARD::CodeObjects::Base) &&
116
+ !object.is_a?(::YARD::CodeObjects::NamespaceObject)
117
+ fromobj = owner
118
+ end
119
+
120
+ from = serializer.serialized_path(fromobj)
121
+ link = File.relative_path(from, objpath)
122
+ else
123
+ link = File.join(serializer.basepath, objpath)
124
+ end
125
+
126
+ link + (anchor ? "##{urlencode(anchor_for(anchor))}" : "")
127
+ end
128
+
129
+ def link_url(url, title = nil, _params = nil)
130
+ title ||= url
131
+ "[#{title}](#{url})"
132
+ end
133
+ end
134
+ end
135
+ end
data/lib/openhab/yard.rb CHANGED
@@ -6,10 +6,16 @@ Dir[File.expand_path("yard/**/*.rb", __dir__)].sort.each do |f|
6
6
  require f
7
7
  end
8
8
 
9
+ YARD::Templates::Template.extra_includes << OpenHAB::YARD::BaseHelper
10
+ YARD::Templates::Template.extra_includes << ->(opts) { OpenHAB::YARD::CodeRay::HtmlHelper if opts.format == :html }
9
11
  YARD::Templates::Template.extra_includes << ->(opts) { OpenHAB::YARD::HtmlHelper if opts.format == :html }
12
+ YARD::Templates::Template.extra_includes << ->(opts) { OpenHAB::YARD::MarkdownHelper if opts.format == :markdown }
13
+
10
14
  YARD::Templates::Engine.register_template_path File.expand_path("../../templates", __dir__)
11
15
  YARD::Tags::Library.define_tag "Java Interface", :interface
12
16
 
17
+ YARD::Server.register_static_path(".")
18
+
13
19
  #
14
20
  # @!parse
15
21
  # # @!visibility private
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.rc10
4
+ version: 5.0.0.rc11
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-12-06 00:00:00.000000000 Z
11
+ date: 2022-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.4'
167
+ - !ruby/object:Gem::Dependency
168
+ name: nokogiri
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 1.13.9
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 1.13.9
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: persistent_httparty
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -327,16 +341,26 @@ extra_rdoc_files: []
327
341
  files:
328
342
  - lib/openhab/core.rb
329
343
  - lib/openhab/core/actions.rb
344
+ - lib/openhab/core/actions/audio.rb
345
+ - lib/openhab/core/actions/ephemeris.rb
346
+ - lib/openhab/core/actions/exec.rb
347
+ - lib/openhab/core/actions/http.rb
348
+ - lib/openhab/core/actions/ping.rb
349
+ - lib/openhab/core/actions/transformation.rb
350
+ - lib/openhab/core/actions/voice.rb
330
351
  - lib/openhab/core/dependency_tracking.rb
352
+ - lib/openhab/core/dto.rb
353
+ - lib/openhab/core/dto/item_channel_link.rb
354
+ - lib/openhab/core/dto/thing.rb
331
355
  - lib/openhab/core/entity_lookup.rb
332
356
  - lib/openhab/core/events.rb
333
357
  - lib/openhab/core/events/abstract_event.rb
334
- - lib/openhab/core/events/item_channel_link.rb
358
+ - lib/openhab/core/events/abstract_item_registry_event.rb
359
+ - lib/openhab/core/events/abstract_thing_registry_event.rb
335
360
  - lib/openhab/core/events/item_command_event.rb
336
361
  - lib/openhab/core/events/item_event.rb
337
362
  - lib/openhab/core/events/item_state_changed_event.rb
338
363
  - lib/openhab/core/events/item_state_event.rb
339
- - lib/openhab/core/events/thing.rb
340
364
  - lib/openhab/core/events/thing_status_info_event.rb
341
365
  - lib/openhab/core/items.rb
342
366
  - lib/openhab/core/items/accepted_data_types.rb
@@ -369,6 +393,7 @@ files:
369
393
  - lib/openhab/core/lazy_array.rb
370
394
  - lib/openhab/core/profile_factory.rb
371
395
  - lib/openhab/core/provider.rb
396
+ - lib/openhab/core/proxy.rb
372
397
  - lib/openhab/core/registry.rb
373
398
  - lib/openhab/core/rules.rb
374
399
  - lib/openhab/core/rules/module.rb
@@ -413,6 +438,7 @@ files:
413
438
  - lib/openhab/core/value_cache.rb
414
439
  - lib/openhab/core_ext.rb
415
440
  - lib/openhab/core_ext/between.rb
441
+ - lib/openhab/core_ext/ephemeris.rb
416
442
  - lib/openhab/core_ext/java/class.rb
417
443
  - lib/openhab/core_ext/java/duration.rb
418
444
  - lib/openhab/core_ext/java/list.rb
@@ -435,6 +461,7 @@ files:
435
461
  - lib/openhab/core_ext/ruby/symbol.rb
436
462
  - lib/openhab/core_ext/ruby/time.rb
437
463
  - lib/openhab/dsl.rb
464
+ - lib/openhab/dsl/debouncer.rb
438
465
  - lib/openhab/dsl/events.rb
439
466
  - lib/openhab/dsl/events/watch_event.rb
440
467
  - lib/openhab/dsl/gems.rb
@@ -477,8 +504,10 @@ files:
477
504
  - lib/openhab/rspec/mocks/bundle_install_support.rb
478
505
  - lib/openhab/rspec/mocks/bundle_resolver.rb
479
506
  - lib/openhab/rspec/mocks/event_admin.rb
507
+ - lib/openhab/rspec/mocks/instance_method_stasher.rb
480
508
  - lib/openhab/rspec/mocks/persistence_service.rb
481
509
  - lib/openhab/rspec/mocks/safe_caller.rb
510
+ - lib/openhab/rspec/mocks/space.rb
482
511
  - lib/openhab/rspec/mocks/synchronous_executor.rb
483
512
  - lib/openhab/rspec/mocks/thing_handler.rb
484
513
  - lib/openhab/rspec/mocks/timer.rb
@@ -488,6 +517,7 @@ files:
488
517
  - lib/openhab/rspec/shell.rb
489
518
  - lib/openhab/rspec/suspend_rules.rb
490
519
  - lib/openhab/yard.rb
520
+ - lib/openhab/yard/base_helper.rb
491
521
  - lib/openhab/yard/cli/stats.rb
492
522
  - lib/openhab/yard/code_objects/group_object.rb
493
523
  - lib/openhab/yard/code_objects/java/base.rb
@@ -496,12 +526,14 @@ files:
496
526
  - lib/openhab/yard/code_objects/java/interface_object.rb
497
527
  - lib/openhab/yard/code_objects/java/package_object.rb
498
528
  - lib/openhab/yard/code_objects/java/proxy.rb
529
+ - lib/openhab/yard/coderay.rb
499
530
  - lib/openhab/yard/handlers/jruby/base.rb
500
531
  - lib/openhab/yard/handlers/jruby/class_handler.rb
501
532
  - lib/openhab/yard/handlers/jruby/constant_handler.rb
502
533
  - lib/openhab/yard/handlers/jruby/java_import_handler.rb
503
534
  - lib/openhab/yard/handlers/jruby/mixin_handler.rb
504
535
  - lib/openhab/yard/html_helper.rb
536
+ - lib/openhab/yard/markdown_helper.rb
505
537
  - lib/openhab/yard/tags/constant_directive.rb
506
538
  - lib/openhab/yard/tags/group_directive.rb
507
539
  - lib/openhab/yard/tags/library.rb