telepost 0.7.0 → 0.8.1

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
2
  SHA256:
3
- metadata.gz: ce9f085814a576e30a317fe675e5b9614b7ea2d5e29115b68dc97fc47b38bad4
4
- data.tar.gz: 8ab2ba95abc2b1374545b9786c085d2fc9c0800971534e552c116db28a0fd7a0
3
+ metadata.gz: 72e3854ed2c2ef04727919095d396357f7cd91641387825a039d28cafdf819cf
4
+ data.tar.gz: 4ef6fe085695c41b615dbc31ce0c885c966ecd357e361625e91d74aad61a07a4
5
5
  SHA512:
6
- metadata.gz: 0bebef45aa63ee4fd189bfbd8fb36d66f231ffd1b1968d8c7e160ad4b768bc3898491bc0c4eaa5e7ebc344ee4585cd9f1a1c86752c9a164c3d68e6a0315012e8
7
- data.tar.gz: a1ef9ccedac60beb0092a6cbf417fcd90272e9fdeb4ea836bc4c34dcc8f8ebde080ba61d182adfdb8609bb64680a6ad162f49d8efe641d809010ad40c8042f74
6
+ metadata.gz: 29ef8828ecfb355777daffb9a8a69fffd59b3393357bd60bc9b5012a9be6062c67ffd0660cd6d4bbd5c9a5effec7ef4a4c1bafbed5be7801b4494b935c1a3db2
7
+ data.tar.gz: 9e5aab74dccdca37292a2eb5959c2b24396cddfdd6189de47445ad0e48194efee77dbc3a7728303a70d1860f8f80984a9809794cdfecdf0440b5fb929d6effae
data/Gemfile CHANGED
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  source 'https://rubygems.org'
7
7
  gemspec
8
8
 
9
- gem 'minitest', '~>5.25', require: false
9
+ gem 'minitest', '~>6.0', require: false
10
10
  gem 'minitest-reporters', '~>1.7', require: false
11
11
  gem 'rake', '~>13.2', require: false
12
12
  gem 'rubocop', '~>1.71', require: false
13
+ gem 'rubocop-elegant', '>=0.0.20', require: false
13
14
  gem 'rubocop-minitest', '~>0.38', require: false
14
15
  gem 'rubocop-performance', '~>1.25', require: false
15
16
  gem 'rubocop-rake', '~>0.7', require: false
data/Gemfile.lock CHANGED
@@ -7,17 +7,18 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.8.7)
11
- public_suffix (>= 2.0.2, < 7.0)
12
- ansi (1.5.0)
10
+ addressable (2.9.0)
11
+ public_suffix (>= 2.0.2, < 8.0)
12
+ ansi (1.6.0)
13
13
  ast (2.4.3)
14
- bigdecimal (3.2.2)
14
+ bigdecimal (4.1.0)
15
15
  builder (3.3.0)
16
16
  concurrent-ruby (1.3.5)
17
- crack (1.0.0)
17
+ crack (1.0.1)
18
18
  bigdecimal
19
19
  rexml
20
20
  docile (1.4.1)
21
+ drb (2.2.3)
21
22
  dry-core (1.1.0)
22
23
  concurrent-ruby (~> 1.0)
23
24
  logger
@@ -33,8 +34,8 @@ GEM
33
34
  dry-types (~> 1.8, >= 1.8.2)
34
35
  ice_nine (~> 0.11)
35
36
  zeitwerk (~> 2.6)
36
- dry-types (1.8.3)
37
- bigdecimal (~> 3.0)
37
+ dry-types (1.9.1)
38
+ bigdecimal (>= 3.0)
38
39
  concurrent-ruby (~> 1.0)
39
40
  dry-core (~> 1.0)
40
41
  dry-inflector (~> 1.0)
@@ -48,54 +49,65 @@ GEM
48
49
  multipart-post (~> 2.0)
49
50
  faraday-net_http (3.4.1)
50
51
  net-http (>= 0.5.0)
51
- hashdiff (1.2.0)
52
+ hashdiff (1.2.1)
52
53
  ice_nine (0.11.2)
53
- json (2.13.0)
54
+ json (2.19.2)
55
+ json-schema (6.2.0)
56
+ addressable (~> 2.8)
57
+ bigdecimal (>= 3.1, < 5)
54
58
  language_server-protocol (3.17.0.5)
55
59
  lint_roller (1.1.0)
56
60
  logger (1.7.0)
57
- minitest (5.25.5)
58
- minitest-reporters (1.7.1)
61
+ mcp (0.9.2)
62
+ json-schema (>= 4.1)
63
+ minitest (6.0.5)
64
+ drb (~> 2.0)
65
+ prism (~> 1.5)
66
+ minitest-reporters (1.8.0)
59
67
  ansi
60
68
  builder
61
- minitest (>= 5.0)
69
+ minitest (>= 5.0, < 7)
62
70
  ruby-progressbar
63
71
  multipart-post (2.4.1)
64
72
  net-http (0.6.0)
65
73
  uri
66
74
  parallel (1.27.0)
67
- parser (3.3.8.0)
75
+ parser (3.3.10.2)
68
76
  ast (~> 2.4.1)
69
77
  racc
70
- prism (1.4.0)
71
- public_suffix (6.0.2)
78
+ prism (1.9.0)
79
+ public_suffix (7.0.5)
72
80
  racc (1.8.1)
73
81
  rainbow (3.1.1)
74
- rake (13.3.0)
75
- regexp_parser (2.10.0)
76
- rexml (3.4.1)
77
- rubocop (1.78.0)
82
+ rake (13.4.2)
83
+ regexp_parser (2.11.3)
84
+ rexml (3.4.4)
85
+ rubocop (1.85.1)
78
86
  json (~> 2.3)
79
87
  language_server-protocol (~> 3.17.0.2)
80
88
  lint_roller (~> 1.1.0)
89
+ mcp (~> 0.6)
81
90
  parallel (~> 1.10)
82
91
  parser (>= 3.3.0.2)
83
92
  rainbow (>= 2.2.2, < 4.0)
84
93
  regexp_parser (>= 2.9.3, < 3.0)
85
- rubocop-ast (>= 1.45.1, < 2.0)
94
+ rubocop-ast (>= 1.49.0, < 2.0)
86
95
  ruby-progressbar (~> 1.7)
87
96
  unicode-display_width (>= 2.4.0, < 4.0)
88
- rubocop-ast (1.46.0)
97
+ rubocop-ast (1.49.1)
89
98
  parser (>= 3.3.7.2)
90
- prism (~> 1.4)
91
- rubocop-minitest (0.38.1)
99
+ prism (~> 1.7)
100
+ rubocop-elegant (0.0.20)
101
+ lint_roller (~> 1.1)
102
+ rubocop (~> 1.75)
103
+ rubocop-minitest (0.39.1)
92
104
  lint_roller (~> 1.1)
93
105
  rubocop (>= 1.75.0, < 2.0)
94
106
  rubocop-ast (>= 1.38.0, < 2.0)
95
- rubocop-performance (1.25.0)
107
+ rubocop-performance (1.26.1)
96
108
  lint_roller (~> 1.1)
97
109
  rubocop (>= 1.75.0, < 2.0)
98
- rubocop-ast (>= 1.38.0, < 2.0)
110
+ rubocop-ast (>= 1.47.1, < 2.0)
99
111
  rubocop-rake (0.7.1)
100
112
  lint_roller (~> 1.1)
101
113
  rubocop (>= 1.72.1)
@@ -104,7 +116,7 @@ GEM
104
116
  docile (~> 1.1)
105
117
  simplecov-html (~> 0.11)
106
118
  simplecov_json_formatter (~> 0.1)
107
- simplecov-cobertura (3.0.0)
119
+ simplecov-cobertura (3.1.0)
108
120
  rexml
109
121
  simplecov (~> 0.19)
110
122
  simplecov-html (0.13.2)
@@ -114,15 +126,15 @@ GEM
114
126
  faraday (~> 2.0)
115
127
  faraday-multipart (~> 1.0)
116
128
  zeitwerk (~> 2.6)
117
- unicode-display_width (3.1.4)
118
- unicode-emoji (~> 4.0, >= 4.0.4)
119
- unicode-emoji (4.0.4)
120
- uri (1.0.3)
121
- webmock (3.25.1)
129
+ unicode-display_width (3.2.0)
130
+ unicode-emoji (~> 4.1)
131
+ unicode-emoji (4.2.0)
132
+ uri (1.0.4)
133
+ webmock (3.26.2)
122
134
  addressable (>= 2.8.0)
123
135
  crack (>= 0.3.2)
124
136
  hashdiff (>= 0.4.0, < 2.0.0)
125
- yard (0.9.37)
137
+ yard (0.9.43)
126
138
  zeitwerk (2.7.3)
127
139
 
128
140
  PLATFORMS
@@ -133,10 +145,11 @@ PLATFORMS
133
145
  x86_64-linux
134
146
 
135
147
  DEPENDENCIES
136
- minitest (~> 5.25)
148
+ minitest (~> 6.0)
137
149
  minitest-reporters (~> 1.7)
138
150
  rake (~> 13.2)
139
151
  rubocop (~> 1.71)
152
+ rubocop-elegant (>= 0.0.20)
140
153
  rubocop-minitest (~> 0.38)
141
154
  rubocop-performance (~> 1.25)
142
155
  rubocop-rake (~> 0.7)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-2025 Yegor Bugayenko
3
+ Copyright (c) 2018-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/LICENSES/MIT.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-2025 Yegor Bugayenko
3
+ Copyright (c) 2018-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -46,6 +46,15 @@ tp = Telepost.new('..token..', chats: [12345])
46
46
  tp.spam('How are you?')
47
47
  ```
48
48
 
49
+ You can also attach a file (sent as a Telegram document). The
50
+ `file` argument accepts a path or an already-open `IO`/`File`,
51
+ and `caption:` is optional:
52
+
53
+ ```ruby
54
+ tp = Telepost.new('..token..')
55
+ tp.attach(12345, '/tmp/dump.sql', caption: 'Today is dump')
56
+ ```
57
+
49
58
  That's it.
50
59
 
51
60
  ## How to contribute
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
- require 'rubygems'
7
6
  require 'rake'
8
7
  require 'rake/clean'
8
+ require 'rubygems'
9
9
 
10
10
  CLEAN = FileList['coverage']
11
11
 
@@ -37,4 +37,5 @@ require 'yard'
37
37
  desc 'Build Yard documentation'
38
38
  YARD::Rake::YardocTask.new do |t|
39
39
  t.files = ['lib/**/*.rb']
40
+ t.options = ['--fail-on-warning']
40
41
  end
data/lib/telepost.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'telegram/bot'
@@ -18,7 +18,7 @@ require 'telegram/bot'
18
18
  # {README}[https://github.com/yegor256/telepost/blob/master/README.md] file.
19
19
  #
20
20
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
21
- # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
21
+ # Copyright:: Copyright (c) 2018-2026 Yegor Bugayenko
22
22
  # License:: MIT
23
23
  class Telepost
24
24
  # Fake implementation for testing
@@ -31,9 +31,7 @@ class Telepost
31
31
  @sent = []
32
32
  end
33
33
 
34
- def run
35
- # Nothing to do here
36
- end
34
+ def run; end
37
35
 
38
36
  def spam(*lines)
39
37
  post(0, lines)
@@ -42,6 +40,12 @@ class Telepost
42
40
  def post(chat, *lines)
43
41
  @sent << "#{chat}: #{lines.join(' ')}"
44
42
  end
43
+
44
+ def attach(chat, file, caption: nil)
45
+ path = file.is_a?(String) ? file : file.path
46
+ tail = caption.nil? ? '' : " caption=#{caption}"
47
+ @sent << "#{chat}: [attach:#{File.basename(path)}#{tail}]"
48
+ end
45
49
  end
46
50
 
47
51
  # When can't post a message
@@ -49,9 +53,6 @@ class Telepost
49
53
  # @note Raised when message posting fails
50
54
  class CantPost < StandardError; end
51
55
 
52
- # To make it possible to get the client.
53
- #
54
- # @return [Telegram::Bot::Client] The Telegram bot client
55
56
  attr_reader :client
56
57
 
57
58
  # Makes a new object. To obtain a token you should talk
@@ -72,8 +73,10 @@ class Telepost
72
73
  # @return [void]
73
74
  # @raise [RuntimeError] If no block is given
74
75
  def run
75
- raise 'Block must be given' unless block_given?
76
+ raise(RuntimeError, 'Block must be given') unless block_given?
76
77
  @bot.listen do |message|
78
+ next unless message.respond_to?(:chat)
79
+ next if message.chat.nil?
77
80
  yield(message.chat.id, message.respond_to?(:text) ? message.text : '')
78
81
  end
79
82
  rescue Net::OpenTimeout
@@ -102,11 +105,25 @@ class Telepost
102
105
  # @param lines [Array<String>] Message lines to send
103
106
  # @return [Telegram::Bot::Types::Message] The sent message object
104
107
  def post(chat, *lines, parse_mode: 'Markdown')
105
- @bot.api.send_message(
106
- chat_id: chat,
107
- parse_mode:,
108
- disable_web_page_preview: true,
109
- text: lines.join(' ')
110
- )
108
+ @bot.api.send_message(chat_id: chat, parse_mode:, disable_web_page_preview: true, text: lines.join(' '))
109
+ end
110
+
111
+ # Attach a file (as a Telegram document) to the chat. The file
112
+ # argument can either be a path (String) or an open IO/File. The
113
+ # filename shown in Telegram comes from the basename of the path.
114
+ #
115
+ # @param chat [Integer, String] Chat ID or channel name
116
+ # @param file [String, File, IO] Path to the file or an open IO
117
+ # @param caption [String, nil] Optional caption for the attachment
118
+ # @param parse_mode [String] Parse mode used for the caption
119
+ # @return [Telegram::Bot::Types::Message] The sent message object
120
+ def attach(chat, file, caption: nil, parse_mode: 'Markdown')
121
+ document =
122
+ if file.is_a?(String)
123
+ Faraday::UploadIO.new(file, 'application/octet-stream', File.basename(file))
124
+ else
125
+ file
126
+ end
127
+ @bot.api.send_document(chat_id: chat, document:, caption:, parse_mode:)
111
128
  end
112
129
  end
data/telepost.gemspec CHANGED
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'English'
7
7
 
8
8
  Gem::Specification.new do |s|
9
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
10
10
  s.required_ruby_version = '>=3.2'
11
11
  s.name = 'telepost'
12
- s.version = '0.7.0'
12
+ s.version = '0.8.1'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Simple Telegram posting Ruby gem'
15
15
  s.description = 'Simple Telegram posting Ruby gem'
16
16
  s.authors = ['Yegor Bugayenko']
17
17
  s.email = 'yegor256@gmail.com'
18
18
  s.homepage = 'https://github.com/yegor256/telepost'
19
- s.files = `git ls-files`.split($RS)
19
+ s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
20
20
  s.rdoc_options = ['--charset=UTF-8']
21
21
  s.extra_rdoc_files = ['README.md']
22
- s.add_dependency 'telegram-bot-ruby', '~> 1.0'
22
+ s.add_dependency('telegram-bot-ruby', '~> 1.0')
23
23
  s.metadata['rubygems_mfa_required'] = 'true'
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telepost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -30,21 +30,6 @@ extensions: []
30
30
  extra_rdoc_files:
31
31
  - README.md
32
32
  files:
33
- - ".0pdd.yml"
34
- - ".github/workflows/actionlint.yml"
35
- - ".github/workflows/codecov.yml"
36
- - ".github/workflows/copyrights.yml"
37
- - ".github/workflows/markdown-lint.yml"
38
- - ".github/workflows/pdd.yml"
39
- - ".github/workflows/rake.yml"
40
- - ".github/workflows/reuse.yml"
41
- - ".github/workflows/typos.yml"
42
- - ".github/workflows/xcop.yml"
43
- - ".github/workflows/yamllint.yml"
44
- - ".gitignore"
45
- - ".pdd"
46
- - ".rubocop.yml"
47
- - ".rultor.yml"
48
33
  - Gemfile
49
34
  - Gemfile.lock
50
35
  - LICENSE.txt
@@ -54,10 +39,7 @@ files:
54
39
  - Rakefile
55
40
  - lib/telepost.rb
56
41
  - logo.svg
57
- - renovate.json
58
42
  - telepost.gemspec
59
- - test/test__helper.rb
60
- - test/test_telepost.rb
61
43
  homepage: https://github.com/yegor256/telepost
62
44
  licenses:
63
45
  - MIT
@@ -78,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
60
  - !ruby/object:Gem::Version
79
61
  version: '0'
80
62
  requirements: []
81
- rubygems_version: 3.6.7
63
+ rubygems_version: 3.6.9
82
64
  specification_version: 4
83
65
  summary: Simple Telegram posting Ruby gem
84
66
  test_files: []
data/.0pdd.yml DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
- ---
6
- errors:
7
- - yegor256@gmail.com
8
-
9
- tags:
10
- - pdd
11
- - bug
@@ -1,25 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: actionlint
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- actionlint:
15
- timeout-minutes: 15
16
- runs-on: ubuntu-24.04
17
- steps:
18
- - uses: actions/checkout@v4
19
- - name: Download actionlint
20
- id: get_actionlint
21
- run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
22
- shell: bash
23
- - name: Check workflow files
24
- run: ${{ steps.get_actionlint.outputs.executable }} -color
25
- shell: bash
@@ -1,25 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: codecov
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- jobs:
11
- codecov:
12
- timeout-minutes: 15
13
- runs-on: ubuntu-24.04
14
- steps:
15
- - uses: actions/checkout@v4
16
- - uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: 3.3
19
- bundler-cache: true
20
- - run: bundle config set --global path "$(pwd)/vendor/bundle"
21
- - run: bundle install --no-color
22
- - run: bundle exec rake
23
- - uses: codecov/codecov-action@v5
24
- with:
25
- token: ${{ secrets.CODECOV_TOKEN }}
@@ -1,15 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: copyrights
6
- 'on':
7
- push:
8
- pull_request:
9
- jobs:
10
- copyrights:
11
- timeout-minutes: 15
12
- runs-on: ubuntu-24.04
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: yegor256/copyrights-action@0.0.12
@@ -1,23 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: markdown-lint
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- paths-ignore: ['paper/**', 'sandbox/**']
14
- concurrency:
15
- group: markdown-lint-${{ github.ref }}
16
- cancel-in-progress: true
17
- jobs:
18
- markdown-lint:
19
- timeout-minutes: 15
20
- runs-on: ubuntu-24.04
21
- steps:
22
- - uses: actions/checkout@v4
23
- - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
@@ -1,19 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: pdd
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- pdd:
15
- timeout-minutes: 15
16
- runs-on: ubuntu-24.04
17
- steps:
18
- - uses: actions/checkout@v4
19
- - uses: volodya-lombrozo/pdd-action@master
@@ -1,28 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: rake
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- test:
15
- strategy:
16
- matrix:
17
- os: [ubuntu-24.04, macos-15, windows-2022]
18
- ruby: [3.3]
19
- runs-on: ${{ matrix.os }}
20
- steps:
21
- - uses: actions/checkout@v4
22
- - uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler-cache: true
26
- - run: bundle config set --global path "$(pwd)/vendor/bundle"
27
- - run: bundle install --no-color
28
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: reuse
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- reuse:
15
- timeout-minutes: 15
16
- runs-on: ubuntu-24.04
17
- steps:
18
- - uses: actions/checkout@v4
19
- - uses: fsfe/reuse-action@v5
@@ -1,19 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: typos
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- typos:
15
- timeout-minutes: 15
16
- runs-on: ubuntu-24.04
17
- steps:
18
- - uses: actions/checkout@v4
19
- - uses: crate-ci/typos@v1.33.1
@@ -1,15 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: xcop
6
- 'on':
7
- push:
8
- pull_request:
9
- jobs:
10
- xcop:
11
- timeout-minutes: 15
12
- runs-on: ubuntu-24.04
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: g4s8/xcop-action@master
@@ -1,19 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
2
- # SPDX-License-Identifier: MIT
3
- ---
4
- # yamllint disable rule:line-length
5
- name: yamllint
6
- 'on':
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
- branches:
12
- - master
13
- jobs:
14
- yamllint:
15
- timeout-minutes: 15
16
- runs-on: ubuntu-24.04
17
- steps:
18
- - uses: actions/checkout@v4
19
- - uses: ibiqlik/action-yamllint@v3
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- .bundle/
2
- .DS_Store
3
- .idea/
4
- .yardoc/
5
- *.gem
6
- coverage/
7
- doc/
8
- node_modules/
9
- rdoc/
10
- vendor/
data/.pdd DELETED
@@ -1,5 +0,0 @@
1
- --source=.
2
- --verbose
3
- --rule min-words:20
4
- --rule min-estimate:15
5
- --rule max-estimate:90
data/.rubocop.yml DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
- ---
6
- AllCops:
7
- Exclude:
8
- - 'bin/**/*'
9
- - 'assets/**/*'
10
- - 'vendor/**/*'
11
- - 'j/**/*'
12
- DisplayCopNames: true
13
- TargetRubyVersion: 3.2
14
- NewCops: enable
15
- SuggestExtensions: false
16
- plugins:
17
- - rubocop-rake
18
- - rubocop-minitest
19
- - rubocop-performance
20
- Minitest/EmptyLineBeforeAssertionMethods:
21
- Enabled: false
22
- Layout/EmptyLineAfterGuardClause:
23
- Enabled: false
24
- Layout/MultilineMethodCallIndentation:
25
- Enabled: false
26
- Metrics/AbcSize:
27
- Max: 50
28
- Metrics/MethodLength:
29
- Max: 30
30
- Metrics/CyclomaticComplexity:
31
- Max: 10
32
- Metrics/PerceivedComplexity:
33
- Max: 10
34
- Metrics/ParameterLists:
35
- Max: 10
36
- Layout/ParameterAlignment:
37
- Enabled: false
38
- require: []
data/.rultor.yml DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
- ---
6
- # yamllint disable rule:line-length
7
- docker:
8
- image: yegor256/ruby
9
- assets:
10
- rubygems.yml: yegor256/home#assets/rubygems.yml
11
- install: |-
12
- pdd -f /dev/null
13
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
14
- release:
15
- pre: false
16
- script: |-
17
- bundle exec rake
18
- rm -rf *.gem
19
- sed -i "s/0\.0\.0/${tag}/g" telepost.gemspec
20
- git add telepost.gemspec
21
- git commit -m "Version set to ${tag}"
22
- gem build telepost.gemspec
23
- chmod 0600 ../rubygems.yml
24
- gem push *.gem --config-file ../rubygems.yml
25
- merge:
26
- script: |-
27
- bundle exec rake
data/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ]
6
- }
data/test/test__helper.rb DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- $stdout.sync = true
7
-
8
- require 'simplecov'
9
- require 'simplecov-cobertura'
10
- unless SimpleCov.running || ENV['PICKS']
11
- SimpleCov.command_name('test')
12
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
- [
14
- SimpleCov::Formatter::HTMLFormatter,
15
- SimpleCov::Formatter::CoberturaFormatter
16
- ]
17
- )
18
- SimpleCov.minimum_coverage 85
19
- SimpleCov.minimum_coverage_by_file 85
20
- SimpleCov.start do
21
- add_filter 'test/'
22
- add_filter 'vendor/'
23
- add_filter 'target/'
24
- track_files 'lib/**/*.rb'
25
- track_files '*.rb'
26
- end
27
- end
28
-
29
- require 'minitest/autorun'
30
- require 'minitest/reporters'
31
- Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
32
-
33
- require 'webmock/minitest'
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'yaml'
7
- require_relative 'test__helper'
8
- require_relative '../lib/telepost'
9
-
10
- # Telepost test.
11
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
12
- # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
13
- # License:: MIT
14
- class TelepostTest < Minitest::Test
15
- def test_fake_posting
16
- tp = Telepost::Fake.new
17
- tp.run
18
- tp.post(123, 'This is', 'a simple', 'message')
19
- assert_equal(1, tp.sent.count)
20
- end
21
-
22
- def test_fake_spam
23
- tp = Telepost::Fake.new
24
- tp.spam('how are you all?')
25
- end
26
-
27
- def test_sends_single_message
28
- WebMock.disable_net_connect!
29
- stub_request(:post, 'https://api.telegram.org/botfoo/sendMessage').to_return(body: '{}')
30
- tp = Telepost.new('foo')
31
- tp.post(42, 'hello!')
32
- end
33
-
34
- def test_sends_simple_spam
35
- WebMock.disable_net_connect!
36
- stub_request(:post, 'https://api.telegram.org/bottoken/sendMessage').to_return(body: '{}')
37
- tp = Telepost.new('token', chats: [42])
38
- tp.spam('hey!')
39
- end
40
-
41
- def test_listens
42
- WebMock.disable_net_connect!
43
- stub_request(:post, 'https://api.telegram.org/botxx/getUpdates')
44
- .to_return(status: 200, body: '{}')
45
- tp = Telepost.new('xx')
46
- t =
47
- Thread.new do
48
- tp.run do |chat, msg|
49
- # we'll never reach this point
50
- end
51
- end
52
- t.terminate
53
- t.join
54
- end
55
-
56
- def test_real_posting
57
- WebMock.enable_net_connect!
58
- cfg = '/code/home/assets/zerocracy/baza.yml'
59
- skip unless File.exist?(cfg)
60
- yaml = YAML.safe_load_file(cfg)
61
- tp = Telepost.new(
62
- yaml['tg']['token'],
63
- chats: [yaml['tg']['admin_chat'].to_i]
64
- )
65
- tp.spam('This is just a test message from telepost test')
66
- end
67
- end