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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8643600c0d33e46d69b23ab93f84ef082e908a830dc59ae34a0658366e9de4c
4
- data.tar.gz: 1d365e31477a4d5107f268ff85f886cfa02f2935dd84f599e4cf667b0909bf57
3
+ metadata.gz: e982aaecae5159992f07d2a5edbc6be3c37d9ca02658cfd0077f8d05eccc7e63
4
+ data.tar.gz: 70535c84bcdad8ef21a0c9c950119b784b7420e786229ecf1fb90b5aaecb077c
5
5
  SHA512:
6
- metadata.gz: 8b3bc75c7778c983af7f9549dd5344556e6a66d7771233e99de4406648698943011875a98f0e55b3cb56baa0a3ff9ef5fcae027aa9d4929a498de6d19475e75e
7
- data.tar.gz: b663acca7e013ab696f3259bbf8dcb8019acddea5f12e215f2f9fbc1d0d9b93770e83dc4f1f02ed3f51b9a9b196cae2ad9c2e9ad347e24920e2cdd34fbb72ae8
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.5)
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-universal-darwin)
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-universal-darwin)
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
- $ gem install runways
9
+ $ gem install runways
10
10
 
11
11
  Create a new runways application:
12
12
 
13
- $ runways hello
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
- - [ ] Handle loading the server without DbConfig setup
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
- - [ ] Handle file loading like how rails handles it
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
@@ -0,0 +1,12 @@
1
+ class Object
2
+ def self.const_missing(c)
3
+ return nil if @calling_const_missing
4
+
5
+ @calling_const_missing = true
6
+ require c.to_s.underscore
7
+ klass = Object.const_get(c)
8
+ @calling_const_missing = false
9
+
10
+ klass
11
+ end
12
+ end
@@ -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
- establish_connection
44
- ActiveRecord::Migrator.migrate('db/migrate/')
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
@@ -1,4 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'runways', '<%= Runways::VERSION %>'
4
- gem "sqlite3", "~> 1.3.6"
4
+ gem "sqlite3", "~> 1.3.6"
5
+
6
+ group :development do
7
+ gem 'rerun'
8
+ 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
@@ -2,7 +2,8 @@ require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require './lib/<%= name.underscore %>_service'
4
4
 
5
- Bundler.require(:default)
5
+ env = ENV['APP_ENV'] || 'development'
6
+ Bundler.require(:default, env)
6
7
 
7
8
  class <%= name.camelize %>Server
8
9
  class << self
@@ -1,14 +1,4 @@
1
- require 'rubygems'
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)
@@ -1,3 +1,3 @@
1
1
  module Runways
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/runways.rb CHANGED
@@ -1,6 +1,8 @@
1
- require "runways/version"
2
1
  require "active_record"
2
+
3
+ require "runways/version"
3
4
  require "runways/generators/app_structure_generator"
5
+ require "runways/dependencies"
4
6
 
5
7
  module Runways
6
8
  # Your code goes here...
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.5
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-16 00:00:00.000000000 Z
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