graphtown 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f47657af97266ba1dee3c38eab5a831ad463dbcefaa9a08b9e0452817ad2a89
4
+ data.tar.gz: e7b04fc544431cb93fa8ec4b816e643556156287c299362906fc73fe45e3976a
5
+ SHA512:
6
+ metadata.gz: 9eda28d3c45ae087b5be37a390e5a02a24e7c975c9c2f0d327fd0cadea2f6d60930cf908d5bb0581bee7c96798c2e15db6405a53636556b477253be61797d202
7
+ data.tar.gz: b6bc01538472d9c463930e24d7ff797ee09d028f3b3df65ce7bf6d12d1dcb3df54e510f0127feb979255c731204843e5ab5e1f4db9020ce4b3f458eed0bd89cb
@@ -0,0 +1,38 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ .bundle
19
+ .ruby-version
20
+
21
+ # Node
22
+ node_modules
23
+ .npm
24
+ .node_repl_history
25
+
26
+ # Yarn
27
+ yarn-error.log
28
+ yarn-debug.log*
29
+ .pnp/
30
+ .pnp.js
31
+
32
+ # Yarn Integrity file
33
+ .yarn-integrity
34
+
35
+ spec/dest
36
+ .bridgetown-metadata
37
+ .bridgetown-cache
38
+ .bridgetown-webpack
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,22 @@
1
+ require: rubocop-bridgetown
2
+
3
+ inherit_gem:
4
+ rubocop-bridgetown: .rubocop.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ Include:
9
+ - lib/**/*.rb
10
+
11
+ Exclude:
12
+ - .gitignore
13
+ - .rspec
14
+ - .rubocop.yml
15
+
16
+ - Gemfile.lock
17
+ - CHANGELOG.md
18
+ - LICENSE.txt
19
+ - README.md
20
+
21
+ - script/**/*
22
+ - vendor/**/*
@@ -0,0 +1,7 @@
1
+ # master
2
+
3
+ * Use this file to keep track of plugin updates
4
+
5
+ # 0.1.0 / 2020-05-01
6
+
7
+ * First version
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present Jared White
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Graphtown
2
+
3
+ Easily consume GraphQL APIs for your Bridgetown website using a tidy Builder DSL on top of the [Graphlient](http://github.com/ashkan18/graphlient) gem.
4
+
5
+ ## Installation
6
+
7
+ Run this command to add this plugin to your site's Gemfile:
8
+
9
+ ```shell
10
+ $ bundle add graphtown -g bridgetown_plugins
11
+ ```
12
+
13
+ ---
14
+
15
+ # Documentation coming soon…
16
+
17
+ ## Usage
18
+
19
+ The plugin will…
20
+
21
+ ### Optional configuration options
22
+
23
+ The plugin will automatically use any of the following metadata variables if they are present in your site's `_data/site_metadata.yml` file.
24
+
25
+
26
+
27
+ ## Testing
28
+
29
+ * Run `bundle exec rspec` to run the test suite
30
+ * Or run `script/cibuild` to validate with Rubocop and test with rspec together.
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it (https://github.com/whitefusionhq/graphtown/fork)
35
+ 2. Clone the fork using `git clone` to your local development machine.
36
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 5. Push to the branch (`git push origin my-new-feature`)
39
+ 6. Create a new Pull Request
@@ -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,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/graphtown/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "graphtown"
7
+ spec.version = Graphtown::VERSION
8
+ spec.author = "Jared White"
9
+ spec.email = "jared@whitefusion.io"
10
+ spec.summary = "Easily consume GraphQL APIs for your Bridgetown website using a tidy Builder DSL on top of the Graphlient gem."
11
+ spec.homepage = "https://github.com/whitefusionhq/graphtown"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
15
+ spec.test_files = spec.files.grep(%r!^spec/!)
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.required_ruby_version = ">= 2.5.0"
19
+
20
+ spec.add_dependency "bridgetown", ">= 0.15", "< 2.0"
21
+ spec.add_dependency "graphlient", "~> 0.4"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "nokogiri", "~> 1.6"
25
+ spec.add_development_dependency "rack-test", "~> 1.1"
26
+ spec.add_development_dependency "rake", "~> 12.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
29
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridgetown"
4
+ require "graphtown/query_builder"
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "graphlient"
4
+ require "active_support/concern"
5
+
6
+ module Graphtown
7
+ module QueryBuilder
8
+ class Queries < OpenStruct; end
9
+
10
+ extend ActiveSupport::Concern
11
+
12
+ class_methods do
13
+ attr_accessor :graphql_queries
14
+
15
+ def graphql(graph_name, &block)
16
+ self.graphql_queries ||= Queries.new
17
+ graphql_queries.send("#{graph_name}=", block)
18
+ end
19
+ end
20
+
21
+ def queries
22
+ return self.class.graphql_queries if @_executed_queries
23
+
24
+ client = graphql_client
25
+ self.class.graphql_queries.each_pair do |graph_name, block|
26
+ graph_dsl = Graphlient::Query.new(&block)
27
+
28
+ query_variables = if respond_to?("variables_for_#{graph_name}")
29
+ send("variables_for_#{graph_name}")
30
+ end
31
+
32
+ self.class.graphql_queries.send(
33
+ "#{graph_name}=",
34
+ client.execute(graph_dsl.to_s, query_variables).data.send(graph_name)
35
+ )
36
+ end
37
+
38
+ @_executed_queries = true
39
+ self.class.graphql_queries
40
+ end
41
+
42
+ def graphql_client
43
+ raise "Please add graphql_endpoint to your config file" unless config[:graphql_endpoint]
44
+
45
+ Graphlient::Client.new(graphql_endpoint) do |client|
46
+ configure_graphql_client(client)
47
+ end
48
+ end
49
+
50
+ # override in concrete class if need be
51
+ def graphql_endpoint
52
+ raise "Please add graphql_endpoint to your config file" unless config[:graphql_endpoint]
53
+
54
+ config[:graphql_endpoint]
55
+ end
56
+
57
+ # override in concrete class if need be
58
+ def configure_graphql_client(client); end
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Graphtown
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "graphtown",
3
+ "version": "0.1.0",
4
+ "main": "frontend/javascript/index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/username/graphtown.git"
8
+ },
9
+ "author": "Bridgetown Maintainers <maintainers@bridgetownrb.com>",
10
+ "homepage": "https://www.bridgetownrb.com",
11
+ "license": "MIT",
12
+ "private": false,
13
+ "files": [
14
+ "frontend"
15
+ ]
16
+ }
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphtown
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jared White
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bridgetown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.15'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.15'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: graphlient
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.4'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.4'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: nokogiri
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.6'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.6'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rack-test
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '12.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '12.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-bridgetown
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '0.2'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.2'
131
+ description:
132
+ email: jared@whitefusion.io
133
+ executables: []
134
+ extensions: []
135
+ extra_rdoc_files: []
136
+ files:
137
+ - ".gitignore"
138
+ - ".rspec"
139
+ - ".rubocop.yml"
140
+ - CHANGELOG.md
141
+ - Gemfile
142
+ - LICENSE.txt
143
+ - README.md
144
+ - Rakefile
145
+ - graphtown.gemspec
146
+ - lib/graphtown.rb
147
+ - lib/graphtown/query_builder.rb
148
+ - lib/graphtown/version.rb
149
+ - package.json
150
+ homepage: https://github.com/whitefusionhq/graphtown
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 2.5.0
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.0.6
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Easily consume GraphQL APIs for your Bridgetown website using a tidy Builder
173
+ DSL on top of the Graphlient gem.
174
+ test_files: []