etwin 0.0.1

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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +11 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +9 -0
  7. data/Gemfile.lock +82 -0
  8. data/README.md +30 -0
  9. data/Rakefile +8 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/etwin.gemspec +37 -0
  13. data/lib/etwin.rb +27 -0
  14. data/lib/etwin/_auth.rb +4 -0
  15. data/lib/etwin/auth.rb +14 -0
  16. data/lib/etwin/auth/_auth_context.rb +30 -0
  17. data/lib/etwin/auth/auth_context.rb +9 -0
  18. data/lib/etwin/auth/auth_scope.rb +25 -0
  19. data/lib/etwin/auth/auth_type.rb +26 -0
  20. data/lib/etwin/auth/guest_auth_context.rb +71 -0
  21. data/lib/etwin/auth/user_auth_context.rb +83 -0
  22. data/lib/etwin/client.rb +11 -0
  23. data/lib/etwin/client/auth.rb +66 -0
  24. data/lib/etwin/client/etwin_client.rb +17 -0
  25. data/lib/etwin/client/http_etwin_client.rb +36 -0
  26. data/lib/etwin/core.rb +10 -0
  27. data/lib/etwin/core/object_type.rb +35 -0
  28. data/lib/etwin/hammerfest.rb +13 -0
  29. data/lib/etwin/hammerfest/hammerfest_server.rb +27 -0
  30. data/lib/etwin/hammerfest/hammerfest_user_id.rb +57 -0
  31. data/lib/etwin/hammerfest/hammerfest_username.rb +57 -0
  32. data/lib/etwin/hammerfest/short_hammerfest_user.rb +103 -0
  33. data/lib/etwin/link.rb +15 -0
  34. data/lib/etwin/link/hammerfest_link.rb +106 -0
  35. data/lib/etwin/link/link_action.rb +93 -0
  36. data/lib/etwin/link/twinoid_link.rb +106 -0
  37. data/lib/etwin/link/versioned_hammerfest_link.rb +93 -0
  38. data/lib/etwin/link/versioned_links.rb +123 -0
  39. data/lib/etwin/link/versioned_twinoid_link.rb +93 -0
  40. data/lib/etwin/twinoid.rb +12 -0
  41. data/lib/etwin/twinoid/short_twinoid_user.rb +93 -0
  42. data/lib/etwin/twinoid/twinoid_user_display_name.rb +57 -0
  43. data/lib/etwin/twinoid/twinoid_user_id.rb +57 -0
  44. data/lib/etwin/user.rb +15 -0
  45. data/lib/etwin/user/short_user.rb +93 -0
  46. data/lib/etwin/user/user.rb +123 -0
  47. data/lib/etwin/user/user_display_name.rb +57 -0
  48. data/lib/etwin/user/user_display_name_version.rb +83 -0
  49. data/lib/etwin/user/user_display_name_versions.rb +83 -0
  50. data/lib/etwin/user/user_id.rb +57 -0
  51. data/lib/etwin/version.rb +6 -0
  52. data/sorbet/config +2 -0
  53. data/sorbet/rbi/gems/ast.rbi +48 -0
  54. data/sorbet/rbi/gems/debase.rbi +67 -0
  55. data/sorbet/rbi/gems/irb.rbi +352 -0
  56. data/sorbet/rbi/gems/parallel.rbi +83 -0
  57. data/sorbet/rbi/gems/parser.rbi +1405 -0
  58. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  59. data/sorbet/rbi/gems/rake.rbi +644 -0
  60. data/sorbet/rbi/gems/regexp_parser.rbi +914 -0
  61. data/sorbet/rbi/gems/reline.rbi +556 -0
  62. data/sorbet/rbi/gems/rexml.rbi +605 -0
  63. data/sorbet/rbi/gems/rspec-core.rbi +1920 -0
  64. data/sorbet/rbi/gems/rspec-expectations.rbi +1148 -0
  65. data/sorbet/rbi/gems/rspec-mocks.rbi +1090 -0
  66. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  67. data/sorbet/rbi/gems/rspec.rbi +15 -0
  68. data/sorbet/rbi/gems/rubocop-ast.rbi +1338 -0
  69. data/sorbet/rbi/gems/rubocop.rbi +7491 -0
  70. data/sorbet/rbi/gems/ruby-debug-ide.rbi +608 -0
  71. data/sorbet/rbi/gems/ruby-progressbar.rbi +305 -0
  72. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  73. data/sorbet/rbi/hidden-definitions/errors.txt +4905 -0
  74. data/sorbet/rbi/hidden-definitions/hidden.rbi +9193 -0
  75. data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +276 -0
  76. data/sorbet/rbi/todo.rbi +7 -0
  77. metadata +220 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 91479b28b00a4f5f8225a418c5f1f742fdd71554d00afbb5c4c5fe69858152fa
4
+ data.tar.gz: ed39199b30be361b3568339b75d288f0706531aac94598fb0b63f74d25448b36
5
+ SHA512:
6
+ metadata.gz: 2a5758dfe8e51877b210a3ee1e98f183d020c122582f107a68c031acc85564054b351bc94c4d26d7faa358497bfa6682c4b27a1e12e2c5bbab85922fce5ca6c9
7
+ data.tar.gz: ef84e9e060c0b7a7002b3d02a878f15d440f81543e2e9879f94a88c59ca15ff2f97e3d5ae0d286466f127b456fdf9a20a01cc156fdd29ba9ddf523c29b0dc4d4
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,11 @@
1
+ require:
2
+ - rubocop-sorbet
3
+
4
+ AllCops:
5
+ DisplayCopNames: true
6
+ DisplayStyleGuide: true
7
+ NewCops: "enable"
8
+ TargetRubyVersion: 2.7
9
+
10
+ Style/AccessorGrouping:
11
+ EnforcedStyle: "separated"
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in hello_rb.gemspec
6
+ gemspec
7
+
8
+ gem 'irb', '~> 1.2.7', group: :development
9
+ gem 'ruby-debug-ide', '~> 2.3.1', group: :development
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ etwin (0.0.1)
5
+ faraday (~> 1.1.0)
6
+ sorbet-runtime (~> 0.5.6076)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.1)
12
+ debase (2.3.2)
13
+ debase-ruby_core_source (~> 0.10.11)
14
+ debase-ruby_core_source (0.10.11)
15
+ diff-lcs (1.4.4)
16
+ faraday (1.1.0)
17
+ multipart-post (>= 1.2, < 3)
18
+ ruby2_keywords
19
+ io-console (0.5.6)
20
+ irb (1.2.7)
21
+ reline (>= 0.1.5)
22
+ multipart-post (2.1.1)
23
+ parallel (1.20.0)
24
+ parser (2.7.2.0)
25
+ ast (~> 2.4.1)
26
+ rainbow (3.0.0)
27
+ rake (13.0.1)
28
+ regexp_parser (1.8.2)
29
+ reline (0.1.9)
30
+ io-console (~> 0.5)
31
+ rexml (3.2.4)
32
+ rspec (3.10.0)
33
+ rspec-core (~> 3.10.0)
34
+ rspec-expectations (~> 3.10.0)
35
+ rspec-mocks (~> 3.10.0)
36
+ rspec-core (3.10.0)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-expectations (3.10.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-mocks (3.10.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.0)
45
+ rubocop (1.3.1)
46
+ parallel (~> 1.10)
47
+ parser (>= 2.7.1.5)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ regexp_parser (>= 1.8)
50
+ rexml
51
+ rubocop-ast (>= 1.1.1)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 1.4.0, < 2.0)
54
+ rubocop-ast (1.1.1)
55
+ parser (>= 2.7.1.5)
56
+ rubocop-sorbet (0.5.1)
57
+ rubocop
58
+ ruby-debug-ide (2.3.1)
59
+ debase (~> 2.3.2)
60
+ ruby-progressbar (1.10.1)
61
+ ruby2_keywords (0.0.2)
62
+ sorbet (0.5.6084)
63
+ sorbet-static (= 0.5.6084)
64
+ sorbet-runtime (0.5.6111)
65
+ sorbet-static (0.5.6084-x86_64-linux)
66
+ unicode-display_width (1.7.0)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ etwin!
73
+ irb (~> 1.2.7)
74
+ rake (~> 13.0.1)
75
+ rspec (~> 3.10.0)
76
+ rubocop (~> 1.3.1)
77
+ rubocop-sorbet (~> 0.5.1)
78
+ ruby-debug-ide (~> 2.3.1)
79
+ sorbet (~> 0.5.6076)
80
+
81
+ BUNDLED WITH
82
+ 2.1.4
@@ -0,0 +1,30 @@
1
+ # Etwin client for ruby
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'etwin'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```
14
+ bundle install
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ TODO
20
+
21
+ ## Development
22
+
23
+ ```
24
+ bundle install
25
+ bundle exec rubocop
26
+ bundle exec rspec
27
+ bundle exec rake release
28
+ bundle exec rake install
29
+ bundle exec srb tc
30
+ ```
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'etwin'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/etwin/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'etwin'
7
+ spec.version = Etwin::VERSION
8
+ spec.authors = ['Charles Samborski']
9
+ spec.email = ['demurgos@demurgos.net']
10
+ spec.licenses = ['AGPL-3.0-or-later']
11
+
12
+ spec.summary = 'Ruby client for the Eternal-Twin API.'
13
+ spec.description = 'Ruby client for the Eternal-Twin API. Defines Etwin domain types and HTTP client.'
14
+ spec.homepage = 'https://gitlab.com/eternal-twin/etwin'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://gitlab.com/eternal-twin/etwin'
19
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/eternal-twin/etwin'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency('rake', '~> 13.0.1')
31
+ spec.add_development_dependency('rspec', '~> 3.10.0')
32
+ spec.add_development_dependency('rubocop', '~> 1.3.1')
33
+ spec.add_development_dependency('rubocop-sorbet', '~> 0.5.1')
34
+ spec.add_development_dependency('sorbet', '~> 0.5.6076')
35
+ spec.add_runtime_dependency('faraday', '~> 1.1.0')
36
+ spec.add_runtime_dependency('sorbet-runtime', '~> 0.5.6076')
37
+ end
@@ -0,0 +1,27 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require 'faraday'
5
+ require 'json'
6
+ require 'pp'
7
+ require 'time'
8
+ require 'sorbet-runtime'
9
+
10
+ # Eternal-Twin types and client
11
+ module Etwin
12
+ # class << self
13
+ # def get_user(name)
14
+ # "Hello, #{name}"
15
+ # end
16
+ # end
17
+ end
18
+
19
+ require_relative './etwin/auth'
20
+ require_relative './etwin/core'
21
+ require_relative './etwin/hammerfest'
22
+ require_relative './etwin/link'
23
+ require_relative './etwin/twinoid'
24
+ require_relative './etwin/user'
25
+ require_relative './etwin/version'
26
+
27
+ require_relative './etwin/_auth'
@@ -0,0 +1,4 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative './auth/_auth_context'
@@ -0,0 +1,14 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ # Authentication and Authorization typess
6
+ module Auth
7
+ end
8
+ end
9
+
10
+ require_relative './auth/auth_context'
11
+ require_relative './auth/auth_scope'
12
+ require_relative './auth/auth_type'
13
+ require_relative './auth/guest_auth_context'
14
+ require_relative './auth/user_auth_context'
@@ -0,0 +1,30 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ module Auth # rubocop:disable Style/Documentation
6
+ class << AuthContext
7
+ extend T::Sig
8
+
9
+ sig(:final) { returns(String) }
10
+ def AuthContext.name
11
+ 'Etwin::Auth::AuthContext'
12
+ end
13
+
14
+ sig(:final) { params(json_str: String).returns(T.self_type) }
15
+ def AuthContext.from_json(json_str)
16
+ deserialize JSON.parse(json_str)
17
+ end
18
+
19
+ sig(:final) { params(raw: T.untyped).returns(T.self_type) }
20
+ def AuthContext.deserialize(raw)
21
+ type = AuthType.deserialize(raw['type'])
22
+ case type
23
+ when AuthType::Guest then GuestAuthContext.deserialize(raw)
24
+ when AuthType::User then UserAuthContext.deserialize(raw)
25
+ else T.absurd(type)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ module Auth # rubocop:disable Style/Documentation
6
+ extend T::Sig
7
+ AuthContext = T.type_alias { T.any(GuestAuthContext, UserAuthContext) }
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ module Auth
6
+ # Authentication scope enum
7
+ class AuthScope < T::Enum
8
+ extend T::Sig
9
+
10
+ enums do
11
+ Default = new('Default')
12
+ end
13
+
14
+ sig { returns(String) }
15
+ def to_s
16
+ T.cast(serialize, String)
17
+ end
18
+
19
+ sig { returns(String) }
20
+ def inspect
21
+ "AuthScope(#{self})"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ module Auth
6
+ # Authentication type enum
7
+ class AuthType < T::Enum
8
+ extend T::Sig
9
+
10
+ enums do
11
+ Guest = new('Guest')
12
+ User = new('User')
13
+ end
14
+
15
+ sig { returns(String) }
16
+ def to_s
17
+ T.cast(serialize, String)
18
+ end
19
+
20
+ sig { returns(String) }
21
+ def inspect
22
+ "AuthType(#{self})"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,71 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Etwin
5
+ module Auth
6
+ # Guest authentication context
7
+ class GuestAuthContext
8
+ extend T::Helpers
9
+ extend T::Sig
10
+
11
+ final!
12
+
13
+ sig(:final) { returns(AuthScope) }
14
+ attr_reader :scope
15
+
16
+ sig(:final) { params(scope: AuthScope).void }
17
+ def initialize(scope)
18
+ @scope = T.let(scope, AuthScope)
19
+ freeze
20
+ end
21
+
22
+ sig(:final) { params(other: BasicObject).returns(T::Boolean) }
23
+ def ==(other)
24
+ case other
25
+ when GuestAuthContext
26
+ @scope == other.scope
27
+ else
28
+ false
29
+ end
30
+ end
31
+
32
+ sig(:final) { returns(Integer) }
33
+ def hash
34
+ [@scope].hash
35
+ end
36
+
37
+ # https://github.com/sorbet/sorbet/blob/master/rbi/stdlib/json.rbi#L194
38
+ sig(:final) { params(opts: T.untyped).returns(String) }
39
+ def to_json(opts = nil)
40
+ JSON.generate(as_json, opts)
41
+ end
42
+
43
+ sig(:final) { returns(T::Hash[String, T.untyped]) }
44
+ def as_json
45
+ {
46
+ 'scope' => @scope.serialize
47
+ }
48
+ end
49
+
50
+ sig(:final) { returns(String) }
51
+ def inspect
52
+ "GuestAuthContext(scope=#{@scope.inspect})"
53
+ end
54
+
55
+ class << self
56
+ extend T::Sig
57
+
58
+ sig(:final) { params(json_str: String).returns(T.attached_class) }
59
+ def from_json(json_str)
60
+ deserialize JSON.parse(json_str)
61
+ end
62
+
63
+ sig(:final) { params(raw: T.untyped).returns(T.attached_class) }
64
+ def deserialize(raw)
65
+ scope = AuthScope.deserialize(raw['scope'])
66
+ new(scope)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end