moostodon 0.2.0 → 0.4.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: 5f038cf56717aa994ca947f4bbad7534c836077e
4
- data.tar.gz: 794e0d73f1b841fcaefbd39bb2701b2c3a247546
2
+ SHA256:
3
+ metadata.gz: 2580c5ee1288d53430a0eb92bd55f9228d197ea529a175115862c34292d3dad7
4
+ data.tar.gz: 278f4930eda8f39a12bd5d3a3c57d761effdda5d7367f6f55ea39924cd32a87a
5
5
  SHA512:
6
- metadata.gz: 2bd4966f31b63c77afde8378911dd3c230035daf1916f321792f26298533a6bd8e7c28cff9915140824c0a8bb4759bc79fcbc81fe7f3a56691cc017ddddb657e
7
- data.tar.gz: e29819fd090bc36898337632083dddd286a96e4982fa7d415b275066ef7b67e499832b362ab4adc3c1398e8207e0a9ae950f23e933dca43d8aa05e72ff6f3e9c
6
+ metadata.gz: 148d9169f3f691ab0b473ff6d63dfe30b867809177618281cbc7f130d97b181fccb1e57bd51361740dc28c7bda43925e970141f12f1c5c27821101149b5596a7
7
+ data.tar.gz: 6bae80cac1da85d1505710c5ffdf5f3feb8d255322fb98facd8b8d61d9289552fb9ed6af7053686efdaa8732472cd288cb20e848200beaa68e71c8b8a0b43ffa
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'field'
4
+
3
5
  module Mastodon
4
6
  class Account < Mastodon::Base
5
7
  # @!attribute [r] id
@@ -34,6 +36,10 @@ module Mastodon
34
36
  # @return [Boolean]
35
37
  # @!attribute [r] moved
36
38
  # @return [Mastodon::Account]
39
+ # @!attribute [r] fields
40
+ # @return [Mastodon::Collection<Mastodon::Field>]
41
+ # @!attribute [r] bot?
42
+ # @return [Boolean]
37
43
 
38
44
  normal_attr_reader :id,
39
45
  :username,
@@ -50,10 +56,12 @@ module Mastodon
50
56
  :following_count,
51
57
  :statuses_count
52
58
 
53
- predicate_attr_reader :locked
59
+ predicate_attr_reader :locked, :bot
54
60
 
55
61
  object_attr_reader :moved, Mastodon::Account
56
62
 
63
+ collection_attr_reader :fields, Mastodon::Field
64
+
57
65
  def initialize(attributes = {})
58
66
  attributes.fetch('id')
59
67
  super
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/version'
3
+ require_relative 'version'
4
4
 
5
5
  module Mastodon
6
6
  class Client
@@ -7,6 +7,7 @@ module Mastodon
7
7
  BadRequest = Class.new(ClientError)
8
8
  Unauthorized = Class.new(ClientError)
9
9
  Forbidden = Class.new(ClientError)
10
+ NotFound = Class.new(ClientError)
10
11
  UnprocessableEntity = Class.new(ClientError)
11
12
  TooManyRequests = Class.new(ClientError)
12
13
 
@@ -20,6 +21,7 @@ module Mastodon
20
21
  400 => Mastodon::Error::BadRequest,
21
22
  401 => Mastodon::Error::Unauthorized,
22
23
  403 => Mastodon::Error::Forbidden,
24
+ 404 => Mastodon::Error::NotFound,
23
25
  422 => Mastodon::Error::UnprocessableEntity,
24
26
  429 => Mastodon::Error::TooManyRequests,
25
27
  500 => Mastodon::Error::InternalServerError,
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mastodon
4
+ class Field < Mastodon::Base
5
+ # @!attribute [r] name
6
+ # @return [String]
7
+ # @!attribute [r] value
8
+ # @return [String]
9
+ # @!attribute [r] verified_at
10
+ # @return [String]
11
+
12
+ normal_attr_reader :name, :value, :verified_at
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mastodon
4
+ class Filter < Mastodon::Base
5
+ # @!attribute [r] id
6
+ # @return [String]
7
+ # @!attribute [r] phrase
8
+ # @return [String]
9
+ # @!attribute [r] context
10
+ # @return [Array<String>]
11
+ # @!attribute [r] expires_at
12
+ # @return [String]
13
+ # @!attribute [r] irreversible?
14
+ # @return [Boolean]
15
+ # @!attribute [r] whole_word?
16
+ # @return [Boolean]
17
+
18
+ normal_attr_reader :id,
19
+ :phrase,
20
+ :context,
21
+ :expires_at
22
+
23
+ predicate_attr_reader :irreversible,
24
+ :whole_word
25
+
26
+ def initialize(attributes = {})
27
+ attributes.fetch('id')
28
+ super
29
+ end
30
+ end
31
+ end
32
+
@@ -14,12 +14,18 @@ module Mastodon
14
14
  # @return [String]
15
15
  # @!attribute [r] urls
16
16
  # @return [Hash]
17
+ # @!attribute [r] thumbnail
18
+ # @return [String]
19
+ # @!attribute [r] max_toot_chars
20
+ # @return [Integer]
17
21
 
18
22
  normal_attr_reader :uri,
19
23
  :title,
20
24
  :description,
21
25
  :email,
22
26
  :version,
23
- :urls
27
+ :urls,
28
+ :thumbnail,
29
+ :max_toot_chars
24
30
  end
25
31
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/account'
3
+ require_relative '../rest/utils'
4
+ require_relative '../account'
5
+ require_relative '../relationship'
5
6
 
6
7
  module Mastodon
7
8
  module REST
@@ -24,8 +25,15 @@ module Mastodon
24
25
  # the user's avatar
25
26
  # @option options header [String] A base64 encoded image to display as
26
27
  # the user's header image
28
+ # @option options bot [Boolean] A boolean indicating if this account
29
+ # is automated
30
+
27
31
  # @return [Mastodon::Account]
28
32
  def update_credentials(opts = {})
33
+ opts[:fields] and opts.delete(:fields).each_with_index { |f, i|
34
+ opts["fields_attributes[#{i}][name]"] = f[:name]
35
+ opts["fields_attributes[#{i}][value]"] = f[:value]
36
+ }
29
37
  perform_request_with_object(:patch,
30
38
  '/api/v1/accounts/update_credentials',
31
39
  opts, Mastodon::Account)
@@ -66,6 +74,76 @@ module Mastodon
66
74
  '/api/v1/follows', { uri: uri },
67
75
  Mastodon::Account)
68
76
  end
77
+
78
+
79
+ # Get account endorsements
80
+ # @return [Mastodon::Collection<Mastodon::Account>]
81
+ def endorsements
82
+ perform_request_with_collection(:get, '/api/v1/endorsements',
83
+ {}, Mastodon::Account)
84
+ end
85
+
86
+ # Add an endorsement
87
+ # @param id [Integer]
88
+ # @return [Mastodon::Relationship]
89
+ def add_endorsement(id)
90
+ perform_request_with_object(:post, "/api/v1/accounts/#{id}/pin",
91
+ {}, Mastodon::Relationship)
92
+ end
93
+
94
+ # Remove an endorsement
95
+ # @param id [Integer]
96
+ # @return [Mastodon::Relationship]
97
+ def remove_endorsement(id)
98
+ perform_request_with_object(:post, "/api/v1/accounts/#{id}/unpin",
99
+ {}, Mastodon::Relationship)
100
+ end
101
+ # Get user mutes
102
+ # @return [Mastodon::Collection<Mastodon::Account>]
103
+ def mutes
104
+ perform_request_with_collection(:get, '/api/v1/mutes',
105
+ {}, Mastodon::Account)
106
+ end
107
+
108
+ # Get user blocks
109
+ # @param options [Hash]
110
+ # @option options :limit [Integer]
111
+ # @return [Mastodon::Collection<Mastodon::Account>]
112
+ def blocks(options = {})
113
+ perform_request_with_collection(:get, '/api/v1/blocks',
114
+ options, Mastodon::Account)
115
+ end
116
+ # Report an account
117
+ # @param id [Integer]
118
+ # @param options [Hash]
119
+ # @option options :status_ids [Array<Integer>]
120
+ # @option options :comment [String]
121
+ def report(id, options = {})
122
+ options[:account_id] = id
123
+ !perform_request(:post, '/api/v1/reports', options).nil?
124
+ end
125
+ # Gets follow requests
126
+ # @param options [Hash]
127
+ # @option options :limit [Integer]
128
+ # @return [Mastodon::Collection<Mastodon::Account>]
129
+ def follow_requests(options = {})
130
+ perform_request_with_collection(:get, '/api/v1/follow_requests',
131
+ options, Mastodon::Account)
132
+ end
133
+
134
+ # Accept a follow request
135
+ # @param id [Integer]
136
+ # @return [Boolean]
137
+ def accept_follow_request(id)
138
+ !perform_request(:post, "/api/v1/follow_requests/#{id}/authorize").nil?
139
+ end
140
+
141
+ # Reject follow request
142
+ # @param id [Integer]
143
+ # @return [Boolean]
144
+ def reject_follow_request(id)
145
+ !perform_request(:post, "/api/v1/follow_requests/#{id}/reject").nil?
146
+ end
69
147
  end
70
148
  end
71
149
  end
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/statuses'
4
- require 'mastodon/rest/accounts'
5
- require 'mastodon/rest/timelines'
6
- require 'mastodon/rest/notifications'
7
- require 'mastodon/rest/search'
8
- require 'mastodon/rest/relationships'
9
- require 'mastodon/rest/media'
10
- require 'mastodon/rest/suggestions'
11
- require 'mastodon/rest/apps'
12
- require 'mastodon/rest/instances'
3
+ require_relative 'statuses'
4
+ require_relative 'accounts'
5
+ require_relative 'timelines'
6
+ require_relative 'notifications'
7
+ require_relative 'search'
8
+ require_relative 'relationships'
9
+ require_relative 'media'
10
+ require_relative 'suggestions'
11
+ require_relative 'apps'
12
+ require_relative 'instances'
13
+ require_relative 'lists'
14
+ require_relative 'filters'
13
15
 
14
16
  module Mastodon
15
17
  module REST
@@ -24,6 +26,8 @@ module Mastodon
24
26
  include Mastodon::REST::Suggestions
25
27
  include Mastodon::REST::Apps
26
28
  include Mastodon::REST::Instances
29
+ include Mastodon::REST::Lists
30
+ include Mastodon::REST::Filters
27
31
  end
28
32
  end
29
33
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/app'
3
+ require_relative '../rest/utils'
4
+ require_relative '../app'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/client'
4
- require 'mastodon/rest/api'
3
+ require_relative '../client'
4
+ require_relative 'api'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'utils'
4
+ require_relative '../filter'
5
+
6
+ module Mastodon
7
+ module REST
8
+ module Filters
9
+ include Mastodon::REST::Utils
10
+
11
+ # Create a new filter
12
+ # @param options [Hash]
13
+ # @option options :phrase [String]
14
+ # @option options :context [Array<String>]
15
+ # @option options :irreversible [Boolean]
16
+ # @option options :whole_word [Boolean]
17
+ # @option options :expires_in [Integer]
18
+ # @returns [Mastodon::Filter]
19
+ def create_filter(options = {})
20
+ context = options.delete(:context)
21
+ context = [ context ] unless context.kind_of? Array
22
+ options['context[]'] = context
23
+
24
+ perform_request_with_object(:post, '/api/v1/filters',
25
+ options, Mastodon::Filter)
26
+ end
27
+
28
+ # Gets a filter
29
+ # @param id [Integer]
30
+ # @returns [Mastodon::Filter]
31
+ def filter(id)
32
+ perform_request_with_object(:get, "/api/v1/filters/#{id}",
33
+ {}, Mastodon::Filter)
34
+ end
35
+
36
+ # Gets all filters
37
+ # @returns [Mastodon::Collection<Mastodon::Filter>]
38
+ def filters
39
+ perform_request_with_collection(:get, '/api/v1/filters',
40
+ {}, Mastodon::Filter)
41
+ end
42
+
43
+ # Update an existing filter
44
+ # @param id [Integer]
45
+ # @param options [Hash]
46
+ # @option options :phrase [String]
47
+ # @option options :context [Array<String>]
48
+ # @option options :irreversible [Boolean]
49
+ # @option options :whole_word [Boolean]
50
+ # @option options :expires_in [Integer]
51
+ # @returns [Mastodon::Filter]
52
+ def update_filter(id, options = {})
53
+ context = options.delete(:context)
54
+ context = [ context ] unless context.kind_of? Array
55
+ options['context[]'] = context
56
+
57
+ perform_request_with_object(:put, "/api/v1/filters/#{id}",
58
+ options, Mastodon::Filter)
59
+ end
60
+
61
+ # Delete a filter
62
+ # @param id [Integer]
63
+ # @returns [Mastodon::Filter]
64
+ def delete_filter(id)
65
+ !perform_request(:delete, "/api/v1/filters/#{id}").nil?
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/instance'
3
+ require_relative '../rest/utils'
4
+ require_relative '../instance'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -14,6 +14,31 @@ module Mastodon
14
14
  perform_request_with_object(:get, '/api/v1/instance', {},
15
15
  Mastodon::Instance)
16
16
  end
17
+
18
+ # Get user domain blocks
19
+ # @param options [Hash]
20
+ # @option options :limit [Integer]
21
+ # @return [Mastodon::Collection<String>]
22
+ def domain_blocks(options = {})
23
+ perform_request_with_collection(:get, '/api/v1/domain_blocks',
24
+ options, String)
25
+ end
26
+
27
+ # Block a domain
28
+ # @param domain [String]
29
+ # @return [Boolean]
30
+ def block_domain(domain)
31
+ !perform_request(:post, '/api/v1/domain_blocks',
32
+ { domain: domain }).nil?
33
+ end
34
+
35
+ # Unblock a domain
36
+ # @param domain [String]
37
+ # @return [Boolean]
38
+ def unblock_domain(domain)
39
+ !perform_request(:delete, '/api/v1/domain_blocks',
40
+ { domain: domain }).nil?
41
+ end
17
42
  end
18
43
  end
19
44
  end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'utils'
4
+ require_relative '../list'
5
+
6
+ module Mastodon
7
+ module REST
8
+ module Lists
9
+ include Mastodon::REST::Utils
10
+
11
+ # Retrieve list
12
+ # @param id [Integer]
13
+ # @return [Mastodon::List]
14
+ def list(id)
15
+ perform_request_with_object(:get, "/api/v1/lists/#{id}",
16
+ {}, Mastodon::List)
17
+ end
18
+
19
+ # Retrieve all lists
20
+ # @param id [Integer]
21
+ # @return [Mastodon::Collections<Mastodon::List>]
22
+ def lists
23
+ perform_request_with_collection(:get, '/api/v1/lists',
24
+ {}, Mastodon::List)
25
+ end
26
+
27
+ # Create a new list
28
+ # @param title [String]
29
+ # @return [Mastodon::List]
30
+ def create_list(title)
31
+ options = { title: title }
32
+ perform_request_with_object(:post, '/api/v1/lists',
33
+ options, Mastodon::List)
34
+ end
35
+
36
+ # Update a list
37
+ # @param id [Integer]
38
+ # @param options [Hash]
39
+ # @option options :title [String]
40
+ # @return [Mastodon::List]
41
+ def update_list(id, options = {})
42
+ perform_request_with_object(:put, "/api/v1/lists/#{id}",
43
+ options, Mastodon::List)
44
+ end
45
+
46
+ # Gets the accounts that are in a list
47
+ # @param id [Integer]
48
+ # @param options [Hash]
49
+ # @option options :limit [Integer]
50
+ # @return [Mastodon::Collection<Mastodon::Account>]
51
+ def list_accounts(id, options = {})
52
+ perform_request_with_collection(:get, "/api/v1/lists/#{id}/accounts",
53
+ options, Mastodon::List)
54
+ end
55
+
56
+ # Gets the lists this account is a part of
57
+ # @param id [Integer]
58
+ # @return [Mastodon::Collection<Mastodon::List>]
59
+ def account_lists(id)
60
+ perform_request_with_collection(:get, "/api/v1/accounts/#{id}/lists",
61
+ {}, Mastodon::List)
62
+ end
63
+
64
+ # Delete a list
65
+ # @param id [Integer]
66
+ # @return [Boolean]
67
+ def delete_list(id)
68
+ !perform_request(:delete, "/api/v1/lists/#{id}").nil?
69
+ end
70
+
71
+ # Add accounts to a list
72
+ # @param id [Integer]
73
+ # @param accounts [Array<Integer>]
74
+ def list_add_accounts(id, *accounts)
75
+ options = {}
76
+ options['account_ids[]'] = accounts
77
+ perform_request(:post, "/api/v1/lists/#{id}/accounts",
78
+ options)
79
+ end
80
+
81
+ # Add accounts to a list
82
+ # @param id [Integer]
83
+ # @param accounts [Array<Integer>]
84
+ def list_remove_accounts(id, *accounts)
85
+ options = {}
86
+ options['account_ids[]'] = accounts
87
+ perform_request(:delete, "/api/v1/lists/#{id}/accounts",
88
+ options)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/media'
3
+ require_relative '../rest/utils'
4
+ require_relative '../media'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -13,8 +13,10 @@ module Mastodon
13
13
  # upload. Will be converted to HTTP::FormData::File before upload
14
14
  # @param description [String] A text description of the image, to be
15
15
  # along with the image.
16
+ # @param focus [Array] Array of floats that set the focal point of
17
+ # the image
16
18
  # @return [Mastodon::Media]
17
- def upload_media(file, description = nil)
19
+ def upload_media(file, description = nil, *focus)
18
20
  file = if file.is_a?(HTTP::FormData::File)
19
21
  file
20
22
  else
@@ -22,6 +24,7 @@ module Mastodon
22
24
  end
23
25
  payload = { file: file }
24
26
  payload[:description] = description unless description.nil?
27
+ payload[:focus] = focus.collect{|f| f.to_s}.join(',') unless focus.nil?
25
28
  perform_request_with_object(:post, '/api/v1/media', payload,
26
29
  Mastodon::Media)
27
30
  end
@@ -37,6 +40,18 @@ module Mastodon
37
40
  { description: description },
38
41
  Mastodon::Media)
39
42
  end
43
+
44
+ # Update a media focal point, can only be updated while it's not
45
+ # associated to a status
46
+ # @param media_id [Integer] Id of the media, returned by upload_media
47
+ # @param focal_x [Float] X position of the focus
48
+ # @param focal_y [Float] Y position of the focus
49
+ # @return [Mastodon::Media]
50
+ def update_media_focus(media_id, focus_x, focus_y)
51
+ perform_request_with_object(:put, "/api/v1/media/#{media_id}",
52
+ { focus: "#{focus_x},#{focus_y}" },
53
+ Mastodon::Media)
54
+ end
40
55
  end
41
56
  end
42
57
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/notification'
3
+ require_relative '../rest/utils'
4
+ require_relative '../notification'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/relationship'
3
+ require_relative '../rest/utils'
4
+ require_relative '../relationship'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -3,8 +3,8 @@
3
3
  require 'addressable/uri'
4
4
  require 'http'
5
5
  require 'oj'
6
- require 'mastodon/error'
7
- require 'mastodon/headers'
6
+ require_relative '../error'
7
+ require_relative '../headers'
8
8
 
9
9
  module Mastodon
10
10
  module REST
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/status'
3
+ require_relative '../rest/utils'
4
+ require_relative '../status'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/status'
3
+ require_relative 'utils'
4
+ require_relative '../status'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -112,6 +112,26 @@ module Mastodon
112
112
  perform_request_with_collection(:get, url, options, Mastodon::Status)
113
113
  end
114
114
 
115
+ # Mute thread
116
+ # @param id [Integer]
117
+ # @return [Mastodon::Status]
118
+ def mute_thread(id)
119
+ perform_request_with_object(:post,
120
+ "/api/v1/statuses/#{id}/mute",
121
+ {},
122
+ Mastodon::Status)
123
+ end
124
+
125
+ # Unmute thread
126
+ # @param id [Integer]
127
+ # @return [Mastodon::Status]
128
+ def unmute_thread(id)
129
+ perform_request_with_object(:post,
130
+ "/api/v1/statuses/#{id}/unmute",
131
+ {},
132
+ Mastodon::Status)
133
+ end
134
+
115
135
  private
116
136
 
117
137
  def normalize_status_params(*args)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/account'
3
+ require_relative '../rest/utils'
4
+ require_relative '../account'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -14,6 +14,14 @@ module Mastodon
14
14
  perform_request_with_collection(:get, '/api/v1/accounts/suggestions',
15
15
  {}, Mastodon::Account)
16
16
  end
17
+
18
+ # Remove account from suggestions
19
+ # @param id [Integer]
20
+ # @return [Boolean]
21
+ def remove_suggestion(id)
22
+ !perform_request(:delete,
23
+ "/api/v1/suggestions/#{id}").nil?
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/utils'
4
- require 'mastodon/status'
3
+ require_relative '../rest/utils'
4
+ require_relative '../status'
5
5
 
6
6
  module Mastodon
7
7
  module REST
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/rest/request'
3
+ require_relative 'request'
4
4
 
5
5
  module Mastodon
6
6
  module REST
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/account'
4
- require 'mastodon/status'
3
+ require_relative 'account'
4
+ require_relative 'status'
5
5
 
6
6
  module Mastodon
7
7
  class Results < Mastodon::Base
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/account'
4
- require 'mastodon/entities/media'
5
- require 'mastodon/entities/mention'
6
- require 'mastodon/entities/app'
7
- require 'mastodon/entities/hashtag'
8
- require 'mastodon/emoji'
3
+ require_relative 'account'
4
+ require_relative 'entities/media'
5
+ require_relative 'entities/mention'
6
+ require_relative 'entities/app'
7
+ require_relative 'entities/hashtag'
8
+ require_relative 'emoji'
9
+ require_relative 'card'
9
10
 
10
11
  module Mastodon
11
12
  class Status < Mastodon::Base
@@ -80,6 +81,7 @@ module Mastodon
80
81
  object_attr_reader :account, Mastodon::Account
81
82
  object_attr_reader :reblog, Mastodon::Status
82
83
  object_attr_reader :application, Mastodon::Entities::App
84
+ object_attr_reader :card, Mastodon::Card
83
85
 
84
86
  collection_attr_reader :media_attachments, Mastodon::Entities::Media
85
87
  collection_attr_reader :mentions, Mastodon::Entities::Mention
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'http/request'
4
- require 'mastodon/client'
5
- require 'mastodon/streaming/connection'
6
- require 'mastodon/streaming/deleted_status'
7
- require 'mastodon/streaming/message_parser'
8
- require 'mastodon/streaming/response'
4
+ require_relative '../client'
5
+ require_relative '../streaming/connection'
6
+ require_relative '../streaming/deleted_status'
7
+ require_relative '../streaming/message_parser'
8
+ require_relative '../streaming/response'
9
9
 
10
10
  module Mastodon
11
11
  module Streaming
@@ -35,6 +35,14 @@ module Mastodon
35
35
  stream('user', options, &block)
36
36
  end
37
37
 
38
+ # Streams posts from the local instance
39
+ #
40
+ # @yield [Mastodon::Status, Mastodon::Notification,
41
+ # Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
42
+ def local(options = {}, &block)
43
+ stream('public/local', options, &block)
44
+ end
45
+
38
46
  # Returns statuses that contain the specified hashtag
39
47
  #
40
48
  # @yield [Mastodon::Status, Mastodon::Notification,
@@ -44,6 +52,32 @@ module Mastodon
44
52
  stream('hashtag', options, &block)
45
53
  end
46
54
 
55
+ # Returns local statuses that contain the specified hashtag
56
+ #
57
+ # @yield [Mastodon::Status, Mastodon::Notification,
58
+ # Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
59
+ def local_hashtag(tag, options = {}, &block)
60
+ options['tag'] = tag
61
+ stream('hashtag/local', options, &block)
62
+ end
63
+
64
+ # Returns statuses from the specified list
65
+ #
66
+ # @yield [Mastodon::Status, Mastodon::Notification,
67
+ # Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
68
+ def list(id, options = {}, &block)
69
+ options['list'] = id
70
+ stream('list', options, &block)
71
+ end
72
+
73
+ # Returns direct messages for the authenticated user
74
+ #
75
+ # @yield [Mastodon::Status, Mastodon::Notification,
76
+ # Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
77
+ def direct(options = {}, &block)
78
+ stream('direct', options, &block)
79
+ end
80
+
47
81
  # Returns all public statuses
48
82
  #
49
83
  # @yield [Mastodon::Status, Mastodon::Notification,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mastodon/status'
4
- require 'mastodon/streaming/deleted_status'
3
+ require_relative '../status'
4
+ require_relative '../streaming/deleted_status'
5
5
 
6
6
  module Mastodon
7
7
  module Streaming
@@ -3,7 +3,7 @@
3
3
  require 'buftok'
4
4
  require 'http'
5
5
  require 'json'
6
- require 'mastodon/error'
6
+ require_relative '../error'
7
7
 
8
8
  module Mastodon
9
9
  module Streaming
@@ -10,7 +10,7 @@ module Mastodon
10
10
  end
11
11
 
12
12
  def minor
13
- 2
13
+ 4
14
14
  end
15
15
 
16
16
  def patch
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable/uri'
4
- require 'mastodon/base'
5
- require 'mastodon/collection'
6
- require 'mastodon/results'
7
- require 'mastodon/rest/client'
8
- require 'mastodon/streaming/client'
4
+ require_relative 'mastodon/base'
5
+ require_relative 'mastodon/collection'
6
+ require_relative 'mastodon/results'
7
+ require_relative 'mastodon/rest/client'
8
+ require_relative 'mastodon/streaming/client'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moostodon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxine Michalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -98,6 +98,8 @@ files:
98
98
  - lib/mastodon/entities/media.rb
99
99
  - lib/mastodon/entities/mention.rb
100
100
  - lib/mastodon/error.rb
101
+ - lib/mastodon/field.rb
102
+ - lib/mastodon/filter.rb
101
103
  - lib/mastodon/headers.rb
102
104
  - lib/mastodon/instance.rb
103
105
  - lib/mastodon/list.rb
@@ -108,7 +110,9 @@ files:
108
110
  - lib/mastodon/rest/api.rb
109
111
  - lib/mastodon/rest/apps.rb
110
112
  - lib/mastodon/rest/client.rb
113
+ - lib/mastodon/rest/filters.rb
111
114
  - lib/mastodon/rest/instances.rb
115
+ - lib/mastodon/rest/lists.rb
112
116
  - lib/mastodon/rest/media.rb
113
117
  - lib/mastodon/rest/notifications.rb
114
118
  - lib/mastodon/rest/relationships.rb
@@ -148,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
152
  version: '0'
149
153
  requirements: []
150
154
  rubyforge_project:
151
- rubygems_version: 2.5.2.1
155
+ rubygems_version: 2.7.7
152
156
  signing_key:
153
157
  specification_version: 4
154
158
  summary: A ruby interface to the Mastodon API, based on mastodon-api.