grate 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +5 -1
- data/bin/grate +1 -1
- data/grate.gemspec +4 -0
- data/lib/grate/new_project.rb +16 -9
- data/lib/grate/server.rb +4 -1
- data/lib/grate/version.rb +1 -1
- data/templates/config.ru.tt +2 -28
- data/templates/config/application.rb.tt +27 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd3c69c43a62b6083f458743383985f89c784bb091ee53e2e26942ee0ea5c0f
|
4
|
+
data.tar.gz: 22adc80d5c08d3eabe53fab4a6dbcf06207d01ca518f1e269ef496cc1809146f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fe0f19db52b195d68b7d22a607dc90bdfbf976fce0962e0a834046557c05901590ce1667665e5f90b3d432357ff13150182b5e5154103686a900f92276515a
|
7
|
+
data.tar.gz: e930269af35b2f659bb9fdabc4500e0e83afc3bedbbccb37aae3eb83dd32ea0b910d1424047e091fc2e5c376b556f39d3578fcf3e3570953a9a0b79e9aa2455c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All changes will be documented in this file
|
4
|
+
|
5
|
+
## [0.1.2]
|
6
|
+
### Added
|
7
|
+
- Added a `server` command to grate cli.
|
8
|
+
- Added a bin directory to locally run grate cli.
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Renamed `ProjectNameApplication` to just `Application` (to make
|
12
|
+
running server easier)
|
13
|
+
- Moved application to `config/application.rb`
|
14
|
+
|
15
|
+
## [0.1.1]
|
16
|
+
### Changed
|
17
|
+
- Fixed casing for initial project generation. Before, `snake-case`
|
18
|
+
names would generate an application called `Snake-caseApplication`,
|
19
|
+
which would break.
|
20
|
+
|
21
|
+
- Added a changelog (kinda meta, eh?)
|
22
|
+
|
23
|
+
|
24
|
+
## [0.1.0]
|
25
|
+
### Changed
|
26
|
+
Released first version. Super minimal, contains:
|
27
|
+
- A server via rack
|
28
|
+
- A basic interface to GraphQL Ruby
|
29
|
+
- One simple query DSL (`queryable_on`)
|
30
|
+
- A generator for new project
|
31
|
+
|
data/README.md
CHANGED
@@ -40,9 +40,13 @@ be a safe, welcoming space for collaboration, and contributors are
|
|
40
40
|
expected to adhere to the [Contributor
|
41
41
|
Covenant](http://contributor-covenant.org) code of conduct.
|
42
42
|
|
43
|
+
Please add any changes to the
|
44
|
+
[CHANGELOG](https://github.com/nicholaslyang/grate/blob/master/CHANGELOG.md).
|
45
|
+
|
43
46
|
## License
|
44
47
|
|
45
|
-
The gem is available as open source under the terms of the [MIT
|
48
|
+
The gem is available as open source under the terms of the [MIT
|
49
|
+
License](https://opensource.org/licenses/MIT).
|
46
50
|
|
47
51
|
## Code of Conduct
|
48
52
|
|
data/bin/grate
CHANGED
data/grate.gemspec
CHANGED
@@ -14,6 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://grate.github.io"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
+
spec.metadata = {
|
18
|
+
"changelog_uri" => "https://github.com/nicholaslyang/grate/blob/master/CHANGELOG.md",
|
19
|
+
}
|
20
|
+
|
17
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
22
|
f.match(%r{^(test|spec|features)/})
|
19
23
|
end
|
data/lib/grate/new_project.rb
CHANGED
@@ -13,34 +13,41 @@ module Grate
|
|
13
13
|
|
14
14
|
def create_directory
|
15
15
|
Dir.mkdir name
|
16
|
+
@project_dir = File.join(Dir.pwd, name)
|
16
17
|
end
|
17
18
|
|
18
19
|
def create_files
|
19
20
|
@camel_name = classify(name)
|
20
21
|
@snake_name = snake_case(name)
|
21
|
-
templates_dir = File.join(__dir__,
|
22
|
+
templates_dir = File.join(__dir__, '..', '..', 'templates')
|
22
23
|
Find.find(templates_dir) do |file|
|
23
24
|
case File.extname(file)
|
24
|
-
when
|
25
|
-
template(file, File.join(
|
26
|
-
when
|
27
|
-
template(file, File.join(
|
25
|
+
when '.tt'
|
26
|
+
template(file, File.join(@project_dir, to_relative(file).gsub('.tt', '')))
|
27
|
+
when '.dot'
|
28
|
+
template(file, File.join(@project_dir, ".#{to_relative(file).chomp('.dot')}"))
|
28
29
|
when /\.[A-Za-z]+/
|
29
|
-
template(file, File.join(
|
30
|
+
template(file, File.join(@project_dir, to_relative(file)))
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
def copy_bin
|
36
|
+
bin_dir = File.join(__dir__, '..', '..', 'bin')
|
37
|
+
|
38
|
+
FileUtils.copy_entry(bin_dir, File.join(@project_dir, 'bin'))
|
39
|
+
end
|
40
|
+
|
34
41
|
private
|
35
42
|
def to_relative(path)
|
36
|
-
path.gsub(/.*templates\//,
|
43
|
+
path.gsub(/.*templates\//, '')
|
37
44
|
end
|
38
45
|
|
39
46
|
def snake_case(name)
|
40
|
-
name.gsub(
|
47
|
+
name.gsub('_', '-').underscore
|
41
48
|
end
|
42
49
|
def classify(name)
|
43
|
-
name.gsub(
|
50
|
+
name.gsub('-', '_').camelize
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
data/lib/grate/server.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
require 'rack'
|
1
2
|
require 'pathname'
|
2
3
|
module Grate
|
3
4
|
class Server < Thor::Group
|
4
5
|
|
5
6
|
def run_server
|
6
|
-
|
7
|
+
app_file = File.join(Dir.pwd, 'config', 'application.rb')
|
8
|
+
require app_file if FileTest.exist?(app_file)
|
9
|
+
Rack::Handler::WEBrick.run Application.new
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/grate/version.rb
CHANGED
data/templates/config.ru.tt
CHANGED
@@ -1,29 +1,3 @@
|
|
1
|
-
|
2
|
-
require 'json'
|
3
|
-
require 'sequel'
|
4
|
-
require 'graphql'
|
5
|
-
require 'grate'
|
1
|
+
require_relative './config/application'
|
6
2
|
|
7
|
-
|
8
|
-
require 'active_support/inflector'
|
9
|
-
|
10
|
-
# Load the database first
|
11
|
-
require_relative './db/database'
|
12
|
-
|
13
|
-
# Then load all the abstract
|
14
|
-
require_relative './app/types/query_type'
|
15
|
-
require_relative './app/models/application_model'
|
16
|
-
require_relative './app/controllers/application_controller.rb'
|
17
|
-
require_relative './app/schema'
|
18
|
-
|
19
|
-
|
20
|
-
class <%= @camel_name %>Application
|
21
|
-
def call(env)
|
22
|
-
req = Rack::Request.new(env)
|
23
|
-
params = JSON.parse(req.body.read)
|
24
|
-
res = Schema.execute(params["query"])
|
25
|
-
['200', {'Content-Type' => 'text/html'}, [res.to_json]]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
run <%= @camel_name %>Application.new
|
3
|
+
run Application.new
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dotenv/load'
|
2
|
+
require 'json'
|
3
|
+
require 'sequel'
|
4
|
+
require 'graphql'
|
5
|
+
require 'grate'
|
6
|
+
|
7
|
+
# Ideally should move off this, but it's so damn useful
|
8
|
+
require 'active_support/inflector'
|
9
|
+
|
10
|
+
# Load the database first
|
11
|
+
require_relative '../db/database'
|
12
|
+
|
13
|
+
# Then load all the abstract
|
14
|
+
require_relative '../app/types/query_type'
|
15
|
+
require_relative '../app/models/application_model'
|
16
|
+
require_relative '../app/controllers/application_controller.rb'
|
17
|
+
require_relative '../app/schema'
|
18
|
+
|
19
|
+
|
20
|
+
class Application
|
21
|
+
def call(env)
|
22
|
+
req = Rack::Request.new(env)
|
23
|
+
params = JSON.parse(req.body.read)
|
24
|
+
res = Schema.execute(params["query"])
|
25
|
+
['200', {'Content-Type' => 'text/html'}, [res.to_json]]
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Yang
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- ".rspec"
|
180
180
|
- ".ruby-version"
|
181
181
|
- ".travis.yml"
|
182
|
+
- CHANGELOG.md
|
182
183
|
- CODE_OF_CONDUCT.md
|
183
184
|
- Gemfile
|
184
185
|
- LICENSE
|
@@ -198,6 +199,7 @@ files:
|
|
198
199
|
- templates/app/schema.rb.tt
|
199
200
|
- templates/app/types/query_type.rb.tt
|
200
201
|
- templates/config.ru.tt
|
202
|
+
- templates/config/application.rb.tt
|
201
203
|
- templates/config/database.yml.tt
|
202
204
|
- templates/db/database.rb.tt
|
203
205
|
- templates/db/development.db
|
@@ -207,7 +209,8 @@ files:
|
|
207
209
|
homepage: https://grate.github.io
|
208
210
|
licenses:
|
209
211
|
- MIT
|
210
|
-
metadata:
|
212
|
+
metadata:
|
213
|
+
changelog_uri: https://github.com/nicholaslyang/grate/blob/master/CHANGELOG.md
|
211
214
|
post_install_message:
|
212
215
|
rdoc_options: []
|
213
216
|
require_paths:
|