kanal-plugins-user_system 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 224bf63f0573197c1906ae9cfbd203b3bfd2c978912b1e54b3d7a6bcf69f5256
4
- data.tar.gz: 140e802ccbbdff1741797bd598e40f41a7577bd3817fc9a96402bcbf9e423f3f
3
+ metadata.gz: c1431f2eeddd6b6e97175a22f7d31063505f06fd0935a55d1c6026f3c2323552
4
+ data.tar.gz: 9ccc59bd1d3fb32ca0e2f95c20dc2a65cd14bff3738045709b190059481e2d14
5
5
  SHA512:
6
- metadata.gz: a7120a03627e13ab8e2230b6dd6e40058925882b5bdc038569546d501f2f5c39fd3da8c26f765ba4b738eb51fe6ae5951b254a409c48182c375292bfcb2fa2a3
7
- data.tar.gz: 147f98f6e3358f0f3997a62f7e61a58ade941a65879523c66f873d646690fdbdf1f3811236508f9faaa7d3b44f2e6b0261ee299f853a4f242a0906ef72298956
6
+ metadata.gz: 1969a250ca3b45ead3bfae3e4af43df035078cd4967cfc645b10c4d3823137043c5459cb3385f6c3aaaad9a07b6616070974663651b8fdf5c93b6c947c0ab33c
7
+ data.tar.gz: e1d9ae9cc89aa335b99b78c26bc6a2b02097d0071956854ce5686284ba7e88f76aa522281960f73a8495c39b9f1dfe8db741fa04bf41baafc243c62857f40bbb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2023-04-12
4
+
5
+ - Auto creation of users. Now available for telegram
6
+
3
7
  ## [0.1.0] - 2022-11-14
4
8
 
5
9
  - Initial release
data/Gemfile CHANGED
@@ -9,8 +9,6 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
- gem "kanal"
13
-
14
12
  group :development do
15
13
  gem "rubocop", "~> 1.21"
16
14
  gem "ruby-debug-ide"
@@ -19,6 +17,5 @@ group :development do
19
17
  end
20
18
 
21
19
  group :test do
22
- gem "kanal-plugins-active_record"
23
20
  gem "simplecov", require: false
24
21
  end
data/Gemfile.lock CHANGED
@@ -1,19 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kanal-plugins-user_system (0.2.1)
4
+ kanal-plugins-user_system (0.3.1)
5
5
  activerecord
6
+ kanal (= 0.5.1)
7
+ kanal-plugins-active_record (= 0.2.1)
6
8
  sqlite3
7
9
 
8
10
  GEM
9
11
  remote: https://rubygems.org/
10
12
  specs:
11
- activemodel (7.0.4.2)
12
- activesupport (= 7.0.4.2)
13
- activerecord (7.0.4.2)
14
- activemodel (= 7.0.4.2)
15
- activesupport (= 7.0.4.2)
16
- activesupport (7.0.4.2)
13
+ activemodel (7.0.4.3)
14
+ activesupport (= 7.0.4.3)
15
+ activerecord (7.0.4.3)
16
+ activemodel (= 7.0.4.3)
17
+ activesupport (= 7.0.4.3)
18
+ activesupport (7.0.4.3)
17
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
20
  i18n (>= 1.6, < 2)
19
21
  minitest (>= 5.1)
@@ -21,7 +23,7 @@ GEM
21
23
  ast (2.4.2)
22
24
  backport (1.2.0)
23
25
  benchmark (0.2.1)
24
- concurrent-ruby (1.2.0)
26
+ concurrent-ruby (1.2.2)
25
27
  diff-lcs (1.5.0)
26
28
  docile (1.4.0)
27
29
  e2mmap (0.1.0)
@@ -29,24 +31,26 @@ GEM
29
31
  concurrent-ruby (~> 1.0)
30
32
  jaro_winkler (1.5.4)
31
33
  json (2.6.3)
32
- kanal (0.3.0)
33
- kanal-plugins-active_record (0.2.0)
34
+ kanal (0.5.1)
35
+ kanal-plugins-active_record (0.2.1)
34
36
  activerecord
35
- kanal
36
37
  kramdown (2.4.0)
37
38
  rexml
38
39
  kramdown-parser-gfm (1.1.0)
39
40
  kramdown (~> 2.0)
40
- minitest (5.17.0)
41
- nokogiri (1.14.0-x86_64-darwin)
41
+ minitest (5.18.0)
42
+ nokogiri (1.14.3-x86_64-darwin)
42
43
  racc (~> 1.4)
43
- parallel (1.22.1)
44
- parser (3.2.0.0)
44
+ nokogiri (1.14.3-x86_64-linux)
45
+ racc (~> 1.4)
46
+ parallel (1.23.0)
47
+ parser (3.2.2.1)
45
48
  ast (~> 2.4.1)
46
49
  racc (1.6.2)
47
50
  rainbow (3.1.1)
48
51
  rake (13.0.6)
49
- regexp_parser (2.6.2)
52
+ rbs (2.8.4)
53
+ regexp_parser (2.8.0)
50
54
  reverse_markdown (2.1.1)
51
55
  nokogiri
52
56
  rexml (3.2.5)
@@ -54,67 +58,66 @@ GEM
54
58
  rspec-core (~> 3.12.0)
55
59
  rspec-expectations (~> 3.12.0)
56
60
  rspec-mocks (~> 3.12.0)
57
- rspec-core (3.12.0)
61
+ rspec-core (3.12.2)
58
62
  rspec-support (~> 3.12.0)
59
- rspec-expectations (3.12.2)
63
+ rspec-expectations (3.12.3)
60
64
  diff-lcs (>= 1.2.0, < 2.0)
61
65
  rspec-support (~> 3.12.0)
62
- rspec-mocks (3.12.3)
66
+ rspec-mocks (3.12.5)
63
67
  diff-lcs (>= 1.2.0, < 2.0)
64
68
  rspec-support (~> 3.12.0)
65
69
  rspec-support (3.12.0)
66
- rubocop (1.44.1)
70
+ rubocop (1.50.2)
67
71
  json (~> 2.3)
68
72
  parallel (~> 1.10)
69
73
  parser (>= 3.2.0.0)
70
74
  rainbow (>= 2.2.2, < 4.0)
71
75
  regexp_parser (>= 1.8, < 3.0)
72
76
  rexml (>= 3.2.5, < 4.0)
73
- rubocop-ast (>= 1.24.1, < 2.0)
77
+ rubocop-ast (>= 1.28.0, < 2.0)
74
78
  ruby-progressbar (~> 1.7)
75
79
  unicode-display_width (>= 2.4.0, < 3.0)
76
- rubocop-ast (1.24.1)
77
- parser (>= 3.1.1.0)
80
+ rubocop-ast (1.28.0)
81
+ parser (>= 3.2.1.0)
78
82
  ruby-debug-ide (0.7.3)
79
83
  rake (>= 0.8.1)
80
- ruby-progressbar (1.11.0)
84
+ ruby-progressbar (1.13.0)
81
85
  simplecov (0.22.0)
82
86
  docile (~> 1.1)
83
87
  simplecov-html (~> 0.11)
84
88
  simplecov_json_formatter (~> 0.1)
85
89
  simplecov-html (0.12.3)
86
90
  simplecov_json_formatter (0.1.4)
87
- solargraph (0.48.0)
91
+ solargraph (0.49.0)
88
92
  backport (~> 1.2)
89
93
  benchmark
90
- bundler (>= 1.17.2)
94
+ bundler (~> 2.0)
91
95
  diff-lcs (~> 1.4)
92
96
  e2mmap
93
97
  jaro_winkler (~> 1.5)
94
98
  kramdown (~> 2.3)
95
99
  kramdown-parser-gfm (~> 1.1)
96
100
  parser (~> 3.0)
97
- reverse_markdown (>= 1.0.5, < 3)
98
- rubocop (>= 0.52)
101
+ rbs (~> 2.0)
102
+ reverse_markdown (~> 2.0)
103
+ rubocop (~> 1.38)
99
104
  thor (~> 1.0)
100
105
  tilt (~> 2.0)
101
106
  yard (~> 0.9, >= 0.9.24)
102
- sqlite3 (1.6.0-x86_64-darwin)
107
+ sqlite3 (1.6.2-x86_64-darwin)
108
+ sqlite3 (1.6.2-x86_64-linux)
103
109
  thor (1.2.1)
104
- tilt (2.0.11)
110
+ tilt (2.1.0)
105
111
  tzinfo (2.0.6)
106
112
  concurrent-ruby (~> 1.0)
107
113
  unicode-display_width (2.4.2)
108
- webrick (1.7.0)
109
- yard (0.9.28)
110
- webrick (~> 1.7.0)
114
+ yard (0.9.34)
111
115
 
112
116
  PLATFORMS
113
- x86_64-darwin-21
117
+ x86_64-darwin-22
118
+ x86_64-linux
114
119
 
115
120
  DEPENDENCIES
116
- kanal
117
- kanal-plugins-active_record
118
121
  kanal-plugins-user_system!
119
122
  rake (~> 13.0)
120
123
  rspec (~> 3.0)
@@ -125,4 +128,4 @@ DEPENDENCIES
125
128
  yard
126
129
 
127
130
  BUNDLED WITH
128
- 2.3.19
131
+ 2.4.9
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanal
4
+ module Plugins
5
+ module UserSystem
6
+ module Helpers
7
+ #
8
+ # Serves as a configuration storage for UserSystem plugin to allow enabling of automatic creation of users
9
+ #
10
+ class AutoCreateEnabler
11
+ attr_reader :telegram_enabled
12
+
13
+ def initialize
14
+ @telegram_enabled = false
15
+ end
16
+
17
+ def enable_telegram
18
+ @telegram_enabled = true
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanal
4
+ module Plugins
5
+ module UserSystem
6
+ module Helpers
7
+ #
8
+ # Serves as a storage of methods to enable automatic user creation used by UserSystem
9
+ #
10
+ module AutoCreator
11
+ #
12
+ # Enables automatic creation of telegram user with telegram_chat_id property during consuming of input by router
13
+ #
14
+ # @param [Kanal::Core::Core] core <description>
15
+ #
16
+ def self.enable_telegram(core)
17
+ core.hooks.attach :input_before_router do |input|
18
+ tg_chat_id = input.tg_chat_id
19
+
20
+ tg_chat_id_property = "telegram_chat_id"
21
+
22
+ return if tg_chat_id.nil?
23
+
24
+ user = KanalUser.find_all_by_property(property_name: tg_chat_id_property, property_value: tg_chat_id).first
25
+
26
+ unless user
27
+ username = input.tg_username
28
+
29
+ username ||= "TEMP_USERNAME_#{tg_chat_id}"
30
+
31
+ user = KanalUser.create(username: username)
32
+ user.create_or_update_property(tg_chat_id_property, tg_chat_id)
33
+ end
34
+
35
+ input.user = user
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "kanal/core/plugins/plugin"
4
4
  require_relative "./models/kanal_user"
5
+ require_relative "helpers/auto_creator"
6
+ require_relative "helpers/auto_create_enabler"
5
7
 
6
8
  module Kanal
7
9
  module Plugins
@@ -10,6 +12,14 @@ module Kanal
10
12
  # registration and removal system
11
13
  class UserSystemPlugin < Kanal::Core::Plugins::Plugin
12
14
  include Models
15
+ include Helpers
16
+
17
+ attr_reader :auto_create
18
+
19
+ def initialize
20
+ super
21
+ @auto_create = AutoCreateEnabler.new
22
+ end
13
23
 
14
24
  def name
15
25
  :user_system
@@ -31,6 +41,8 @@ module Kanal
31
41
 
32
42
  setup_user_storage core
33
43
  setup_user_state core
44
+
45
+ AutoCreator.enable_telegram(core) if @auto_create.telegram_enabled
34
46
  end
35
47
 
36
48
  def setup_user_state(core)
@@ -3,7 +3,7 @@
3
3
  module Kanal
4
4
  module Plugins
5
5
  module UserSystem
6
- VERSION = "0.2.1"
6
+ VERSION = "0.3.1"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanal-plugins-user_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - idchlife
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-29 00:00:00.000000000 Z
11
+ date: 2023-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kanal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: kanal-plugins-active_record
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.1
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: sqlite3
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -56,9 +84,10 @@ files:
56
84
  - LICENSE.txt
57
85
  - README.md
58
86
  - Rakefile
59
- - kanal-plugins-user_system.gemspec
60
87
  - lib/kanal/plugins/user_system.rb
61
88
  - lib/kanal/plugins/user_system/database/database_connection.rb
89
+ - lib/kanal/plugins/user_system/helpers/auto_create_enabler.rb
90
+ - lib/kanal/plugins/user_system/helpers/auto_creator.rb
62
91
  - lib/kanal/plugins/user_system/helpers/json_value_converter_mixin.rb
63
92
  - lib/kanal/plugins/user_system/migrations/20221124150000_create_base_models.rb
64
93
  - lib/kanal/plugins/user_system/models/kanal_user.rb
@@ -74,7 +103,7 @@ metadata:
74
103
  homepage_uri: https://github.com/idchlife/kanal-plugins-user_system
75
104
  source_code_uri: https://github.com/idchlife/kanal-plugins-user_system
76
105
  changelog_uri: https://github.com/idchlife/kanal-plugins-user_system
77
- post_install_message:
106
+ post_install_message:
78
107
  rdoc_options: []
79
108
  require_paths:
80
109
  - lib
@@ -90,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
119
  version: '0'
91
120
  requirements: []
92
121
  rubygems_version: 3.1.6
93
- signing_key:
122
+ signing_key:
94
123
  specification_version: 4
95
124
  summary: User system plugin for kanal library, provides users, user properties, etc
96
125
  test_files: []
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/kanal/plugins/user_system/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "kanal-plugins-user_system"
7
- spec.version = Kanal::Plugins::UserSystem::VERSION
8
- spec.authors = ["idchlife"]
9
- spec.email = ["idchlife@gmail.com"]
10
-
11
- spec.summary = "User system plugin for kanal library, provides users, user properties, etc"
12
- spec.description = "Library that provides user feature, with saving users and their properties"
13
- spec.homepage = "https://github.com/idchlife/kanal-plugins-user_system"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.6"
16
-
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/idchlife/kanal-plugins-user_system"
21
- spec.metadata["changelog_uri"] = "https://github.com/idchlife/kanal-plugins-user_system"
22
-
23
- spec.add_dependency "activerecord"
24
- # spec.add_dependency "kanal"
25
- spec.add_dependency "sqlite3"
26
-
27
- # Specify which files should be added to the gem when it is released.
28
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
- spec.files = Dir.chdir(__dir__) do
30
- `git ls-files -z`.split("\x0").reject do |f|
31
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
32
- end
33
- end
34
- spec.bindir = "exe"
35
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
- spec.require_paths = ["lib"]
37
-
38
- # Uncomment to register a new dependency of your gem
39
- # spec.add_dependency "example-gem", "~> 1.0"
40
-
41
- # For more information and examples about making a new gem, check out our
42
- # guide at: https://bundler.io/guides/creating_gem.html
43
- end