ruby_graphiql_explorer 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b2fe1194d4f2a7748ee3b98b5ed642046e321476474c9ddf098673525a1558c5
4
+ data.tar.gz: 0d3b574741f440de4413f57420dfb72d31da198ce2d52d881a00e8c1c2663a8b
5
+ SHA512:
6
+ metadata.gz: f828caa23d99a0e4cf38e91f84be16b91761a8a412db006ac062669f8ec2735d2c64d5ccfa7359e76de315b3291c6146b7d211b98c9d023bdf7acf64a1bfcd67
7
+ data.tar.gz: a2d014ba184e0bfdf0db9ff379f77798c128a17d0e45cb74f396fdda502f54a5752d1d649ce4ed50798a67b8f14fc04f71dbf93033495a83b63ee341556b4f29
@@ -0,0 +1,30 @@
1
+ name: build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v1
11
+
12
+ - name: Install Ruby (2.6)
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+
17
+ - name: Setup Code Climate test-reporter
18
+ run: |
19
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
20
+ chmod +x ./cc-test-reporter
21
+ ./cc-test-reporter before-build
22
+ - name: Build and test with RSpec
23
+ run: |
24
+ gem install bundler
25
+ bundle install --jobs 4 --retry 3
26
+ bundle exec rspec
27
+ - name: Publish code coverage
28
+ run: |
29
+ export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
30
+ ./cc-test-reporter after-build -r ${{secrets.CC_TEST_REPORTER_ID}}
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,119 @@
1
+ require: rubocop-performance
2
+ AllCops:
3
+ TargetRubyVersion: 2.4
4
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
5
+ # to ignore them, so only the ones explicitly set in this file are enabled.
6
+ DisabledByDefault: true
7
+ Exclude:
8
+ - 'lib/**/*.html.erb'
9
+ - 'vendor/**/*'
10
+ - 'node_modules/**/*'
11
+
12
+ # Prefer &&/|| over and/or.
13
+ Style/AndOr:
14
+ Enabled: true
15
+
16
+ # Align `when` with `case`.
17
+ Layout/CaseIndentation:
18
+ Enabled: true
19
+
20
+ # Align comments with method definitions.
21
+ Layout/CommentIndentation:
22
+ Enabled: true
23
+
24
+ # No extra empty lines.
25
+ Layout/EmptyLines:
26
+ Enabled: true
27
+
28
+ # In a regular class definition, no empty lines around the body.
29
+ Layout/EmptyLinesAroundClassBody:
30
+ Enabled: true
31
+
32
+ # In a regular method definition, no empty lines around the body.
33
+ Layout/EmptyLinesAroundMethodBody:
34
+ Enabled: true
35
+
36
+ # In a regular module definition, no empty lines around the body.
37
+ Layout/EmptyLinesAroundModuleBody:
38
+ Enabled: true
39
+
40
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
41
+ Style/HashSyntax:
42
+ Enabled: true
43
+
44
+ # Method definitions after `private` or `protected` isolated calls need one
45
+ # extra level of indentation.
46
+ Layout/IndentationConsistency:
47
+ Enabled: true
48
+
49
+ # Two spaces, no tabs (for indentation).
50
+ Layout/IndentationWidth:
51
+ Enabled: true
52
+
53
+ Layout/SpaceAfterColon:
54
+ Enabled: true
55
+
56
+ Layout/SpaceAfterComma:
57
+ Enabled: true
58
+
59
+ Layout/SpaceAroundEqualsInParameterDefault:
60
+ Enabled: true
61
+
62
+ Layout/SpaceAroundKeyword:
63
+ Enabled: true
64
+
65
+ Layout/SpaceAroundOperators:
66
+ Enabled: true
67
+
68
+ Layout/SpaceBeforeFirstArg:
69
+ Enabled: true
70
+
71
+ # Defining a method with parameters needs parentheses.
72
+ Style/MethodDefParentheses:
73
+ Enabled: true
74
+
75
+ # Use `foo {}` not `foo{}`.
76
+ Layout/SpaceBeforeBlockBraces:
77
+ Enabled: true
78
+
79
+ # Use `foo { bar }` not `foo {bar}`.
80
+ Layout/SpaceInsideBlockBraces:
81
+ Enabled: true
82
+
83
+ # Use `{ a: 1 }` not `{a:1}`.
84
+ Layout/SpaceInsideHashLiteralBraces:
85
+ Enabled: true
86
+
87
+ Layout/SpaceInsideParens:
88
+ Enabled: true
89
+
90
+ # Check quotes usage according to lint rule below.
91
+ Style/StringLiterals:
92
+ Enabled: true
93
+ EnforcedStyle: double_quotes
94
+
95
+ # Detect hard tabs, no hard tabs.
96
+ Layout/IndentationStyle:
97
+ Enabled: true
98
+
99
+ # Blank lines should not have any spaces.
100
+ Layout/TrailingEmptyLines:
101
+ Enabled: true
102
+
103
+ # No trailing whitespace.
104
+ Layout/TrailingWhitespace:
105
+ Enabled: true
106
+
107
+ # Use quotes for string literals when they are enough.
108
+ Style/RedundantPercentQ:
109
+ Enabled: true
110
+
111
+ # Align `end` with the matching keyword or starting expression except for
112
+ # assignments, where it should be aligned with the LHS.
113
+ Layout/EndAlignment:
114
+ Enabled: true
115
+ EnforcedStyleAlignWith: variable
116
+
117
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
118
+ Lint/RequireParentheses:
119
+ Enabled: true
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 12.0"
6
+
7
+ group :test do
8
+ gem "rspec"
9
+ end
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby_graphiql_explorer (1.0.0)
5
+ rack-app
6
+ rack-app-front_end
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.1)
12
+ diff-lcs (1.4.4)
13
+ parallel (1.19.2)
14
+ parser (2.7.1.4)
15
+ ast (~> 2.4.1)
16
+ rack (2.2.3)
17
+ rack-app (7.6.4)
18
+ rack
19
+ rack-app-front_end (0.22.0)
20
+ rack-app (>= 6.3.1)
21
+ tilt
22
+ rainbow (3.0.0)
23
+ rake (12.3.3)
24
+ regexp_parser (1.7.1)
25
+ rexml (3.2.4)
26
+ rspec (3.9.0)
27
+ rspec-core (~> 3.9.0)
28
+ rspec-expectations (~> 3.9.0)
29
+ rspec-mocks (~> 3.9.0)
30
+ rspec-core (3.9.2)
31
+ rspec-support (~> 3.9.3)
32
+ rspec-expectations (3.9.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-mocks (3.9.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-support (3.9.3)
39
+ rubocop (0.90.0)
40
+ parallel (~> 1.10)
41
+ parser (>= 2.7.1.1)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.7)
44
+ rexml
45
+ rubocop-ast (>= 0.3.0, < 1.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 1.4.0, < 2.0)
48
+ rubocop-ast (0.3.0)
49
+ parser (>= 2.7.1.4)
50
+ rubocop-performance (1.7.1)
51
+ rubocop (>= 0.82.0)
52
+ ruby-progressbar (1.10.1)
53
+ tilt (2.0.10)
54
+ unicode-display_width (1.7.0)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ rake (~> 12.0)
61
+ rspec
62
+ rubocop
63
+ rubocop-performance
64
+ ruby_graphiql_explorer!
65
+
66
+ BUNDLED WITH
67
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Gaurav Tiwari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # RubyGraphiqlExplorer
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby_graphiql_explorer`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ruby_graphiql_explorer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ruby_graphiql_explorer
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_graphiql_explorer.
36
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,15 @@
1
+ require "ruby_graphiql_explorer/version"
2
+ require "rack/app"
3
+ require "rack/app/front_end"
4
+
5
+ module RubyGraphiqlExplorer
6
+ class Error < StandardError; end
7
+
8
+ class App < Rack::App
9
+ apply_extensions :front_end
10
+
11
+ get "/" do
12
+ render "index.html.erb"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ <html>
2
+ <head>
3
+ <title>GraphQL API explorer</title>
4
+ <link href="https://unpkg.com/graphiql/graphiql.min.css" rel="stylesheet" />
5
+ </head>
6
+ <body style="margin: 0">
7
+ <div id="graphiql" style="height: 100vh"></div>
8
+
9
+ <script
10
+ crossorigin
11
+ src="https://unpkg.com/react/umd/react.production.min.js"
12
+ ></script>
13
+ <script
14
+ crossorigin
15
+ src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"
16
+ ></script>
17
+ <script
18
+ crossorigin
19
+ src="https://unpkg.com/graphiql/graphiql.min.js"
20
+ ></script>
21
+
22
+ <script>
23
+ const graphQLFetcher = (graphQLParams) =>
24
+ fetch('<%= ENV.fetch('GRAPHQL_API_URL', 'http://localhost:3000/graphql') %>', {
25
+ method: 'post',
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ Authorization: '<%= ENV.fetch(
29
+ 'GRAPHQL_API_KEY',
30
+ 'http://localhost:3000/graphql'
31
+ ) %>'
32
+ },
33
+ body: JSON.stringify(graphQLParams)
34
+ })
35
+ .then((response) => response.json())
36
+ .catch(() => response.text())
37
+ ReactDOM.render(
38
+ React.createElement(GraphiQL, { fetcher: graphQLFetcher }),
39
+ document.getElementById('graphiql')
40
+ )
41
+ </script>
42
+ </body>
43
+ </html>
@@ -0,0 +1,3 @@
1
+ module RubyGraphiqlExplorer
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "lib/ruby_graphiql_explorer/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ruby_graphiql_explorer"
5
+ spec.version = RubyGraphiqlExplorer::VERSION
6
+ spec.authors = ["Gaurav Tiwari"]
7
+ spec.email = ["gaurav@gauravtiwari.co.uk"]
8
+
9
+ spec.summary = "Minimal mountable API graphiql explorer"
10
+ spec.description = "Minimal mountable API graphiql explorer"
11
+ spec.homepage = "https://github.com/gauravtiwari/ruby_graphiql_explorer"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/gauravtiwari/ruby_graphiql_explorer"
18
+ spec.metadata["changelog_uri"] = "https://github.com/gauravtiwari/ruby_graphiql_explorer"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "rack-app"
30
+ spec.add_dependency "rack-app-front_end"
31
+
32
+ spec.add_development_dependency "rubocop"
33
+ spec.add_development_dependency "rubocop-performance"
34
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_graphiql_explorer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gaurav Tiwari
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack-app
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
+ - !ruby/object:Gem::Dependency
28
+ name: rack-app-front_end
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-performance
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Minimal mountable API graphiql explorer
70
+ email:
71
+ - gaurav@gauravtiwari.co.uk
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".github/workflows/ci.yml"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".rubocop.yml"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE
84
+ - README.md
85
+ - Rakefile
86
+ - lib/ruby_graphiql_explorer.rb
87
+ - lib/ruby_graphiql_explorer/index.html.erb
88
+ - lib/ruby_graphiql_explorer/version.rb
89
+ - ruby_graphiql_explorer.gemspec
90
+ homepage: https://github.com/gauravtiwari/ruby_graphiql_explorer
91
+ licenses: []
92
+ metadata:
93
+ allowed_push_host: https://rubygems.org/
94
+ homepage_uri: https://github.com/gauravtiwari/ruby_graphiql_explorer
95
+ source_code_uri: https://github.com/gauravtiwari/ruby_graphiql_explorer
96
+ changelog_uri: https://github.com/gauravtiwari/ruby_graphiql_explorer
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.3.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.0.3
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Minimal mountable API graphiql explorer
116
+ test_files: []