terminalwire 0.2.4 → 0.3.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/exe/terminalwire +1 -1
  3. data/exe/terminalwire-exec +1 -1
  4. metadata +9 -169
  5. data/.rspec +0 -3
  6. data/CHANGELOG.md +0 -5
  7. data/CODE_OF_CONDUCT.md +0 -132
  8. data/LICENSE.txt +0 -9
  9. data/README.md +0 -45
  10. data/Rakefile +0 -8
  11. data/examples/exec/localrails +0 -2
  12. data/lib/generators/terminalwire/install/USAGE +0 -9
  13. data/lib/generators/terminalwire/install/install_generator.rb +0 -38
  14. data/lib/generators/terminalwire/install/templates/application_terminal.rb.tt +0 -21
  15. data/lib/generators/terminalwire/install/templates/bin/terminalwire +0 -2
  16. data/lib/generators/terminalwire/install/templates/main_terminal.rb +0 -40
  17. data/lib/terminalwire/adapter.rb +0 -53
  18. data/lib/terminalwire/cache.rb +0 -114
  19. data/lib/terminalwire/client/entitlement/environment_variables.rb +0 -26
  20. data/lib/terminalwire/client/entitlement/paths.rb +0 -97
  21. data/lib/terminalwire/client/entitlement/policy.rb +0 -117
  22. data/lib/terminalwire/client/entitlement/schemes.rb +0 -26
  23. data/lib/terminalwire/client/entitlement.rb +0 -9
  24. data/lib/terminalwire/client/exec.rb +0 -44
  25. data/lib/terminalwire/client/handler.rb +0 -67
  26. data/lib/terminalwire/client/resource.rb +0 -204
  27. data/lib/terminalwire/client/server_license_verification.rb +0 -74
  28. data/lib/terminalwire/client.rb +0 -30
  29. data/lib/terminalwire/logging.rb +0 -8
  30. data/lib/terminalwire/rails.rb +0 -69
  31. data/lib/terminalwire/server/context.rb +0 -80
  32. data/lib/terminalwire/server/resource.rb +0 -120
  33. data/lib/terminalwire/server.rb +0 -63
  34. data/lib/terminalwire/thor.rb +0 -55
  35. data/lib/terminalwire/transport.rb +0 -58
  36. data/lib/terminalwire/version.rb +0 -5
  37. data/lib/terminalwire.rb +0 -56
  38. data/sig/terminalwire.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8a974238ae54d86b1c98334295187af746fede63382fe22d3cb527c4216f728
4
- data.tar.gz: c99cdc090e070a11eb5a05ad2e2e0aebbb1d0c919899b5b0ed891c6ef693a9e8
3
+ metadata.gz: 1937bd63daba6afa08a9fa2b8409bb857994435aaca41625478d1141e372c989
4
+ data.tar.gz: 392a7a5abefa4f05a0c71c7f748845209cb580622900a692ccf65cb931756b43
5
5
  SHA512:
6
- metadata.gz: 0df6c3219578c496eb45b8050164d9427207feb57012071abcf9d683ab6953ea95a92bf9c8eee0ab32c13f5335161777f4d4b1e06e53fdeb524f1d8f4d8987b7
7
- data.tar.gz: 988d13343b1b408d7c70c3e3252ccd43385081c7438263f8add6c21c6320ac93a9e0a8795764dc250a1db601daccd86253fd3c09c2b487dcdec377350ccb6f4e
6
+ metadata.gz: 4af7d35e43e1b79dbf2fdac4b3d0215c2d54cb8732fe4693e6e549577962c2cb797a0296ab46fea4e8de39f98f9ac22536f61b550bf9ab36c116acafe477a740
7
+ data.tar.gz: 4204aad1b0893dd3a926fda32cf7f7271823c6b9b9b08b5826a76c280c9b5cf407acb3d4c50ce10b07b4d2ba2925bac11a2f791ec2aef0cfc6793511f19232b6
data/exe/terminalwire CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/terminalwire.rb"
2
+ require "terminalwire/client"
3
3
 
4
4
  begin
5
5
  Terminalwire::Client.websocket(url: "wss://terminalwire.com/terminal")
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/terminalwire.rb"
2
+ require "terminalwire/client"
3
3
 
4
4
  begin
5
5
  Terminalwire::Client::Exec.start
metadata CHANGED
@@ -1,155 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminalwire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-08 00:00:00.000000000 Z
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: async-websocket
14
+ name: terminalwire-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0.30'
19
+ version: 0.3.0.alpha1
20
20
  type: :runtime
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: '0.30'
27
- - !ruby/object:Gem::Dependency
28
- name: zeitwerk
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: thor
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.3'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: msgpack
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.7'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.7'
69
- - !ruby/object:Gem::Dependency
70
- name: launchy
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: jwt
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.0'
97
- - !ruby/object:Gem::Dependency
98
- name: uri-builder
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.1.9
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.1.9
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '13.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '13.0'
125
- - !ruby/object:Gem::Dependency
126
- name: rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3.0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '3.0'
139
- - !ruby/object:Gem::Dependency
140
- name: rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '7.2'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '7.2'
26
+ version: 0.3.0.alpha1
153
27
  description: Stream command-line apps from your server without a web API
154
28
  email:
155
29
  - brad@terminalwire.com
@@ -159,49 +33,15 @@ executables:
159
33
  extensions: []
160
34
  extra_rdoc_files: []
161
35
  files:
162
- - ".rspec"
163
- - CHANGELOG.md
164
- - CODE_OF_CONDUCT.md
165
- - LICENSE.txt
166
- - README.md
167
- - Rakefile
168
- - examples/exec/localrails
169
36
  - exe/terminalwire
170
37
  - exe/terminalwire-exec
171
- - lib/generators/terminalwire/install/USAGE
172
- - lib/generators/terminalwire/install/install_generator.rb
173
- - lib/generators/terminalwire/install/templates/application_terminal.rb.tt
174
- - lib/generators/terminalwire/install/templates/bin/terminalwire
175
- - lib/generators/terminalwire/install/templates/main_terminal.rb
176
- - lib/terminalwire.rb
177
- - lib/terminalwire/adapter.rb
178
- - lib/terminalwire/cache.rb
179
- - lib/terminalwire/client.rb
180
- - lib/terminalwire/client/entitlement.rb
181
- - lib/terminalwire/client/entitlement/environment_variables.rb
182
- - lib/terminalwire/client/entitlement/paths.rb
183
- - lib/terminalwire/client/entitlement/policy.rb
184
- - lib/terminalwire/client/entitlement/schemes.rb
185
- - lib/terminalwire/client/exec.rb
186
- - lib/terminalwire/client/handler.rb
187
- - lib/terminalwire/client/resource.rb
188
- - lib/terminalwire/client/server_license_verification.rb
189
- - lib/terminalwire/logging.rb
190
- - lib/terminalwire/rails.rb
191
- - lib/terminalwire/server.rb
192
- - lib/terminalwire/server/context.rb
193
- - lib/terminalwire/server/resource.rb
194
- - lib/terminalwire/thor.rb
195
- - lib/terminalwire/transport.rb
196
- - lib/terminalwire/version.rb
197
- - sig/terminalwire.rbs
198
38
  homepage: https://terminalwire.com/ruby
199
39
  licenses:
200
40
  - Proprietary (https://terminalwire.com/license)
201
41
  metadata:
202
42
  allowed_push_host: https://rubygems.org/
203
43
  homepage_uri: https://terminalwire.com/ruby
204
- source_code_uri: https://github.com/terminalwire/ruby
44
+ source_code_uri: https://github.com/terminalwire/ruby/tree/main/terminalwire
205
45
  changelog_uri: https://github.com/terminalwire/ruby/tags
206
46
  funding_uri: https://terminalwire.com/funding
207
47
  post_install_message:
@@ -219,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
59
  - !ruby/object:Gem::Version
220
60
  version: '0'
221
61
  requirements: []
222
- rubygems_version: 3.5.16
62
+ rubygems_version: 3.5.9
223
63
  signing_key:
224
64
  specification_version: 4
225
65
  summary: Ship a CLI for your web app. No API required.
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2024-08-29
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,132 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual
10
- identity and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the overall
26
- community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or advances of
31
- any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email address,
35
- without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official email address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- [INSERT CONTACT METHOD].
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series of
86
- actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or permanent
93
- ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within the
113
- community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
- [https://www.contributor-covenant.org/translations][translations].
127
-
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt DELETED
@@ -1,9 +0,0 @@
1
- Copyright (c) 2024 Brad Gessler.
2
-
3
- License is propietary. Here's the deal:
4
-
5
- * You need to pay for Terminalwire if your organization has more than $1m in assets or makes more than $100k/year in revenue.
6
- * Terminalwire is free for personal use, hobbyists, or businesses that are just starting out, but server licenses still need to be registered at https://terminalwire.com/developers/licenses.
7
- * You can only use the Terminalwire client with licensed Terminalwire servers.
8
-
9
- This list is not exhaustive, please read the full license text at https://terminalwire.com/license.
data/README.md DELETED
@@ -1,45 +0,0 @@
1
- # Terminalwire
2
-
3
- Unlike most command-line tools for web services that require an API, Terminalwire streams terminal I/O between a web server and client over WebSockets. This means you can use your preferred command-line parser within your favorite web server framework to deliver a delightful CLI experience to your users.
4
-
5
- ## Installation
6
-
7
- Install the gem and add to the application's Gemfile by executing:
8
-
9
- $ bundle add terminalwire
10
-
11
- If bundler is not being used to manage dependencies, install the gem by executing:
12
-
13
- $ gem install terminalwire
14
-
15
- ## Rails
16
-
17
- Run the intallation command:
18
-
19
- $ rails g terminalwire:install my-app
20
-
21
- This generates the `./bin/my-app` file. Run it to verify that it connects to the server.
22
-
23
- $ bin/my-app
24
- Commands:
25
- my-app help [COMMAND] # Describe available commands or one specific command
26
-
27
- To edit the command-line, open `./app/cli/main_cli.rb` and make changes to the `MainCLI` class.
28
-
29
- ## Development
30
-
31
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
-
33
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
-
35
- ## Contributing
36
-
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/terminalwire/ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/terminalwire/ruby/blob/main/CODE_OF_CONDUCT.md).
38
-
39
- ## License
40
-
41
- The gem is available as a propietary license. Email brad@terminalwire.com to discuss licensing.
42
-
43
- ## Code of Conduct
44
-
45
- Everyone interacting in the Terminalwire project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/terminalwire/ruby/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,8 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env terminalwire-exec
2
- url: "ws://localhost:3000/terminal"
@@ -1,9 +0,0 @@
1
- Description:
2
- Installs Terminalwire
3
-
4
- Example:
5
- bin/rails generate terminalwire:install
6
-
7
- This will create:
8
- app/terminal/application_terminal.rb
9
- bin/<your-app>
@@ -1,38 +0,0 @@
1
- require "bundler"
2
-
3
- class Terminalwire::InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path("templates", __dir__)
5
-
6
- argument :binary_name, type: :string, required: true, banner: "binary_name"
7
-
8
- def create_terminal_files
9
- template "application_terminal.rb.tt", Rails.root.join("app/terminal/application_terminal.rb")
10
- template "main_terminal.rb", Rails.root.join("app/terminal/main_terminal.rb")
11
- end
12
-
13
- def create_binary_files
14
- copy_file "bin/terminalwire", binary_path
15
- chmod binary_path, 0755, verbose: false
16
- end
17
-
18
- def add_route
19
- route <<~ROUTE
20
- match "/terminal",
21
- to: Terminalwire::Server::Thor.new(MainTerminal),
22
- via: [:get, :connect]
23
- ROUTE
24
- end
25
-
26
- def print_post_install_message
27
- say ""
28
- say "Terminalwire has been successfully installed!", :green
29
- say "Run `#{binary_path.relative_path_from(Rails.root)}` to verify everything is in working order. For support visit https://terminalwire.com."
30
- say ""
31
- end
32
-
33
- private
34
-
35
- def binary_path
36
- Rails.root.join("bin", binary_name)
37
- end
38
- end
@@ -1,21 +0,0 @@
1
- # Learn how to use Thor at http://whatisthor.com.
2
- class ApplicationTerminal < Thor
3
- # Enables IO Streaming.
4
- include Terminalwire::Thor
5
-
6
- # The name of your binary. Thor uses this for its help output.
7
- def self.basename = "<%= binary_name %>"
8
-
9
- private
10
-
11
- def current_user=(user)
12
- # The Session object is a hash-like object that encrypts and signs a hash that's
13
- # stored on the client's file sytem. Conceptually, it's similar to Rails signed
14
- # and encrypted client-side cookies.
15
- session["user_id"] = user.id
16
- end
17
-
18
- def current_user
19
- @current_user ||= User.find(session["user_id"])
20
- end
21
- end
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env terminalwire-exec
2
- url: "ws://localhost:3000/terminal"
@@ -1,40 +0,0 @@
1
- class MainTerminal < ApplicationTerminal
2
- desc "hello NAME", "say hello to NAME"
3
- def hello(name)
4
- puts "Hello #{name}"
5
- end
6
-
7
- desc "login", "Login to your account"
8
- def login
9
- print "Email: "
10
- email = gets.chomp
11
-
12
- print "Password: "
13
- password = getpass
14
-
15
- # Replace this with your own authentication logic; this is an example
16
- # of how you might do this with Devise.
17
- user = User.find_for_authentication(email: email)
18
- if user && user.valid_password?(password)
19
- self.current_user = user
20
- puts "Successfully logged in as #{current_user.email}."
21
- else
22
- puts "Could not find a user with that email and password."
23
- end
24
- end
25
-
26
- desc "whoami", "Displays current user information."
27
- def whoami
28
- if self.current_user
29
- puts "Logged in as #{current_user.email}."
30
- else
31
- puts "Not logged in. Run `#{self.class.basename} login` to login."
32
- end
33
- end
34
-
35
- desc "logout", "Logout of your account"
36
- def logout
37
- session.reset
38
- puts "Successfully logged out."
39
- end
40
- end
@@ -1,53 +0,0 @@
1
- require 'msgpack'
2
-
3
- module Terminalwire::Adapter
4
- # Works with Test, TCP, Unix, WebSocket, and other socket-like abstractions.
5
- class Socket
6
- include Terminalwire::Logging
7
-
8
- attr_reader :transport
9
-
10
- def initialize(transport)
11
- @transport = transport
12
- end
13
-
14
- def write(data)
15
- logger.debug "Adapter: Sending #{data.inspect}"
16
- packed_data = MessagePack.pack(data, symbolize_keys: true)
17
- @transport.write(packed_data)
18
- end
19
-
20
- def read
21
- logger.debug "Adapter: Reading"
22
- packed_data = @transport.read
23
- return nil if packed_data.nil?
24
- data = MessagePack.unpack(packed_data, symbolize_keys: true)
25
- logger.debug "Adapter: Received #{data.inspect}"
26
- data
27
- end
28
-
29
- def close
30
- @transport.close
31
- end
32
- end
33
-
34
- # This is a test adapter that can be used for testing purposes.
35
- class Test
36
- attr_reader :responses
37
-
38
- def initialize(responses = [])
39
- @responses = responses
40
- end
41
-
42
- def write(**data)
43
- @responses << data
44
- end
45
-
46
- def response
47
- @responses.pop
48
- end
49
-
50
- def close
51
- end
52
- end
53
- end