go-on-rails 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/gor/gor_generator.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f78729f6b807de4949b5bfff9f06dde9854808
|
4
|
+
data.tar.gz: 40b116bfcb24d9e7a3d378827adc6734ce3fa673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ab347d8b5206dbd0ddd711dbe696ce39f56bf61b5ff8d3d37b31d48edc93931beecc10587f73754a69219008078fb804016adddf6f584e746f658185207311d
|
7
|
+
data.tar.gz: c095725253a77157d9e19b4327d55ea72f3874243a703fec2ac88b42e5e7225bcf06821dfe9ecd79fbb9983e39b404928157d4f1bc560d725d05585baf066f9f
|
data/README.md
CHANGED
@@ -5,12 +5,7 @@ class GorGenerator < Rails::Generators::Base
|
|
5
5
|
class_option :only_models, type: :boolean, default: false, aliases: '-o', description: "only generate models"
|
6
6
|
|
7
7
|
def generate_gor
|
8
|
-
env_names =
|
9
|
-
unless env_names.include? env_name
|
10
|
-
printf("Invalid env argument: Not any of %p\n\n", env_names)
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
|
8
|
+
env_names = ActiveRecord::Base.configurations.keys
|
14
9
|
rails_env = case env_name
|
15
10
|
when "dev"
|
16
11
|
"development"
|
@@ -20,6 +15,11 @@ class GorGenerator < Rails::Generators::Base
|
|
20
15
|
env_name
|
21
16
|
end
|
22
17
|
|
18
|
+
unless env_names.include? rails_env
|
19
|
+
printf("Invalid env argument \"%s\": Not in the available list %p\n\n", rails_env, env_names)
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
23
|
@models = options[:models]
|
24
24
|
if @models.empty?
|
25
25
|
@models = get_all_models "app/models"
|
@@ -31,8 +31,9 @@ class GorGenerator < Rails::Generators::Base
|
|
31
31
|
|
32
32
|
# read the database configuration
|
33
33
|
@db_config = {}
|
34
|
-
|
34
|
+
read_database_config(rails_env)
|
35
35
|
|
36
|
+
# iterate the models to generate Go codes
|
36
37
|
@models.each do |m|
|
37
38
|
begin
|
38
39
|
klass = m.split('::').inject(Object) { |kls, part| kls.const_get(part) }
|
@@ -47,13 +48,12 @@ class GorGenerator < Rails::Generators::Base
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
# generate program for database connection
|
52
|
+
template "db.go.erb", "go_app/models/db.go"
|
53
|
+
|
50
54
|
unless options[:only_models]
|
51
55
|
# generate the main.go
|
52
56
|
copy_file "main.go", "go_app/main.go"
|
53
|
-
|
54
|
-
# generate program for database connection
|
55
|
-
template "db.go.erb", "go_app/models/db.go"
|
56
|
-
|
57
57
|
# generate the controllers and views dir
|
58
58
|
template "home_controller.go.erb", "go_app/controllers/home_controller.go"
|
59
59
|
copy_file "index.tmpl", "go_app/views/index.tmpl"
|
@@ -75,7 +75,7 @@ class GorGenerator < Rails::Generators::Base
|
|
75
75
|
end.map { |m| m.sub(/\.rb$/,'').camelize } - ["ApplicationRecord"]
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def read_database_config rails_env
|
79
79
|
db_conf = Rails.configuration.database_configuration[rails_env]
|
80
80
|
db_conf["host"] = "localhost" unless db_conf["host"]
|
81
81
|
case db_conf["adapter"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- B1nj0y
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Modeling, developing and testing your Golang app with your familiar Rails
|
14
14
|
tools like rails generate, db migration, console etc. It is more meant to help integrating
|