ruboty-cron 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4dd958d060c75fd932cf6235cfa3a1ee91b87542
4
- data.tar.gz: 43dd58785853b67fd18eada63b0f966d32e66eb6
2
+ SHA256:
3
+ metadata.gz: '09fd64aee5b2b59a9a2fda554debadbeff95948bc1f009574fcbc2397a5407bd'
4
+ data.tar.gz: d8d495a4e771a2b06ebe6530bdf23d9e526edf435f2618926356b17857a26e82
5
5
  SHA512:
6
- metadata.gz: 40f08a59a75bc19dc3abedc14ac3d40c81f391f8ab216f370ef36be997ae60e9f16c8f7f1a844da6fbe28a06a8330be084d542e6c99907a5dd6537882b44686c
7
- data.tar.gz: 03541c379bff1772005470fb4ab5ec9686ae6e5f71239a9e58ed44c043ea10ac09e74bd7a03df33b93cac579ec1a07ffb8a0143110a8c48611d0909f02c8e577
6
+ metadata.gz: e44168e6b2407951688fd5c59de2988dca38c10391754e0fdc78d07851788eeae05ca9634d0ab480879bf680acc5e00f0386403d447a75a230747e02ce5be3e7
7
+ data.tar.gz: 1b7db52d14a1cbd5f44ff57a0b0384b1bfcd312eaad18a5cab3f8bc8e10cf77eabdc82e6714d81ef9f2b6c968cd4d2b5f1b43d3b29cb312c1cb498bb7b5c4638
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,37 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/bump-request.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'r7kamura/bump-request@v0.7.1'
9
+ - 'ruby/setup-ruby@v1.336.0'
10
+ '.github/workflows/ci.yml':
11
+ - 'actions/checkout@v7.0.1'
12
+ - 'ruby/setup-ruby@v1.336.0'
13
+ '.github/workflows/release.yml': []
14
+ dependencies:
15
+ 'actions/checkout@v7.0.1':
16
+ ref: 'v7.0.1'
17
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
18
+ owner_id: 44036562
19
+ repo_id: 197814629
20
+ 'actions/setup-node@v7.1.0':
21
+ ref: 'v7.1.0'
22
+ commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
23
+ owner_id: 44036562
24
+ repo_id: 189476904
25
+ 'r7kamura/bump-request@v0.7.1':
26
+ ref: 'v0.7.1'
27
+ commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
28
+ owner_id: 111689
29
+ repo_id: 533135195
30
+ uses:
31
+ - 'actions/checkout@v7.0.1'
32
+ - 'actions/setup-node@v7.1.0'
33
+ 'ruby/setup-ruby@v1.336.0':
34
+ ref: 'v1.336.0'
35
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
36
+ owner_id: 210414
37
+ repo_id: 231208785
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7.0.1
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1.336.0
18
+ with:
19
+ ruby-version: 3.3
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0.7.1
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/ruboty/cron/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby:
17
+ - '3.3'
18
+ - '3.4'
19
+ - '4.0'
20
+ steps:
21
+ - uses: actions/checkout@v7.0.1
22
+ - uses: ruby/setup-ruby@v1.336.0
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - run: bundle exec ruby -e 'require "ruboty"; require "ruboty/cron"'
@@ -0,0 +1,11 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ uses: r7kamura/workflows/.github/workflows/gem-release.yml@main
11
+ if: github.repository_owner == 'r7kamura'
data/README.md CHANGED
@@ -7,9 +7,13 @@ You can use any [Chrono](https://github.com/r7kamura/chrono/) compatible cron sy
7
7
  ```
8
8
  @ruboty add job "<cron syntax>" <message> - Add a new cron job
9
9
  @ruboty delete job <id> - Delete a cron job
10
+ @ruboty suspend job <id> - Suspend a cron job
11
+ @ruboty resume job <id> - Resume a cron job
10
12
  @ruboty list jobs - List all cron jobs
11
13
  ```
12
14
 
15
+ The scheduled message will be delivered to your bot itself (instead of posting to somewhere by the bot directly) on the time. If the message contains any valid command, your bot will try to respond to it.
16
+
13
17
  ### Example
14
18
  ```
15
19
  $ bundle exec ruboty
@@ -35,3 +39,5 @@ If you want to schedule Ruboty to say something,
35
39
  ```
36
40
  > @ruboty add job "0 8 * * 1-5" @ruboty echo It's Time for School!
37
41
  ```
42
+
43
+ Note that you need to include `@ruboty` before the command name `echo`, because ruboty-echo responds only for any mention to the bot itself. Otherwise your bot will ignore the message as an invalid `echo` command.
@@ -28,8 +28,18 @@ module Ruboty
28
28
  thread.kill
29
29
  end
30
30
 
31
+ def suspend
32
+ stop
33
+ attributes["suspended"] = true
34
+ end
35
+
36
+ def resume(robot)
37
+ start(robot)
38
+ attributes.delete("suspended") if attributes.has_key?("suspended")
39
+ end
40
+
31
41
  def description
32
- %<%5s: "%s" %s> % [id, schedule, body]
42
+ %<%5s: (%s) "%s" %s> % [id, suspended? ? "suspended" : "active", schedule, body]
33
43
  end
34
44
 
35
45
  def id
@@ -43,6 +53,10 @@ module Ruboty
43
53
  def body
44
54
  attributes["body"]
45
55
  end
56
+
57
+ def suspended?
58
+ !!attributes["suspended"]
59
+ end
46
60
  end
47
61
  end
48
62
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Cron
3
- VERSION = "1.0.2"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -9,6 +9,10 @@ module Ruboty
9
9
 
10
10
  on(/list jobs\z/, name: "list", description: "List all cron jobs")
11
11
 
12
+ on(/suspend job (?<id>\d+)/, name: "suspend", description: "Suspend a cron job")
13
+
14
+ on(/resume job (?<id>\d+)/, name: "resume", description: "Resume a cron job")
15
+
12
16
  attr_writer :jobs
13
17
 
14
18
  def initialize(*args)
@@ -37,13 +41,48 @@ module Ruboty
37
41
  message.reply(summary, code: true)
38
42
  end
39
43
 
44
+ def suspend(message)
45
+ id = message[:id].to_i
46
+ if jobs.has_key?(id)
47
+ if running_jobs[id]
48
+ running_jobs[id].suspend
49
+ jobs[id] = running_jobs[id].to_hash
50
+ running_jobs.delete(id)
51
+ message.reply("Job #{id} suspended")
52
+ else
53
+ message.reply("Job #{id} had suspended")
54
+ end
55
+ else
56
+ message.reply("Job #{id} does not exist")
57
+ end
58
+ end
59
+
60
+ def resume(message)
61
+ id = message[:id].to_i
62
+ if jobs.has_key?(id)
63
+ job = Ruboty::Cron::Job.new(jobs[id])
64
+ if job.suspended?
65
+ job.resume(robot)
66
+ jobs[id] = job.to_hash
67
+ running_jobs[id] = job
68
+ message.reply("Job #{id} resumed")
69
+ else
70
+ message.reply("Job #{id} is running")
71
+ end
72
+ else
73
+ message.reply("Job #{id} does not exist")
74
+ end
75
+ end
76
+
40
77
  private
41
78
 
42
79
  def remember
43
80
  jobs.each do |id, attributes|
44
81
  job = Ruboty::Cron::Job.new(attributes)
45
- running_jobs[id] = job
46
- job.start(robot)
82
+ unless job.suspended?
83
+ running_jobs[id] = job
84
+ job.start(robot)
85
+ end
47
86
  end
48
87
  end
49
88
 
data/ruboty-cron.gemspec CHANGED
@@ -11,14 +11,20 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = "https://github.com/r7kamura/ruboty-cron"
12
12
  spec.license = "MIT"
13
13
 
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
17
+ spec.metadata["rubygems_mfa_required"] = "true"
18
+
14
19
  spec.files = `git ls-files -z`.split("\x0")
15
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
22
  spec.require_paths = ["lib"]
18
23
 
24
+ spec.required_ruby_version = ">= 3.3"
25
+
19
26
  spec.add_dependency "activesupport"
20
27
  spec.add_dependency "chrono"
21
28
  spec.add_dependency "ruboty", ">= 0.2.0"
22
- spec.add_development_dependency "bundler", "~> 1.6"
23
29
  spec.add_development_dependency "rake"
24
30
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -52,20 +51,6 @@ dependencies:
52
51
  - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: 0.2.0
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.6'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.6'
69
54
  - !ruby/object:Gem::Dependency
70
55
  name: rake
71
56
  requirement: !ruby/object:Gem::Requirement
@@ -80,15 +65,18 @@ dependencies:
80
65
  - - ">="
81
66
  - !ruby/object:Gem::Version
82
67
  version: '0'
83
- description:
84
68
  email:
85
69
  - r7kamura@gmail.com
86
70
  executables: []
87
71
  extensions: []
88
72
  extra_rdoc_files: []
89
73
  files:
74
+ - ".github/release.yml"
75
+ - ".github/workflows/actions.lock"
76
+ - ".github/workflows/bump-request.yml"
77
+ - ".github/workflows/ci.yml"
78
+ - ".github/workflows/release.yml"
90
79
  - ".gitignore"
91
- - CHANGELOG.md
92
80
  - Gemfile
93
81
  - LICENSE.txt
94
82
  - README.md
@@ -102,8 +90,11 @@ files:
102
90
  homepage: https://github.com/r7kamura/ruboty-cron
103
91
  licenses:
104
92
  - MIT
105
- metadata: {}
106
- post_install_message:
93
+ metadata:
94
+ homepage_uri: https://github.com/r7kamura/ruboty-cron
95
+ source_code_uri: https://github.com/r7kamura/ruboty-cron
96
+ changelog_uri: https://github.com/r7kamura/ruboty-cron/releases
97
+ rubygems_mfa_required: 'true'
107
98
  rdoc_options: []
108
99
  require_paths:
109
100
  - lib
@@ -111,17 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
102
  requirements:
112
103
  - - ">="
113
104
  - !ruby/object:Gem::Version
114
- version: '0'
105
+ version: '3.3'
115
106
  required_rubygems_version: !ruby/object:Gem::Requirement
116
107
  requirements:
117
108
  - - ">="
118
109
  - !ruby/object:Gem::Version
119
110
  version: '0'
120
111
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.5
123
- signing_key:
112
+ rubygems_version: 4.0.20
124
113
  specification_version: 4
125
114
  summary: Mount cron system to Ruboty to schedule messages on a specific time.
126
115
  test_files: []
127
- has_rdoc:
data/CHANGELOG.md DELETED
@@ -1,36 +0,0 @@
1
- ## 1.0.2
2
- - Support multi lines message (#4)
3
-
4
- ## 1.0.1
5
- - Fix greedy match
6
-
7
- ## 1.0.0
8
- - Chnage job behavior to receive body as message in scheduled time
9
-
10
- ## 0.0.9
11
- - Rename: Ellen -> Ruboty
12
-
13
- ## 0.0.8
14
- - Fix loaded modules
15
-
16
- ## 0.0.7
17
- - Format message if adapter supports :code option
18
-
19
- ## 0.0.6
20
- - Store & Rebuild all message attributes
21
-
22
- ## 0.0.5
23
- - Says where job is registered on
24
-
25
- ## 0.0.4
26
- - Support Ruboty v0.2.0
27
-
28
- ## 0.0.3
29
- - Remember registered jobs after initialized
30
- - Stop running job before its deletion
31
-
32
- ## 0.0.2
33
- - Support the new Brain interface
34
-
35
- ## 0.0.1
36
- - 1st Release