openhab-scripting 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/workflow.yml +327 -0
  3. data/.gitignore +17 -0
  4. data/.java-version +1 -0
  5. data/.rspec +1 -0
  6. data/.yardopts +1 -0
  7. data/CHANGELOG.md +113 -0
  8. data/Gemfile +28 -0
  9. data/Gemfile.lock +245 -0
  10. data/Guardfile +35 -0
  11. data/LICENSE +277 -0
  12. data/README.md +23 -0
  13. data/Rakefile +406 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/config/userdata/config/org/openhab/restauth.config +3 -0
  17. data/cucumber.yml +1 -0
  18. data/docs/_config.yml +135 -0
  19. data/docs/contributing/index.md +47 -0
  20. data/docs/examples/conversions.md +123 -0
  21. data/docs/examples/index.md +61 -0
  22. data/docs/index.md +19 -0
  23. data/docs/installation/index.md +26 -0
  24. data/docs/motivation/index.md +27 -0
  25. data/docs/usage/execution.md +9 -0
  26. data/docs/usage/execution/delay.md +48 -0
  27. data/docs/usage/execution/otherwise.md +30 -0
  28. data/docs/usage/execution/run.md +70 -0
  29. data/docs/usage/execution/triggered.md +48 -0
  30. data/docs/usage/guards.md +51 -0
  31. data/docs/usage/guards/between.md +30 -0
  32. data/docs/usage/guards/not_if.md +41 -0
  33. data/docs/usage/guards/only_if.md +40 -0
  34. data/docs/usage/index.md +11 -0
  35. data/docs/usage/items.md +66 -0
  36. data/docs/usage/items/contact.md +84 -0
  37. data/docs/usage/items/dimmer.md +147 -0
  38. data/docs/usage/items/groups.md +76 -0
  39. data/docs/usage/items/number.md +225 -0
  40. data/docs/usage/items/string.md +49 -0
  41. data/docs/usage/items/switch.md +85 -0
  42. data/docs/usage/misc.md +7 -0
  43. data/docs/usage/misc/actions.md +108 -0
  44. data/docs/usage/misc/duration.md +21 -0
  45. data/docs/usage/misc/gems.md +25 -0
  46. data/docs/usage/misc/logging.md +21 -0
  47. data/docs/usage/misc/metadata.md +128 -0
  48. data/docs/usage/misc/store_states.md +42 -0
  49. data/docs/usage/misc/time_of_day.md +69 -0
  50. data/docs/usage/misc/timers.md +67 -0
  51. data/docs/usage/rule.md +43 -0
  52. data/docs/usage/things.md +29 -0
  53. data/docs/usage/triggers.md +8 -0
  54. data/docs/usage/triggers/changed.md +57 -0
  55. data/docs/usage/triggers/channel.md +54 -0
  56. data/docs/usage/triggers/command.md +69 -0
  57. data/docs/usage/triggers/cron.md +19 -0
  58. data/docs/usage/triggers/every.md +76 -0
  59. data/docs/usage/triggers/updated.md +78 -0
  60. data/lib/openhab.rb +39 -0
  61. data/lib/openhab/configuration.rb +16 -0
  62. data/lib/openhab/core/cron.rb +27 -0
  63. data/lib/openhab/core/debug.rb +34 -0
  64. data/lib/openhab/core/dsl.rb +47 -0
  65. data/lib/openhab/core/dsl/actions.rb +107 -0
  66. data/lib/openhab/core/dsl/entities.rb +103 -0
  67. data/lib/openhab/core/dsl/gems.rb +29 -0
  68. data/lib/openhab/core/dsl/group.rb +91 -0
  69. data/lib/openhab/core/dsl/items/items.rb +39 -0
  70. data/lib/openhab/core/dsl/items/number_item.rb +217 -0
  71. data/lib/openhab/core/dsl/items/string_item.rb +102 -0
  72. data/lib/openhab/core/dsl/monkey_patch/actions/actions.rb +4 -0
  73. data/lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb +22 -0
  74. data/lib/openhab/core/dsl/monkey_patch/events.rb +5 -0
  75. data/lib/openhab/core/dsl/monkey_patch/events/item_command.rb +13 -0
  76. data/lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb +25 -0
  77. data/lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb +26 -0
  78. data/lib/openhab/core/dsl/monkey_patch/items/contact_item.rb +54 -0
  79. data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +125 -0
  80. data/lib/openhab/core/dsl/monkey_patch/items/group_item.rb +27 -0
  81. data/lib/openhab/core/dsl/monkey_patch/items/items.rb +130 -0
  82. data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +259 -0
  83. data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +86 -0
  84. data/lib/openhab/core/dsl/monkey_patch/ruby/number.rb +69 -0
  85. data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +46 -0
  86. data/lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb +5 -0
  87. data/lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb +24 -0
  88. data/lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb +41 -0
  89. data/lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb +25 -0
  90. data/lib/openhab/core/dsl/monkey_patch/types/percent_type.rb +23 -0
  91. data/lib/openhab/core/dsl/monkey_patch/types/types.rb +7 -0
  92. data/lib/openhab/core/dsl/property.rb +85 -0
  93. data/lib/openhab/core/dsl/rule/channel.rb +41 -0
  94. data/lib/openhab/core/dsl/rule/cron.rb +115 -0
  95. data/lib/openhab/core/dsl/rule/guard.rb +99 -0
  96. data/lib/openhab/core/dsl/rule/item.rb +207 -0
  97. data/lib/openhab/core/dsl/rule/rule.rb +374 -0
  98. data/lib/openhab/core/dsl/rule/triggers.rb +77 -0
  99. data/lib/openhab/core/dsl/states.rb +63 -0
  100. data/lib/openhab/core/dsl/things.rb +93 -0
  101. data/lib/openhab/core/dsl/time_of_day.rb +203 -0
  102. data/lib/openhab/core/dsl/timers.rb +85 -0
  103. data/lib/openhab/core/dsl/types/quantity.rb +255 -0
  104. data/lib/openhab/core/dsl/units.rb +41 -0
  105. data/lib/openhab/core/duration.rb +69 -0
  106. data/lib/openhab/core/log.rb +175 -0
  107. data/lib/openhab/core/patch_load_path.rb +7 -0
  108. data/lib/openhab/core/startup_delay.rb +22 -0
  109. data/lib/openhab/osgi.rb +52 -0
  110. data/lib/openhab/version.rb +9 -0
  111. data/openhab-scripting.gemspec +30 -0
  112. data/openhab_rules/warmup.rb +5 -0
  113. metadata +157 -0
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # JRuby OpenHAB Scripting Library
2
+
3
+
4
+ <p align="center">
5
+ <img alt="GitHub release (latest SemVer including pre-releases)" src="https://img.shields.io/github/v/release/boc-tothefuture/openhab-jruby?include_prereleases"/>
6
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/boc-tothefuture/openhab-jruby/Openhab-JRuby-Scripting"/>
7
+ <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/boc-tothefuture/openhab-jruby"/>
8
+ <img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/boc-tothefuture/openhab-jruby">
9
+ <img alt="SemVer version observance" src="https://img.shields.io/badge/semver-2.0.0-blue"/>
10
+ <a href="https://conventionalcommits.org"/>
11
+ <img alt="Convention commits observance" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg"/>
12
+ </a>
13
+ </p>
14
+
15
+
16
+ ## Usage
17
+ Usage documentation is located [here](https://boc-tothefuture.github.io/openhab-jruby/).
18
+
19
+ ## Discussion
20
+ Please see [this thread](https://community.openhab.org/t/jruby-openhab-rules-system/110598) on the OpenHAB forum for further discussion. Ideas and suggestions are welcome.
21
+
22
+ ## Library Status
23
+ This is an alpha and syntax and all elements are subject to change as the library evolves.
data/Rakefile ADDED
@@ -0,0 +1,406 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/packagetask'
4
+ require 'rubocop/rake_task'
5
+ require 'bundler/gem_tasks'
6
+ require 'yard'
7
+ require 'English'
8
+ require 'time'
9
+ require 'cucumber'
10
+ require 'cucumber/rake/task'
11
+ require 'open-uri'
12
+ require 'tty-command'
13
+ require 'process_exists'
14
+ require 'cuke_linter'
15
+ require 'erb'
16
+
17
+ require_relative 'lib/openhab/version'
18
+
19
+ PACKAGE_DIR = 'pkg'
20
+ TMP_DIR = 'tmp'
21
+ OPENHAB_DIR = File.join(TMP_DIR, 'openhab')
22
+ DOCS_DIR = 'doc'
23
+ OPENHAB_VERSION = '3.0.0'
24
+ JRUBY_BUNDLE = File.realpath(Dir.glob('bundle/*.jar').first)
25
+ KARAF_CLIENT_PATH = File.join(OPENHAB_DIR, 'runtime/bin/client')
26
+ KARAF_CLIENT_ARGS = [KARAF_CLIENT_PATH, '-p', 'habopen'].freeze
27
+ KARAF_CLIENT = KARAF_CLIENT_ARGS.join(' ')
28
+
29
+ DEPLOY_DIR = File.join(OPENHAB_DIR, 'conf/automation/jsr223/ruby/personal')
30
+ LIB_DIR = File.join(OPENHAB_DIR, 'conf/automation/lib/ruby/lib/')
31
+ STATE_DIR = File.join(OPENHAB_DIR, 'rake_state')
32
+ YARD_DIR = File.join('docs', 'yard')
33
+ CUCUMBER_LOGS = File.join(TMP_DIR, 'cucumber_logs')
34
+ SERVICES_CONFIG = File.join(OPENHAB_DIR, 'conf/services/jruby.cfg')
35
+
36
+ CLEAN << PACKAGE_DIR
37
+ CLEAN << DEPLOY_DIR
38
+ CLEAN << CUCUMBER_LOGS
39
+ CLEAN << YARD_DIR
40
+ CLEAN << '.yardoc'
41
+
42
+ CLOBBER << OPENHAB_DIR
43
+
44
+ desc 'Generate Yard docs'
45
+ task :yard do
46
+ YARD::Rake::YardocTask.new do |t|
47
+ t.files = ['lib/**/*.rb'] # optional
48
+ t.stats_options = ['--list-undoc'] # optional
49
+ end
50
+ end
51
+
52
+ RuboCop::RakeTask.new do |task|
53
+ task.patterns = ['lib/**/*.rb', 'test/**/*.rb']
54
+ task.fail_on_error = false
55
+ end
56
+
57
+ desc 'Lint Code'
58
+ task :lint do
59
+ Rake::Task['rubocop'].invoke
60
+ CukeLinter.lint
61
+ end
62
+
63
+ desc 'Start Documentation Server'
64
+ task docs: :yard do
65
+ sh 'bundle exec jekyll clean'
66
+ sh 'bundle exec jekyll server --config docs/_config.yml'
67
+ end
68
+
69
+ task :yard_server do
70
+ sh 'bundle exec guard'
71
+ end
72
+
73
+ desc 'Run Cucumber Features'
74
+ task :features, [:feature] => ['openhab:warmup', 'openhab:deploy', CUCUMBER_LOGS] do |_, args|
75
+ # Rake::Task['openhab:warmup'].execute
76
+ Cucumber::Rake::Task.new(:features) do |t|
77
+ t.cucumber_opts = "--tags 'not @wip and not @not_implemented' --format pretty #{args[:feature]}"
78
+ end
79
+ end
80
+
81
+ desc 'Get OpenHAB-JRuby Version'
82
+ task :version do
83
+ puts OpenHAB::VERSION
84
+ end
85
+
86
+ namespace :gh do
87
+ zip_path = ''
88
+
89
+ directory PACKAGE_DIR
90
+
91
+ desc 'Package for release'
92
+ task package: [PACKAGE_DIR] do
93
+ zip_filename = "OpenHABJRuby-#{OpenHAB::VERSION}.zip"
94
+ zip_path = File.join(PACKAGE_DIR, zip_filename)
95
+ target_dir = 'lib/'
96
+ sh 'zip', '-r', zip_path, target_dir
97
+ end
98
+
99
+ desc 'Package for release'
100
+ task release: :package do
101
+ sh 'gh', 'release', 'create', OpenHAB::VERSION, '-p', '-F', 'CHANGELOG.md', zip_path, JRUBY_BUNDLE
102
+ end
103
+ end
104
+
105
+ namespace :openhab do
106
+ def command_success?(command)
107
+ cmd = TTY::Command.new(printer: :null)
108
+ cmd.run!(command).success?
109
+ end
110
+
111
+ def running?(fail_on_error: false)
112
+ karaf_status = File.join(OPENHAB_DIR, 'runtime/bin/status')
113
+
114
+ return false unless File.exist? karaf_status
115
+
116
+ if fail_on_error
117
+ fail_on_error(karaf_status)
118
+ true
119
+ else
120
+ command_success? karaf_status
121
+ end
122
+ end
123
+
124
+ # There can be a delay between when OpenHAB is running and ready to process commands
125
+ def ready?(fail_on_error: false)
126
+ return unless running?
127
+
128
+ if fail_on_error
129
+ fail_on_error("#{KARAF_CLIENT} 'system:version'")
130
+ true
131
+ else
132
+ cmd = TTY::Command.new(printer: :null)
133
+ cmd.run!("#{KARAF_CLIENT} 'system:version'").success?
134
+ end
135
+ end
136
+
137
+ def ensure_openhab_running
138
+ abort('Openhab not running') unless running?
139
+ end
140
+
141
+ def print_and_flush(string)
142
+ print string
143
+ $stdout.flush
144
+ end
145
+
146
+ def fail_on_error(command, env = {})
147
+ cmd = TTY::Command.new
148
+ out, = cmd.run(command, env: env, only_output_on_error: true)
149
+ out
150
+ end
151
+
152
+ def karaf(command)
153
+ fail_on_error("#{KARAF_CLIENT} '#{command}'")
154
+ end
155
+
156
+ def wait_for(duration, task)
157
+ print_and_flush "Waiting for up to #{duration} seconds for #{task}"
158
+ duration.times do
159
+ if yield
160
+ puts ''
161
+ return true
162
+ end
163
+
164
+ print_and_flush '.'
165
+ sleep 1
166
+ end
167
+ puts ''
168
+ false
169
+ end
170
+
171
+ def gem_home
172
+ full_path = File.realpath OPENHAB_DIR
173
+ File.join(full_path, '/conf/automation/lib/ruby/gem_home')
174
+ end
175
+
176
+ def ruby_env
177
+ # { 'RUBYLIB' => File.join(full_path, '/conf/automation/lib/ruby/lib'),
178
+ { 'GEM_HOME' => gem_home }
179
+ end
180
+
181
+ def state(task)
182
+ Rake::Task[STATE_DIR.to_s].execute
183
+ task_file = File.join(STATE_DIR, task)
184
+ if File.exist? task_file
185
+ puts "Skipping task(#{task}), task already up to date"
186
+ else
187
+ yield
188
+ touch task_file
189
+ end
190
+ end
191
+
192
+ directory OPENHAB_DIR
193
+ directory DEPLOY_DIR
194
+ directory LIB_DIR
195
+ directory STATE_DIR
196
+ directory CUCUMBER_LOGS
197
+
198
+ desc 'Download Openhab and unzip it'
199
+ task download: [OPENHAB_DIR] do |task|
200
+ state(task.name) do
201
+ openhab_zip = "openhab-#{OPENHAB_VERSION}.zip"
202
+ Dir.chdir(OPENHAB_DIR) do
203
+ puts "Downloading #{openhab_zip}"
204
+ IO.copy_stream(
205
+ open("https://openhab.jfrog.io/openhab/libs-release/org/openhab/distro/openhab/#{OPENHAB_VERSION}/openhab-#{OPENHAB_VERSION}.zip"), openhab_zip
206
+ )
207
+ fail_on_error("unzip #{openhab_zip}")
208
+ rm openhab_zip
209
+ end
210
+ end
211
+ end
212
+
213
+ desc 'Add RubyLib and GEM_HOME to start.sh'
214
+ task rubylib: :download do |task|
215
+ # state(task.name) do
216
+ # paths = ruby_env
217
+ # Dir.chdir(OPENHAB_DIR) do
218
+ # start_file = 'start.sh'
219
+ #
220
+ # settings = {
221
+ # /^export RUBYLIB=/ => "export RUBYLIB=#{paths['RUBYLIB']}\n",
222
+ # /^export GEM_HOME=/ => "export GEM_HOME=#{paths['GEM_HOME']}\n"
223
+ # }
224
+ #
225
+ # settings.each do |regex, line|
226
+ # lines = File.readlines(start_file)
227
+ # unless lines.grep(regex).any?
228
+ # lines.insert(-2, line)
229
+ # File.write(start_file, lines.join)
230
+ # end
231
+ # end
232
+ # end
233
+ # end
234
+ end
235
+
236
+ desc 'Setup services config'
237
+ task services: :download do |task|
238
+ state(task.name) do
239
+ services_config = ERB.new <<~EOF
240
+ org.openhab.automation.jrubyscripting:gem_home=<%= gem_home %>
241
+ EOF
242
+ File.write(SERVICES_CONFIG, services_config.result)
243
+ end
244
+ end
245
+
246
+ def bundle_id
247
+ karaf('bundle:list --no-format org.openhab.automation.jrubyscripting').lines.last[/^\d\d\d/].chomp
248
+ end
249
+
250
+ desc 'Install JRuby Bundle'
251
+ task install: [:download, :rubylib, :services, DEPLOY_DIR] do |task|
252
+ state(task.name) do
253
+ start
254
+ if karaf('bundle:list --no-format org.openhab.automation.jrubyscripting').include?('Active')
255
+ puts 'Bundle Active, no action taken'
256
+ else
257
+ unless karaf('bundle:list --no-format org.openhab.automation.jrubyscripting').include?('Installed')
258
+ karaf("bundle:install file://#{JRUBY_BUNDLE}")
259
+ end
260
+ karaf("bundle:start #{bundle_id}")
261
+ end
262
+ end
263
+ end
264
+
265
+ desc 'Upgrade JRuby Bundle'
266
+ task :upgrade, [:file] do |_, args|
267
+ start
268
+ if karaf('bundle:list --no-format org.openhab.automation.jrubyscripting').include?('Active')
269
+ karaf("bundle:update #{bundle_id} file://#{args[:file]}")
270
+ else
271
+ abort "Bundle not installed, can't upgrade"
272
+ end
273
+ end
274
+
275
+ desc 'Configure'
276
+ task configure: %i[download] do |task|
277
+ # Set log levels
278
+ state(task.name) do
279
+ start
280
+ karaf('log:set TRACE jsr223')
281
+ karaf('log:set TRACE org.openhab.core.automation')
282
+ karaf('log:set TRACE org.openhab.binding.jrubyscripting')
283
+ karaf('openhab:users add foo foo administrator')
284
+ sh 'rsync', '-aih', 'config/userdata/', File.join(OPENHAB_DIR, 'userdata')
285
+ end
286
+ end
287
+
288
+ def start
289
+ if running?
290
+ puts 'OpenHAB already running'
291
+ return
292
+ end
293
+
294
+ env = ruby_env
295
+ env = env.merge({ 'KARAF_REDIRECT' => File.join(File.realpath(TMP_DIR), 'karaf.log'),
296
+ 'EXTRA_JAVA_OPTS' => '-Xmx4g' })
297
+
298
+ Dir.chdir(OPENHAB_DIR) do
299
+ puts 'Starting OpenHAB'
300
+ pid = spawn(env, 'runtime/bin/start')
301
+ Process.detach(pid)
302
+ end
303
+
304
+ wait_for(20, 'OpenHAB to start') { running? }
305
+ abort 'Unable to start OpenHAB' unless running?(fail_on_error: true)
306
+
307
+ wait_for(20, 'OpenHAB to become ready') { ready? }
308
+ abort 'OpenHAB did not become ready' unless ready?(fail_on_error: true)
309
+
310
+ puts 'OpenHAB started and ready'
311
+ end
312
+
313
+ desc 'Start OpenHAB'
314
+ task start: %i[download] do
315
+ start
316
+ end
317
+
318
+ def stop
319
+ if running?
320
+ pid = File.read(File.join(OPENHAB_DIR, 'userdata/tmp/karaf.pid')).chomp.to_i
321
+ Dir.chdir(OPENHAB_DIR) do
322
+ fail_on_error('runtime/bin/stop')
323
+ end
324
+ stopped = wait_for(20, 'OpenHAB to stop') { Process.exists?(pid) == false }
325
+ abort 'Unable to stop OpenHAB' unless stopped
326
+ end
327
+
328
+ puts 'OpenHAB Stopped'
329
+ end
330
+
331
+ desc 'Stop OpenHAB'
332
+ task :stop do
333
+ stop
334
+ end
335
+
336
+ def restart
337
+ puts 'Restarting OpenHAB'
338
+ stop
339
+ start
340
+ puts 'OpenHAB Restarted'
341
+ end
342
+
343
+ desc 'Clobber local Openhab'
344
+ task :clobber do
345
+ stop if running?
346
+
347
+ rm_rf OPENHAB_DIR
348
+ end
349
+
350
+ desc 'Create a Dev Dump in OpenHAB and wait until its complete'
351
+ task :dump do
352
+ dumps = File.join(OPENHAB_DIR, 'userdata', '*.zip')
353
+
354
+ puts 'Deleting any existing dumps'
355
+ dump = Dir[dumps].each { |dump_file| rm dump_file }
356
+
357
+ karaf('dev:dump-create')
358
+
359
+ wait_for(30, 'Dump to be created') do
360
+ Dir[dumps].any?
361
+ end
362
+ dump = Dir[dumps].first
363
+ puts "Found dev dump #{dump}"
364
+ dump_sizes = Array.new(10)
365
+ wait_for(120, 'Dump size to not increase for 10 seconds') do
366
+ dump_sizes << File.size(dump)
367
+ dump_sizes.last(10).uniq.length == 1
368
+ end
369
+ end
370
+
371
+ desc 'Warmup OpenHab environment'
372
+ task warmup: [:prepare, DEPLOY_DIR] do
373
+ start
374
+ openhab_log = File.join(OPENHAB_DIR, 'userdata/logs/openhab.log')
375
+
376
+ file = File.join('openhab_rules', 'warmup.rb')
377
+ dest_file = File.join(DEPLOY_DIR, "#{File.basename(file, '.rb')}_#{Time.now.to_i}.rb")
378
+ cp file, dest_file
379
+ wait_for(20, 'OpenHAB to warmup') do
380
+ File.foreach(openhab_log).grep(/OpenHAB warmup complete/).any?
381
+ end
382
+ rm dest_file
383
+ end
384
+
385
+ desc 'Prepare local Openhab'
386
+ task prepare: [:download, :rubylib, :install, :configure, :deploy, CUCUMBER_LOGS]
387
+
388
+ desc 'Setup local Openhab'
389
+ task setup: %i[prepare stop]
390
+
391
+ desc 'Deploy to local Openhab'
392
+ task deploy: %i[download build] do |_task|
393
+ gem_file = File.join(PACKAGE_DIR, "openhab-scripting-#{OpenHAB::VERSION}.gem")
394
+ fail_on_error("gem install #{gem_file}", ruby_env)
395
+ end
396
+
397
+ desc 'Deploy adhoc test Openhab'
398
+ task adhoc: :deploy do
399
+ mkdir_p DEPLOY_DIR
400
+ Dir.glob(File.join(DEPLOY_DIR, '*.rb')) { |file| rm file }
401
+ Dir.glob(File.join('test/', '*.rb')) do |file|
402
+ dest_name = "#{File.basename(file, '.rb')}_#{Time.now.to_i}.rb"
403
+ cp file, File.join(deploy_dir, dest_name)
404
+ end
405
+ end
406
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'openhab/scripting'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here