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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a70268c20f6bf31cde24253f43e02b3f614866775ce0c68a2a3b95d529a1390
4
- data.tar.gz: d751aa523f340cf9f093a2aad4c6a2978742b4c6d3aa72b089546b9c6d88f2fb
3
+ metadata.gz: 2bd3c69c43a62b6083f458743383985f89c784bb091ee53e2e26942ee0ea5c0f
4
+ data.tar.gz: 22adc80d5c08d3eabe53fab4a6dbcf06207d01ca518f1e269ef496cc1809146f
5
5
  SHA512:
6
- metadata.gz: 62f486ccb3e873e9e70abf49f44a1a2ec12a1c852e854afdd56c8c7c861540567e8fb6ff96242ca5f01b92c1d171f0fb589fd8b1985cb33ea0336ba848e5262d
7
- data.tar.gz: d0caecb988cc386730cdd76bcdd6f4d79307eee636bf5e65c61b30013cc0b2be1d945fd830be046b5485476742b4c93bd12e44225b5134a320a4f3cbf9d66a8f
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 License](https://opensource.org/licenses/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
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/grate'
3
+ require 'grate'
4
4
  Grate::CLI.start(ARGV)
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
@@ -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__, "..", "..", 'templates')
22
+ templates_dir = File.join(__dir__, '..', '..', 'templates')
22
23
  Find.find(templates_dir) do |file|
23
24
  case File.extname(file)
24
- when ".tt"
25
- template(file, File.join(Dir.pwd, name, to_relative(file).gsub(".tt", "")))
26
- when ".dot"
27
- template(file, File.join(Dir.pwd, name, ".#{to_relative(file).chomp(".dot")}"))
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(Dir.pwd, name, to_relative(file)))
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("_", "-").underscore
47
+ name.gsub('_', '-').underscore
41
48
  end
42
49
  def classify(name)
43
- name.gsub("-", "_").camelize
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
- `rackup` if FileTest.exist?(File.join(Dir.pwd, 'config.ru'))
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
@@ -1,3 +1,3 @@
1
1
  module Grate
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,29 +1,3 @@
1
- require 'dotenv/load'
2
- require 'json'
3
- require 'sequel'
4
- require 'graphql'
5
- require 'grate'
1
+ require_relative './config/application'
6
2
 
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 <%= @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.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: