avm-reddit_base0 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/avm/reddit_base0/api/access_token.rb +39 -0
- data/lib/avm/reddit_base0/api/entity.rb +27 -0
- data/lib/avm/reddit_base0/api/me.rb +26 -0
- data/lib/avm/reddit_base0/api/root.rb +24 -0
- data/lib/avm/reddit_base0/api/sub.rb +36 -0
- data/lib/avm/reddit_base0/api/wiki.rb +36 -0
- data/lib/avm/reddit_base0/api.rb +23 -0
- data/lib/avm/reddit_base0/automoderator/age_gender_regex.rb +35 -0
- data/lib/avm/reddit_base0/automoderator/regex.rb +40 -0
- data/lib/avm/reddit_base0/automoderator/year_gender_regex.rb +25 -0
- data/lib/avm/reddit_base0/instances/base.rb +38 -0
- data/lib/avm/reddit_base0/instances.rb +11 -0
- data/lib/avm/reddit_base0/manager.rb +28 -0
- data/lib/avm/reddit_base0/runners/base/generic.rb +33 -0
- data/lib/avm/reddit_base0/runners/base/me/identity.rb +26 -0
- data/lib/avm/reddit_base0/runners/base/me.rb +19 -0
- data/lib/avm/reddit_base0/runners/base/sub/about.rb +26 -0
- data/lib/avm/reddit_base0/runners/base/sub/wiki/read.rb +27 -0
- data/lib/avm/reddit_base0/runners/base/sub/wiki/write.rb +23 -0
- data/lib/avm/reddit_base0/runners/base/sub/wiki.rb +29 -0
- data/lib/avm/reddit_base0/runners/base/sub/wikis.rb +29 -0
- data/lib/avm/reddit_base0/runners/base/sub.rb +27 -0
- data/lib/avm/reddit_base0/runners/base.rb +25 -0
- data/lib/avm/reddit_base0/runners.rb +11 -0
- data/lib/avm/reddit_base0/sources/base.rb +14 -0
- data/lib/avm/reddit_base0/sources/download/download_wiki.rb +39 -0
- data/lib/avm/reddit_base0/sources/download.rb +41 -0
- data/lib/avm/reddit_base0/sources/runners/download.rb +35 -0
- data/lib/avm/reddit_base0/sources/runners.rb +13 -0
- data/lib/avm/reddit_base0/sources.rb +11 -0
- data/lib/avm/reddit_base0/version.rb +7 -0
- data/lib/avm/reddit_base0.rb +9 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 767b77844b069adbb7b1f108351fd2d8da02392fce1048981be07674a058ce44
|
4
|
+
data.tar.gz: 75cf45b8aaac6a87fce17a64e99e10fbc9415742941524990fb6b8d3df8986e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b5529004e039324921b007673a74a6435443ac407dbd743262e8955e46a23c57228087c314988a547e37bb55ffca662456cc16eb70b30a6fc3bfd13ac25155e
|
7
|
+
data.tar.gz: 73f42ae92d183c82adfb12538928dbd184443bfeb9dd0059bfc02307ac67250cef3bd25f56f2416a788a4a69409fed16abf5ea890937226bc0cac3491410c84b
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rest/api'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_envs/http/request'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
class Api < ::EacRest::Api
|
10
|
+
class AccessToken
|
11
|
+
acts_as_instance_method
|
12
|
+
common_constructor :api
|
13
|
+
|
14
|
+
URL = 'https://www.reddit.com/api/v1/access_token'
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def fresh_result
|
18
|
+
http_request.response.body_data_or_raise.fetch('access_token')
|
19
|
+
end
|
20
|
+
|
21
|
+
def fs_object_id
|
22
|
+
[api.username, api.user_username]
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def result
|
27
|
+
fs_cache.read_or_store { fresh_result }
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [EacEnvs::Http::Request]
|
31
|
+
def http_request
|
32
|
+
::EacEnvs::Http::Request.new.url(URL).verb(:post).body_data(
|
33
|
+
grant_type: 'password', username: api.user_username, password: api.user_password
|
34
|
+
).basic_auth(api.client_id, api.secret)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rest/api'
|
4
|
+
require 'eac_rest/entity'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
class Api < ::EacRest::Api
|
10
|
+
class Entity < ::EacRest::Entity
|
11
|
+
# @param url_suffix [Addressable::URI, nil]
|
12
|
+
# @return [Object]
|
13
|
+
def request_data(url_suffix = nil)
|
14
|
+
request(url_suffix).response.body_data_or_raise
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param child_class [Class]
|
18
|
+
# @param url_suffix [Addressable::URI, nil]
|
19
|
+
# @return [Array]
|
20
|
+
def request_children(child_class, url_suffix = nil)
|
21
|
+
request_data(url_suffix).fetch('data')
|
22
|
+
.map { |child_data| child_entity(child_class, child_data) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/api/entity'
|
4
|
+
require 'eac_rest/api'
|
5
|
+
require 'eac_rest/entity'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module RedditBase0
|
10
|
+
class Api < ::EacRest::Api
|
11
|
+
class Me < ::Avm::RedditBase0::Api::Entity
|
12
|
+
ENTITY_ROOT_URL_SUFFIX = '/api/v1/me'
|
13
|
+
|
14
|
+
# @return [Hash]
|
15
|
+
def identity
|
16
|
+
request_data
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Addressable::URI]
|
20
|
+
def entity_root_url_suffix
|
21
|
+
ENTITY_ROOT_URL_SUFFIX.to_uri
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/api/entity'
|
4
|
+
require 'eac_rest/api'
|
5
|
+
require 'eac_rest/entity'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module RedditBase0
|
10
|
+
class Api < ::EacRest::Api
|
11
|
+
class Root < ::Avm::RedditBase0::Api::Entity
|
12
|
+
# @return [Avm::RedditBase0::Api::Me]
|
13
|
+
def me
|
14
|
+
api.entity(::Avm::RedditBase0::Api::Me, nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Avm::RedditBase0::Api::Sub]
|
18
|
+
def sub(name)
|
19
|
+
api.entity(::Avm::RedditBase0::Api::Sub, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/api/entity'
|
4
|
+
require 'avm/reddit_base0/api/wiki'
|
5
|
+
require 'eac_rest/api'
|
6
|
+
require 'eac_rest/entity'
|
7
|
+
require 'eac_ruby_utils/core_ext'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module RedditBase0
|
11
|
+
class Api < ::EacRest::Api
|
12
|
+
class Sub < ::Avm::RedditBase0::Api::Entity
|
13
|
+
# @return [Hash]
|
14
|
+
def about
|
15
|
+
request_data('/about').fetch('data')
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Addressable::URI]
|
19
|
+
def entity_root_url_suffix
|
20
|
+
"#{super}/r/#{id}".to_uri
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param wiki_id [String]
|
24
|
+
# @return [::Avm::RedditBase0::Api::Wiki]
|
25
|
+
def wiki(wiki_id)
|
26
|
+
child_entity(::Avm::RedditBase0::Api::Wiki, wiki_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Array<Avm::RedditBase0::Api::Wiki>]
|
30
|
+
def wikis
|
31
|
+
request_children(::Avm::RedditBase0::Api::Wiki, '/wiki/pages')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/api/entity'
|
4
|
+
require 'eac_rest/api'
|
5
|
+
require 'eac_rest/entity'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module RedditBase0
|
10
|
+
class Api < ::EacRest::Api
|
11
|
+
class Wiki < ::Avm::RedditBase0::Api::Entity
|
12
|
+
# @return [Addressable::URI]
|
13
|
+
def entity_root_url_suffix
|
14
|
+
"#{super}/wiki/#{id}".to_uri
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def read
|
19
|
+
request_data.fetch('data').fetch('content_md')
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Pathname]
|
23
|
+
def subpath
|
24
|
+
id.to_pathname
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param content [String]
|
28
|
+
# @return [Hash]
|
29
|
+
def write(content)
|
30
|
+
parent_entity.request('/api/wiki/edit').verb(:post).body_data(page: id, content: content)
|
31
|
+
.response.body_data_or_raise
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rest/api'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module RedditBase0
|
8
|
+
class Api < ::EacRest::Api
|
9
|
+
ROOT_URL = 'https://oauth.reddit.com'
|
10
|
+
|
11
|
+
common_constructor :client_id, :secret, :user_username, :user_password,
|
12
|
+
super_args: -> { [ROOT_URL] }
|
13
|
+
|
14
|
+
# @return [EacRest::Request]
|
15
|
+
def request(service_url_suffix, headers = {}, &body_data_proc)
|
16
|
+
super(service_url_suffix, headers, &body_data_proc)
|
17
|
+
.header('Authorization', "Bearer #{access_token}")
|
18
|
+
end
|
19
|
+
|
20
|
+
require_sub __FILE__
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/automoderator/regex'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module RedditBase0
|
8
|
+
module Automoderator
|
9
|
+
class AgeGenderRegex
|
10
|
+
common_constructor :age_pattern
|
11
|
+
|
12
|
+
AFTER_PATTERN = '\\)\\s*\\S+.*'
|
13
|
+
BEFORE_PATTERN = '\\s*\\('
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
def after_pattern
|
17
|
+
AFTER_PATTERN
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def before_pattern
|
22
|
+
BEFORE_PATTERN
|
23
|
+
end
|
24
|
+
|
25
|
+
def match?(string)
|
26
|
+
::Avm::RedditBase0::Automoderator::Regex.new(pattern).match?(string)
|
27
|
+
end
|
28
|
+
|
29
|
+
def pattern
|
30
|
+
"^#{before_pattern}(?:#{age_pattern})[HMhm]?#{after_pattern}$"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_rest/api'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/envs'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
module Automoderator
|
10
|
+
class Regex
|
11
|
+
common_constructor :pattern
|
12
|
+
|
13
|
+
def match?(string)
|
14
|
+
python_command(string).system
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# @return [Array<String>]
|
20
|
+
def python_args(string)
|
21
|
+
['-c', python_code(string)]
|
22
|
+
end
|
23
|
+
|
24
|
+
def python_command(string)
|
25
|
+
::EacRubyUtils::Envs.local.executable('python3', '--version')
|
26
|
+
.command(*python_args(string))
|
27
|
+
end
|
28
|
+
|
29
|
+
def python_code(string)
|
30
|
+
<<~CODE
|
31
|
+
import re
|
32
|
+
pattern = re.compile('#{pattern}')
|
33
|
+
if not pattern.match('#{string}'):
|
34
|
+
exit(1)
|
35
|
+
CODE
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/automoderator/age_gender_regex'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module RedditBase0
|
8
|
+
module Automoderator
|
9
|
+
class YearGenderRegex < ::Avm::RedditBase0::Automoderator::AgeGenderRegex
|
10
|
+
AFTER_PATTERN = ''
|
11
|
+
BEFORE_PATTERN = ''
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
def after_pattern
|
15
|
+
AFTER_PATTERN
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
def before_pattern
|
20
|
+
BEFORE_PATTERN
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_generic_base0/instances/base'
|
4
|
+
require 'avm/reddit_base0/api'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
module Instances
|
10
|
+
class Base < ::Avm::EacGenericBase0::Instances::Base
|
11
|
+
uri_components_entries_values 'install', %w[client_id secret sub_name]
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
def auto_install_sub_name
|
15
|
+
suffix
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
def sub_name
|
20
|
+
install_sub_name
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
# @return [Avm::RedditBase0::Api]
|
26
|
+
def api_uncached
|
27
|
+
::Avm::RedditBase0::Api.new(install_client_id, install_secret, install_username,
|
28
|
+
install_password)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Avm::RedditBase0::Api::Sub]
|
32
|
+
def sub_uncached
|
33
|
+
api.root_entity.sub(sub_name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/api'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module RedditBase0
|
8
|
+
class Manager
|
9
|
+
include ::Singleton
|
10
|
+
|
11
|
+
# @param field [String]
|
12
|
+
# @return [String]
|
13
|
+
def envvar_name(field)
|
14
|
+
['reddit', field].map(&:underscore).join('_').upcase
|
15
|
+
end
|
16
|
+
|
17
|
+
%w[client_id username password secret].each do |field|
|
18
|
+
define_method field.to_s do
|
19
|
+
::ENV.fetch(envvar_name(field))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def api
|
24
|
+
::Avm::RedditBase0::Api.new(client_id, secret, username, password)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Generic
|
10
|
+
runner_with :help, :output_item do
|
11
|
+
pos_arg :url_suffix
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
infov 'URL suffix', parsed.url_suffix
|
16
|
+
infov 'URL', request.url
|
17
|
+
run_output
|
18
|
+
end
|
19
|
+
|
20
|
+
def item_hash
|
21
|
+
request.response.body_data_or_raise
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def request_uncached
|
27
|
+
api.request(parsed.url_suffix)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Me
|
10
|
+
class Identity
|
11
|
+
runner_with :help, :output_item
|
12
|
+
|
13
|
+
def run
|
14
|
+
run_output
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Hash]
|
18
|
+
def item_hash
|
19
|
+
api.root_entity.me.identity
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Me
|
10
|
+
runner_with :help, :subcommands do
|
11
|
+
subcommands
|
12
|
+
end
|
13
|
+
|
14
|
+
require_sub __FILE__
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
class About
|
11
|
+
runner_with :help, :output_item
|
12
|
+
|
13
|
+
def run
|
14
|
+
run_output
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Hash]
|
18
|
+
def item_hash
|
19
|
+
sub.about
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
class Wiki
|
11
|
+
class Read
|
12
|
+
runner_with :help, :output
|
13
|
+
|
14
|
+
def run
|
15
|
+
run_output
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_content
|
19
|
+
wiki.read
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
class Wiki
|
11
|
+
class Write
|
12
|
+
runner_with :help, :input
|
13
|
+
|
14
|
+
def run
|
15
|
+
infov 'Result', wiki.write(input_content).pretty_inspect
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
class Wiki
|
11
|
+
runner_with :help, :subcommands do
|
12
|
+
pos_arg :wiki_id
|
13
|
+
subcommands
|
14
|
+
end
|
15
|
+
for_context :wiki
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def wiki_uncached
|
20
|
+
sub.wiki(parsed.wiki_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
require_sub __FILE__
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
class Wikis
|
11
|
+
runner_with :help, :output_list
|
12
|
+
|
13
|
+
def run
|
14
|
+
run_output
|
15
|
+
end
|
16
|
+
|
17
|
+
def list_columns
|
18
|
+
[:id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def list_rows
|
22
|
+
sub.wikis
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Runners
|
8
|
+
class Base < ::Avm::Runners::Base
|
9
|
+
class Sub
|
10
|
+
runner_with :help, :subcommands do
|
11
|
+
pos_arg :sub_name
|
12
|
+
subcommands
|
13
|
+
end
|
14
|
+
for_context :sub
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def sub_uncached
|
19
|
+
api.root_entity.sub(parsed.sub_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
require_sub __FILE__
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/manager'
|
4
|
+
require 'eac_cli/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module RedditBase0
|
8
|
+
module Runners
|
9
|
+
class Base < ::Avm::Runners::Base
|
10
|
+
runner_with :help, :subcommands do
|
11
|
+
subcommands
|
12
|
+
end
|
13
|
+
for_context :api
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def api_uncached
|
18
|
+
::Avm::RedditBase0::Manager.instance.api
|
19
|
+
end
|
20
|
+
|
21
|
+
require_sub __FILE__
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_generic_base0/sources/base'
|
4
|
+
require 'avm/reddit_base0/sources/runners'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
module Sources
|
10
|
+
class Base < ::Avm::EacGenericBase0::Sources::Base
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module RedditBase0
|
7
|
+
module Sources
|
8
|
+
class Download
|
9
|
+
class DownloadWiki
|
10
|
+
acts_as_instance_method
|
11
|
+
common_constructor :download, :wiki
|
12
|
+
delegate :source, to: :download
|
13
|
+
|
14
|
+
DEFAULT_EXTENSION = '.md'
|
15
|
+
AUTOMODERATOR_EXTENSION = '.yml'
|
16
|
+
AUTOMODERATOR_SUBPATH = 'config/automoderator'
|
17
|
+
|
18
|
+
def result
|
19
|
+
target_path.assert_parent.write(wiki.read)
|
20
|
+
end
|
21
|
+
|
22
|
+
def target_path
|
23
|
+
source.path.join('wiki').join(wiki.subpath)
|
24
|
+
.basename_sub { |b| "#{b}#{target_extension}" }
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
def target_extension
|
29
|
+
if wiki.subpath.to_pathname == AUTOMODERATOR_SUBPATH.to_pathname
|
30
|
+
AUTOMODERATOR_EXTENSION
|
31
|
+
else
|
32
|
+
DEFAULT_EXTENSION
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_generic_base0/sources/base'
|
4
|
+
require 'avm/reddit_base0/sources/runners'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
module Sources
|
10
|
+
class Download
|
11
|
+
common_constructor :source, :instance
|
12
|
+
|
13
|
+
def perform
|
14
|
+
source.scm.commit_if_change(commit_message) do
|
15
|
+
internal_perform
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def commit_message
|
23
|
+
source.i18n_translate(:download_commit_message, sub_name: instance.sub_name,
|
24
|
+
date_time: ::DateTime.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
def download_wikis
|
28
|
+
instance.sub.wikis.each do |wiki|
|
29
|
+
download_wiki(wiki)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def internal_perform
|
34
|
+
download_wikis
|
35
|
+
end
|
36
|
+
|
37
|
+
require_sub __FILE__, require_mode: :kernel
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/reddit_base0/sources/download'
|
4
|
+
require 'avm/registry'
|
5
|
+
require 'eac_cli/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module RedditBase0
|
9
|
+
module Sources
|
10
|
+
module Runners
|
11
|
+
class Download
|
12
|
+
runner_with :help do
|
13
|
+
pos_arg :instance_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
runner_context.call(:source_banner)
|
18
|
+
infov 'Instance', instance
|
19
|
+
download.perform
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def download_uncached
|
25
|
+
::Avm::RedditBase0::Sources::Download.new(source, instance)
|
26
|
+
end
|
27
|
+
|
28
|
+
def instance_uncached
|
29
|
+
::Avm::Registry.instances.detect(parsed.instance_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: avm-reddit_base0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Put here the authors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: avm-eac_generic_base0
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: eac_rest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: eac_ruby_utils
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.119'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.119.1
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.119'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.119.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: eac_ruby_gem_support
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.6'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.6'
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- lib/avm/reddit_base0.rb
|
82
|
+
- lib/avm/reddit_base0/api.rb
|
83
|
+
- lib/avm/reddit_base0/api/access_token.rb
|
84
|
+
- lib/avm/reddit_base0/api/entity.rb
|
85
|
+
- lib/avm/reddit_base0/api/me.rb
|
86
|
+
- lib/avm/reddit_base0/api/root.rb
|
87
|
+
- lib/avm/reddit_base0/api/sub.rb
|
88
|
+
- lib/avm/reddit_base0/api/wiki.rb
|
89
|
+
- lib/avm/reddit_base0/automoderator/age_gender_regex.rb
|
90
|
+
- lib/avm/reddit_base0/automoderator/regex.rb
|
91
|
+
- lib/avm/reddit_base0/automoderator/year_gender_regex.rb
|
92
|
+
- lib/avm/reddit_base0/instances.rb
|
93
|
+
- lib/avm/reddit_base0/instances/base.rb
|
94
|
+
- lib/avm/reddit_base0/manager.rb
|
95
|
+
- lib/avm/reddit_base0/runners.rb
|
96
|
+
- lib/avm/reddit_base0/runners/base.rb
|
97
|
+
- lib/avm/reddit_base0/runners/base/generic.rb
|
98
|
+
- lib/avm/reddit_base0/runners/base/me.rb
|
99
|
+
- lib/avm/reddit_base0/runners/base/me/identity.rb
|
100
|
+
- lib/avm/reddit_base0/runners/base/sub.rb
|
101
|
+
- lib/avm/reddit_base0/runners/base/sub/about.rb
|
102
|
+
- lib/avm/reddit_base0/runners/base/sub/wiki.rb
|
103
|
+
- lib/avm/reddit_base0/runners/base/sub/wiki/read.rb
|
104
|
+
- lib/avm/reddit_base0/runners/base/sub/wiki/write.rb
|
105
|
+
- lib/avm/reddit_base0/runners/base/sub/wikis.rb
|
106
|
+
- lib/avm/reddit_base0/sources.rb
|
107
|
+
- lib/avm/reddit_base0/sources/base.rb
|
108
|
+
- lib/avm/reddit_base0/sources/download.rb
|
109
|
+
- lib/avm/reddit_base0/sources/download/download_wiki.rb
|
110
|
+
- lib/avm/reddit_base0/sources/runners.rb
|
111
|
+
- lib/avm/reddit_base0/sources/runners/download.rb
|
112
|
+
- lib/avm/reddit_base0/version.rb
|
113
|
+
homepage:
|
114
|
+
licenses: []
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.7'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubygems_version: 3.1.6
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Put here de description.
|
135
|
+
test_files: []
|