mastodon_command 0.1.8 → 0.1.10

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: a0d137a7b69f917c91d0adceb3f8b85674451b3150325a2af385c90ac65f7f88
4
- data.tar.gz: d2ee552c7c866da5f0b8cb3210f6758f1f4d35002dbc954c1a0456a1842a135e
3
+ metadata.gz: 8aceb7bcdeb04a6e01f2c4e67e24b944bd064ea6849e26b6a080fcfff9be7a01
4
+ data.tar.gz: 90540b8a90c4c9b408a62a1974c34cf37e7517aad5fdf973032ff6381ae7c507
5
5
  SHA512:
6
- metadata.gz: ec4f12f73bc0535f86f0810f3671ea31c90bea1a819bce3248ef8befd9b13e880c70f71352373b4e01033d76d04b6ed20bb03cc344869d9cc0092da9f462add1
7
- data.tar.gz: 14857f581ed5fef4026167d5d0e54cea4a39e997dd729bb03a73f9c63bb6e448a99e4a6c1066d6364ae6222c1805d6f3979be8d1b7d36a91c35de7a590da4f44
6
+ metadata.gz: 2ad72f5a17f8b1e1ae0449bd8ef82cf98b910226ec090bdfba6f033f8f94ad9061cc874756021a756d63608c832811646de0554c6cafbcc23fc42e95715e35e5
7
+ data.tar.gz: f174e8e7d8b5f2f5be1f15ad01c6a26bef9f046f2740ab1fdaae395270e94b710ea16fbbcee847432a2c1a776e2ade9af4b465e70f785d34163c03427aa5fade
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.0.3
5
+ before_install: gem install bundler -v 2.2.32
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'
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,19 +2,22 @@ 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
+ idempotency: request.headers['Idempotency-Key'],
18
+ with_rate_limit: true
19
+ )
20
+
18
21
  render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
19
22
  end
20
23
  end
@@ -1,3 +1,3 @@
1
1
  module MastodonCommand
2
- VERSION = "0.1.8"
2
+ VERSION = '0.1.10'.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"
32
+ spec.add_development_dependency "bundler", "~> 2.2.0"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
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.8
4
+ version: 0.1.10
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: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: 2.2.0
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.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -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