altair-rails 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 073d47c7db152d67e61edaa10a53289026a6816ef6da55036223239f2516fa7e
4
+ data.tar.gz: b93b8ad0b079abfaae4807e2c9ab331c103a8bd0ee35a17d8dcf4afe70c680fb
5
+ SHA512:
6
+ metadata.gz: dfa4259a2aaf0e57a72e0d88d9726ab5c2608b35c79e96a5a6c96de8ae08e081dadef221a9e314abc12c0bee5f8003a53efb07198528faa0cac77f8bca4e3f01
7
+ data.tar.gz: bf0bda9c47faf2d8d097c28240db179e62470ba3418ffff1077a17b5db0a00d2ca84f16cad53ff1da2504f9b0892e153d7d33335aa4e799bcecab7a1d937bc62
data/CHANGELOG.md ADDED
File without changes
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 Jeremy Jackson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Altair Rails - The Altair GraphQL Client for Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/altair-rails.svg)](https://badge.fury.io/rb/altair-rails)
4
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/22128c5c828a8eed6f95/maintainability)](https://codeclimate.com/github/jejacks0n/altair-rails/maintainability)
6
+
7
+ Altair Rails is a Rails engine that provides a mountable endpoint for the [Altair GraphQL Client](https://altairgraphql.dev/).
8
+
9
+ ## Download and Installation
10
+
11
+ Add this line to your Gemfile:
12
+
13
+ ```ruby
14
+ gem "altair-rails"
15
+ ```
16
+
17
+ Or install the latest version with RubyGems:
18
+
19
+ ```bash
20
+ gem install altair-rails
21
+ ```
22
+
23
+ Source code can be downloaded as part of the project on GitHub:
24
+
25
+ * https://github.com/jejacks0n/altair-rails
26
+
27
+ ## Configuration
28
+
29
+ By default the Altair GraphQL Client is mounted at `/altair`. It can be configured by adding an initializer to your Rails application:
30
+
31
+ ```ruby
32
+ Altair::Rails.configure do |config|
33
+ # Where you want to mount the engine in your application. If set to nil,
34
+ # the engine will not be mounted automatically and it will need to be
35
+ # mounted manually. E.g.: in your routes.rb file, adding:
36
+ # mount Altair::Rails::Engine => "/altair"`
37
+ config.mount_at = "/altair"
38
+
39
+ # The path to your GraphQL endpoint. This is used to set the endpointURL.
40
+ config.graphql_path = "/graphql"
41
+
42
+ # The path to your ActionCable endpoint. This is used to set the
43
+ # subscriptionsEndpoint.
44
+ config.action_cable_path = "/cable"
45
+
46
+ # Any options you want to pass to AltairGraphQL.init(). For more details:
47
+ # https://github.com/altair-graphql/altair/blob/f433ee1bf6c52c8639b6448fa7e0c31c6ad955d1/packages/altair-core/src/config.ts
48
+ config.altair_options = {}
49
+ end
50
+ ```
51
+
52
+ ## License
53
+
54
+ Active Experiment is released under the MIT license:
55
+
56
+ * https://opensource.org/licenses/MIT
57
+
58
+ Copyright 2023 [jejacks0n](https://github.com/jejacks0n)
59
+
60
+ ## Make Code Not War
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Altair
4
+ module Rails
5
+ class Configuration
6
+ include Singleton
7
+
8
+ cattr_accessor(*[:mount_at, :graphql_path, :action_cable_path, :altair_options, :altair_version])
9
+
10
+ # Where you want to mount the engine in your application. If set to nil,
11
+ # the engine will not be mounted automatically and it will need to be
12
+ # mounted manually. E.g.: in your routes.rb file, adding:
13
+ # mount Altair::Rails::Engine => "/altair"`
14
+ #
15
+ # Defaults to "/altair".
16
+ @@mount_at = "/altair"
17
+
18
+ # The path to your GraphQL endpoint. This is used to set the endpointURL.
19
+ @@graphql_path = "/graphql"
20
+
21
+ # The path to your ActionCable endpoint. This is used to set the
22
+ # subscriptionsEndpoint.
23
+ @@action_cable_path = "/cable"
24
+
25
+ # Any options you want to pass to AltairGraphQL.init(). For more details:
26
+ # https://github.com/altair-graphql/altair/blob/f433ee1bf6c52c8639b6448fa7e0c31c6ad955d1/packages/altair-core/src/config.ts
27
+ @@altair_options = {}
28
+
29
+ # Generally this should be left to the release version of altair-rails,
30
+ # but if you really want, you can override it here.
31
+ @@altair_version = "5.0.28" # Altair::Rails.version
32
+ end
33
+
34
+ mattr_accessor :configuration
35
+ @@configuration = Configuration
36
+
37
+ def self.configure
38
+ yield @@configuration
39
+ end
40
+
41
+ singleton_class.send(:alias_method, :setup, :configure)
42
+ end
43
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Altair
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Altair::Rails
7
+
8
+ altair_rails = Altair::Rails.configuration
9
+
10
+ if altair_rails.mount_at.present?
11
+ config.after_initialize do |app|
12
+ app.routes.prepend { mount Altair::Rails::Engine => altair_rails.mount_at }
13
+ end
14
+ end
15
+
16
+ routes do
17
+ root to: ->(_) { [200, {}, <<~HTML_BODY] }
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <meta charset="utf-8" />
22
+ <title>Altair</title>
23
+ <base href="https://cdn.jsdelivr.net/npm/altair-static@#{altair_rails.altair_version}/build/dist/">
24
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
25
+ <link href="styles.css" rel="stylesheet" />
26
+ <style>.loading-screen { display: none }</style>
27
+ </head>
28
+ <body>
29
+ <script>
30
+ // window.__ALTAIR_WEB_APP__ = 1;
31
+ const defaultOptions = {
32
+ endpointURL: window.location.origin + "#{altair_rails.graphql_path}",
33
+ subscriptionsEndpoint: "ws://" + window.location.host + "#{altair_rails.action_cable_path}",
34
+ initialSubscriptionsProvider: "action-cable"
35
+ };
36
+ document.addEventListener('DOMContentLoaded', function() {
37
+ AltairGraphQL.init(Object.assign({}, defaultOptions, #{altair_rails.altair_options.to_json}));
38
+ });
39
+ </script>
40
+ <app-root>
41
+ <div class="loading-screen styled">
42
+ <div class="loading-screen-inner">
43
+ <div class="loading-screen-logo-container">
44
+ <img src="assets/img/logo_350.svg" alt="Altair" />
45
+ </div>
46
+ <div class="loading-screen-loading-indicator">
47
+ <span class="loading-indicator-dot"></span>
48
+ <span class="loading-indicator-dot"></span>
49
+ <span class="loading-indicator-dot"></span>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </app-root>
54
+ <script rel="preload" as="script" type="text/javascript" src="runtime.js"></script>
55
+ <script rel="preload" as="script" type="text/javascript" src="polyfills.js" ></script>
56
+ <script rel="preload" as="script" type="text/javascript" src="main.js" ></script>
57
+ </body>
58
+ </html>
59
+ HTML_BODY
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Altair
4
+ module Rails
5
+ # Returns the currently loaded version of Active Experiment as a
6
+ # +Gem::Version+.
7
+ def self.version
8
+ Gem::Version.new(VERSION::STRING)
9
+ end
10
+
11
+ module VERSION
12
+ MAJOR = 0
13
+ MINOR = 0
14
+ TINY = 2
15
+ PRE = nil
16
+
17
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "altair/rails/version"
4
+ require "altair/rails/configuration"
5
+ require "altair/rails/engine"
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: altair-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Jackson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-07-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A static version of the Altair GraphQL Client, for Rails and ActionCable
28
+ subscriptions.
29
+ email: jejacks0n@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - lib/altair/rails.rb
38
+ - lib/altair/rails/configuration.rb
39
+ - lib/altair/rails/engine.rb
40
+ - lib/altair/rails/version.rb
41
+ homepage: https://github.com/jejacks0n/altair-rails
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/jejacks0n/altair-rails
46
+ source_code_uri: https://github.com/jejacks0n/altair-rails
47
+ bug_tracker_uri: https://github.com/jejacks0n/altair-rails/issues
48
+ changelog_uri: https://github.com/jejacks0n/altair-rails/CHANGELOG.md
49
+ documentation_uri: https://github.com/jejacks0n/altair-rails/README.md
50
+ rubygems_mfa_required: 'true'
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.7.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.4.14
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Altair GraphQL Client for Rails.
70
+ test_files: []