mastodon_command 0.1.9 → 4.2.3

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: e30efa3ddcfc5a17a306ffcd479011ce049c95e61dfdacb20b5889965184c4a1
4
- data.tar.gz: 112a9291c179a70d191deec44cfdcfc629013d6b7add1df416a8628ab75a952a
3
+ metadata.gz: e1af1e330d3503e6cee6fa7eb39598b350467ab34be10324578e4578d72aa524
4
+ data.tar.gz: 84c727198d9b53ea9447b7e556e1f77550937fe900434ede12599b01b1e83623
5
5
  SHA512:
6
- metadata.gz: 75f5185b959273a14f98229872525bc8e43b9b0eb0212f9f3894df3d08a817e3f2439f864d4c7697165fef8083088e8d62c4f60899ee7c8d6f393d70b01e861d
7
- data.tar.gz: 640348e8cd8679fe75e302188e0add765b7dda209cb3c77d2f275352d3501048b4c12eba5ae98388827f882d47bff5eb57faaff469686f72913c59753f55a869
6
+ metadata.gz: bce92c9bebdc36e57ef3e8bcbf3e657e97404e3d42a91b4b11f9f2950188b25d041fed87fb436a442333e80af3593db56b89df0e7621cc02f16a454b944741ae
7
+ data.tar.gz: 84473e6b6be833308f2fa6e5867ae8b680a6f39e18f988c1f92e8c6f7bbfbb77eadee56cb7f6445b43fc59fed7187a817f802b5a6f1b653e7121da9234f01e4e
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.15.1
4
+ - 3.2.2
5
+ before_install: gem install bundler -v 2.5.23
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # MastodonCommand
2
2
  - おみくじ機能や大阪弁機能などをつけることができます。
3
- - ローカルでマストドンのバージョン3.4.6にて動作を確認済み
3
+ - ローカルでマストドンのバージョン3.5.0にて動作を確認済み
4
4
  (このプログラムを使って問題が起こっても保証はできないので予めご了承ください🙇‍♂️)
5
5
 
6
6
  ## Installation
7
7
 
8
8
  ```ruby
9
- gem 'mastodon_command', '0.1.9'
9
+ gem 'mastodon_command', '0.1.10'
10
10
  ```
11
11
 
12
12
  ## Usage
@@ -21,11 +21,11 @@ Rails.application.configure do
21
21
  config.after_initialize do
22
22
  MastodonCommand.setup do |status|
23
23
  # おみくじ機能
24
- fortune = MastodonCommand::Random.new('[  \n]?#(おみくじ|占い|運勢)[  \n]?', %w(大吉 中吉 小吉 吉 半吉 凶 大凶))
24
+ fortune = MastodonCommand::RandomConverter.new('[  \n]?#(おみくじ|占い|運勢)[  \n]?', %w(大吉 中吉 小吉 吉 半吉 凶 大凶))
25
25
  status = fortune.convert(status) if fortune.match(status)
26
26
 
27
27
  # 大阪弁機能
28
- osaka = MastodonCommand::Lang.new('[  \n]?#(大阪弁)[  \n]?', [
28
+ osaka = MastodonCommand::LangConverter.new('[  \n]?#(大阪弁)[  \n]?', [
29
29
  {
30
30
  pattern: 'です',
31
31
  replace: 'やで'
@@ -1,7 +1,6 @@
1
1
  module MastodonCommand
2
- class Convert
3
- attr_accessor :pattern
4
- attr_accessor :replaces
2
+ class Converter
3
+ attr_accessor :pattern, :replaces
5
4
 
6
5
  def initialize(pattern, replaces)
7
6
  @pattern = pattern
@@ -1,10 +1,9 @@
1
1
  module MastodonCommand
2
- class Lang < MastodonCommand::Convert
3
-
2
+ class LangConverter < MastodonCommand::Converter
4
3
  def convert(input)
5
- @replaces.each {|replace|
4
+ @replaces.each do |replace|
6
5
  input = input.gsub(/#{replace[:pattern]}/, replace[:replace])
7
- }
6
+ end
8
7
  input
9
8
  end
10
9
  end
@@ -0,0 +1,7 @@
1
+ module MastodonCommand
2
+ class RandomConverter < MastodonCommand::Converter
3
+ def convert(input)
4
+ "#{input}\nあなたの運勢は「#{@replaces.sample}」です"
5
+ end
6
+ end
7
+ end
@@ -2,20 +2,30 @@ module MastodonCommand
2
2
  module StatusesControllerPatch
3
3
  def create
4
4
  status = MastodonCommand.convert_toot(status_params[:status])
5
- @status = PostStatusService.new.call(current_user.account,
6
- text: status,
7
- thread: @thread,
8
- media_ids: status_params[:media_ids],
9
- sensitive: status_params[:sensitive],
10
- spoiler_text: status_params[:spoiler_text],
11
- visibility: status_params[:visibility],
12
- scheduled_at: status_params[:scheduled_at],
13
- application: doorkeeper_token.application,
14
- poll: status_params[:poll],
15
- idempotency: request.headers['Idempotency-Key'],
16
- with_rate_limit: true)
17
-
5
+ @status = PostStatusService.new.call(
6
+ current_user.account,
7
+ text: status,
8
+ thread: @thread,
9
+ media_ids: status_params[:media_ids],
10
+ sensitive: status_params[:sensitive],
11
+ spoiler_text: status_params[:spoiler_text],
12
+ visibility: status_params[:visibility],
13
+ language: status_params[:language],
14
+ scheduled_at: status_params[:scheduled_at],
15
+ application: doorkeeper_token.application,
16
+ poll: status_params[:poll],
17
+ allowed_mentions: status_params[:allowed_mentions],
18
+ idempotency: request.headers['Idempotency-Key'],
19
+ with_rate_limit: true
20
+ )
21
+
18
22
  render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
23
+ rescue PostStatusService::UnexpectedMentionsError => e
24
+ unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new(
25
+ e.accounts,
26
+ serializer: REST::AccountSerializer
27
+ )
28
+ render json: { error: e.message, unexpected_accounts: unexpected_accounts }, status: 422
19
29
  end
20
30
  end
21
31
  end
@@ -1,3 +1,3 @@
1
1
  module MastodonCommand
2
- VERSION = "0.1.9"
2
+ VERSION = '4.2.3'.freeze
3
3
  end
@@ -1,25 +1,14 @@
1
- require "mastodon_command/version"
2
- require "mastodon_command/convert"
3
- require "mastodon_command/convert_random"
4
- require "mastodon_command/convert_lang"
5
- require "mastodon_command/statuses_controller_patch"
1
+ require 'mastodon_command/version'
2
+ require 'mastodon_command/converter'
3
+ require 'mastodon_command/random_converter'
4
+ require 'mastodon_command/lang_converter'
5
+ require 'mastodon_command/statuses_controller_patch'
6
6
 
7
7
  module MastodonCommand
8
8
  def self.setup(&proc)
9
- # create function for Monkey patch
10
- extend self
11
- (
12
- class << self;
13
- self
14
- end).module_eval do
15
- define_method 'convert_toot', &proc
16
- # define_method 'b' do
17
- # p 'b'
18
- # end
19
- end
9
+ define_singleton_method(:convert_toot, &proc)
20
10
 
21
11
  # Monkey patch
22
12
  Api::V1::StatusesController.prepend(MastodonCommand::StatusesControllerPatch)
23
13
  end
24
14
  end
25
-
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.15"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "bundler", "~> 2"
33
+ spec.add_development_dependency "rake", "~> 13"
34
+ spec.add_development_dependency "rspec", "~> 3"
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastodon_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenchiki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2025-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.15'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3'
55
55
  description: Mastodon Toot Command.
56
56
  email:
57
57
  - nagai-kj@nagai-galaxy.com
@@ -68,9 +68,9 @@ files:
68
68
  - bin/console
69
69
  - bin/setup
70
70
  - lib/mastodon_command.rb
71
- - lib/mastodon_command/convert.rb
72
- - lib/mastodon_command/convert_lang.rb
73
- - lib/mastodon_command/convert_random.rb
71
+ - lib/mastodon_command/converter.rb
72
+ - lib/mastodon_command/lang_converter.rb
73
+ - lib/mastodon_command/random_converter.rb
74
74
  - lib/mastodon_command/statuses_controller_patch.rb
75
75
  - lib/mastodon_command/version.rb
76
76
  - mastodon_command.gemspec
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.2.32
95
+ rubygems_version: 3.4.19
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Mastodon Toot Command.
@@ -1,8 +0,0 @@
1
- module MastodonCommand
2
- class Random < MastodonCommand::Convert
3
-
4
- def convert(input)
5
- input + "\nあなたの運勢は「" + @replaces.sample + '」です'
6
- end
7
- end
8
- end