runways 0.1.5 → 0.1.6
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 +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +12 -4
- data/lib/runways/dependencies.rb +12 -0
- data/lib/runways/generators/app_structure_generator.rb +4 -7
- data/lib/runways/generators/templates/application_config.tt +18 -0
- data/lib/runways/generators/templates/db_rake.tt +3 -2
- data/lib/runways/generators/templates/gemfile.tt +5 -1
- data/lib/runways/generators/templates/protobuf_rake.tt +4 -0
- data/lib/runways/generators/templates/server.tt +2 -1
- data/lib/runways/generators/templates/service.tt +1 -11
- data/lib/runways/version.rb +1 -1
- data/lib/runways.rb +3 -1
- metadata +4 -3
- data/lib/runways/generators/templates/models.tt +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e982aaecae5159992f07d2a5edbc6be3c37d9ca02658cfd0077f8d05eccc7e63
|
4
|
+
data.tar.gz: 70535c84bcdad8ef21a0c9c950119b784b7420e786229ecf1fb90b5aaecb077c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10d215260565f79d4e378facdac4c6a63b409553f109a0a53f689be57bd48bd3d0f2084e5ddcfca669831b9c54bc2034285ef7fc772095928787fd2c3b8c76d3
|
7
|
+
data.tar.gz: 5725e891dc785f52d2ac395f08b10b13556749b99423eedf5bc36acb1b2a7d569dc7cd368f8711b596fb5d5bdd289cd202a15fc025dea6c7c454cea2d585b358
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
runways (0.1.
|
4
|
+
runways (0.1.6)
|
5
5
|
activerecord (~> 5.2)
|
6
6
|
grpc (~> 1.16)
|
7
7
|
grpc-tools (~> 1.16)
|
@@ -23,10 +23,10 @@ GEM
|
|
23
23
|
tzinfo (~> 1.1)
|
24
24
|
arel (9.0.0)
|
25
25
|
concurrent-ruby (1.1.3)
|
26
|
-
google-protobuf (3.6.1
|
26
|
+
google-protobuf (3.6.1)
|
27
27
|
googleapis-common-protos-types (1.0.2)
|
28
28
|
google-protobuf (~> 3.0)
|
29
|
-
grpc (1.16.0
|
29
|
+
grpc (1.16.0)
|
30
30
|
google-protobuf (~> 3.1)
|
31
31
|
googleapis-common-protos-types (~> 1.0.0)
|
32
32
|
grpc-tools (1.16.0)
|
data/README.md
CHANGED
@@ -6,16 +6,24 @@ Runways is a gRPC based ruby application. It will setup the basic project struct
|
|
6
6
|
|
7
7
|
Install Runways at the command prompt:
|
8
8
|
|
9
|
-
|
9
|
+
$ gem install runways
|
10
10
|
|
11
11
|
Create a new runways application:
|
12
12
|
|
13
|
-
|
13
|
+
$ runways hello
|
14
14
|
|
15
15
|
Run the following rake task to update protobuf files:
|
16
|
+
|
16
17
|
```ruby
|
17
18
|
rake protobuf_files:update
|
18
19
|
```
|
20
|
+
|
21
|
+
Run the following command to start the server, the server will reload if any file is changed
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
APP_ENV=development rerun -- ruby SERVER_FILE.rb
|
25
|
+
```
|
26
|
+
|
19
27
|
## Development
|
20
28
|
|
21
29
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -42,9 +50,9 @@ Everyone interacting in the Runways project’s codebases, issue trackers, chat
|
|
42
50
|
- [ ] Create runways controller
|
43
51
|
- [ ] Refactor generator code
|
44
52
|
- [ ] Refactor code to generate protobuf files when the application is initialized
|
45
|
-
- [
|
53
|
+
- [x] Handle loading the server without DbConfig setup
|
46
54
|
- [ ] Handle DbConfig in the ActiveRecord style
|
47
55
|
- [ ] Modify rake task to replace `require` with `require_relative` in the services pb file
|
48
|
-
- [
|
56
|
+
- [x] Handle file loading like how rails handles it
|
49
57
|
- [ ] Accept package name from command line
|
50
58
|
- [ ] Don't hard code port
|
@@ -54,13 +54,6 @@ class AppStructure < Thor::Group
|
|
54
54
|
)
|
55
55
|
end
|
56
56
|
|
57
|
-
def generate_models
|
58
|
-
template(
|
59
|
-
"templates/models.tt",
|
60
|
-
"#{name}/app/models.rb"
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
57
|
def generate_service_file
|
65
58
|
template(
|
66
59
|
"templates/service.tt",
|
@@ -87,6 +80,10 @@ class AppStructure < Thor::Group
|
|
87
80
|
template("templates/test_client.tt", "#{name}/test/test_client.rb")
|
88
81
|
end
|
89
82
|
|
83
|
+
def generate_application_file
|
84
|
+
template("templates/application_config.tt", "#{name}/config/application.rb")
|
85
|
+
end
|
86
|
+
|
90
87
|
def run_protoc_cmd
|
91
88
|
inside(name) do
|
92
89
|
run ("grpc_tools_ruby_protoc -I proto --ruby_out=lib/protos --grpc_out=lib/protos proto/#{name.underscore}.proto")
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# setting load path
|
2
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "app", "models")
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), ".")
|
4
|
+
|
5
|
+
# loading required gems
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
Bundler.require(:default)
|
9
|
+
|
10
|
+
# setting database connection
|
11
|
+
require 'application_record'
|
12
|
+
require 'db_config'
|
13
|
+
ActiveRecord::Base.establish_connection(
|
14
|
+
DbConfig.config
|
15
|
+
)
|
16
|
+
|
17
|
+
# requiring protobuf files
|
18
|
+
require './lib/protos/<%= name.underscore %>_services_pb'
|
@@ -40,8 +40,9 @@ namespace :db do
|
|
40
40
|
|
41
41
|
desc 'Migrate the database'
|
42
42
|
task :migrate do
|
43
|
-
|
44
|
-
|
43
|
+
establish_connection
|
44
|
+
ActiveRecord::MigrationContext.new('db/migrate').migrate
|
45
|
+
|
45
46
|
Rake::Task['db:update_schema'].execute
|
46
47
|
puts 'Database migrated.'
|
47
48
|
end
|
@@ -3,5 +3,9 @@ namespace :protobuf_files do
|
|
3
3
|
task :update do
|
4
4
|
lang = ARGV[1] || 'ruby'
|
5
5
|
`grpc_tools_ruby_protoc -I proto --ruby_out=lib/protos --grpc_out=lib/protos proto/<%= name.underscore %>.proto`
|
6
|
+
pb_path = "./lib/protos/<%= name.underscore %>_services_pb.rb"
|
7
|
+
lines = File.readlines(pb_path)
|
8
|
+
lines[4] = "require_relative '<%= name.underscore %>_pb'\n"
|
9
|
+
File.open(pb_path, 'w') { |f| f.write(lines.join) }
|
6
10
|
end
|
7
11
|
end
|
@@ -1,14 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler/setup'
|
3
|
-
require './config/db_config'
|
4
|
-
|
5
|
-
Bundler.require(:default)
|
6
|
-
|
7
|
-
ActiveRecord::Base.establish_connection(
|
8
|
-
DbConfig.config
|
9
|
-
)
|
10
|
-
|
11
|
-
require './lib/protos/<%= name.underscore %>_services_pb'
|
1
|
+
require './config/application'
|
12
2
|
|
13
3
|
class <%= name.camelcase %>Service < <%= name.camelcase %>::<%= name.camelcase %>Service::Service
|
14
4
|
def hello(request, _unused_call)
|
data/lib/runways/version.rb
CHANGED
data/lib/runways.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runways
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NG
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,12 +115,13 @@ files:
|
|
115
115
|
- bin/setup
|
116
116
|
- exe/runways
|
117
117
|
- lib/runways.rb
|
118
|
+
- lib/runways/dependencies.rb
|
118
119
|
- lib/runways/generators/app_structure_generator.rb
|
120
|
+
- lib/runways/generators/templates/application_config.tt
|
119
121
|
- lib/runways/generators/templates/application_record.tt
|
120
122
|
- lib/runways/generators/templates/db_config.tt
|
121
123
|
- lib/runways/generators/templates/db_rake.tt
|
122
124
|
- lib/runways/generators/templates/gemfile.tt
|
123
|
-
- lib/runways/generators/templates/models.tt
|
124
125
|
- lib/runways/generators/templates/proto.tt
|
125
126
|
- lib/runways/generators/templates/protobuf_rake.tt
|
126
127
|
- lib/runways/generators/templates/rakefile.tt
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require './config/db_config'
|
3
|
-
require './app/models/application_record.rb'
|
4
|
-
|
5
|
-
ActiveRecord::Base.establish_connection(
|
6
|
-
DbConfig.config
|
7
|
-
)
|
8
|
-
|
9
|
-
(
|
10
|
-
Dir[File.expand_path './app/models/*.rb'] -
|
11
|
-
Dir[File.expand_path './app/models/application_record.rb']
|
12
|
-
).each do |file|
|
13
|
-
require file
|
14
|
-
end
|