larator 0.1.0 → 0.2.1
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/README.md +4 -0
- data/lib/larator/cli.rb +11 -0
- data/lib/larator/generate.rb +15 -1
- data/lib/larator/generators/base.rb +48 -0
- data/lib/larator/generators/scaffold.rb +7 -7
- data/lib/larator/generators/templates/scaffold/default/controller.tt +2 -2
- data/lib/larator/generators/templates/scaffold/default/model.tt +2 -2
- data/lib/larator/templates/init.tt +8 -0
- data/lib/larator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b4aa118a4c2d86fe00e2c4ef6d00bd6b17de931
|
4
|
+
data.tar.gz: 06e58cfb4aae3dcd3b96eb83bfa9986cce03f3f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95acf3cd919fb685348809133f5e38ae9f28beaeed13a7b29d97ab176d8a9dacdfee6df1bf6ab5242b4aa45e525b8ac990ce30d86788aed1185eeffbab277b04
|
7
|
+
data.tar.gz: bdab5ba7a58ae75c95d0ce5242168060958b08a36e3a33deed535be8845f392271c8153eaa133857a585bbe3e72e2be103a76516a463328aadf38d3ba27f4337
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Larator
|
2
2
|
|
3
|
+
[](https://travis-ci.org/guiltry/larator)
|
4
|
+
[](http://badge.fury.io/rb/larator)
|
5
|
+
|
6
|
+
|
3
7
|
The main purpose of this generator are:
|
4
8
|
|
5
9
|
1. Give an idea to newcomers how to create a simple CRUD application
|
data/lib/larator/cli.rb
CHANGED
@@ -3,6 +3,17 @@ require "larator/generate"
|
|
3
3
|
|
4
4
|
module Larator
|
5
5
|
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
File.dirname(__FILE__) + "/templates"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "generate larator config file", "Generate "
|
13
|
+
def init
|
14
|
+
template("init.tt", ".larator.yml")
|
15
|
+
end
|
16
|
+
|
6
17
|
desc "generate GENERATOR", "Generate "
|
7
18
|
subcommand "generate", Larator::Generate
|
8
19
|
end
|
data/lib/larator/generate.rb
CHANGED
@@ -1,12 +1,26 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Larator
|
2
4
|
class Generate < Thor
|
3
5
|
|
4
6
|
desc "scaffold NAME", "Generate "
|
5
|
-
method_option :
|
7
|
+
method_option :controller_location, type: :string
|
8
|
+
method_option :controller_namespace, type: :string
|
9
|
+
method_option :model_location, type: :string
|
10
|
+
method_option :model_namespace, type: :string
|
11
|
+
method_option :view_location, type: :string
|
6
12
|
def scaffold(name)
|
7
13
|
require "larator/generators/scaffold"
|
8
14
|
Larator::Generators::Scaffold.start([name, options])
|
9
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def options
|
19
|
+
original_options = super
|
20
|
+
return original_options unless File.exists?(".larator.yml")
|
21
|
+
defaults = ::YAML::load_file(".larator.yml") || {}
|
22
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
23
|
+
end
|
10
24
|
end
|
11
25
|
end
|
12
26
|
|
@@ -40,6 +40,54 @@ module Larator
|
|
40
40
|
class_name.pluralize.underscore
|
41
41
|
end
|
42
42
|
|
43
|
+
#############
|
44
|
+
## OPTIONS ##
|
45
|
+
#############
|
46
|
+
|
47
|
+
# Controller #
|
48
|
+
|
49
|
+
# --controller-location=app/Http/Controllers/
|
50
|
+
def controller_location
|
51
|
+
folder_format(opt['controller_location']) || "app/Http/Controllers/"
|
52
|
+
end
|
53
|
+
|
54
|
+
# --controller-namespace=App\\Http\\Controllers
|
55
|
+
def controller_namespace
|
56
|
+
namespace_format(opt['controller_namespace']) || "App\\Http\\Controllers"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Model #
|
60
|
+
|
61
|
+
# --model-location=app/
|
62
|
+
def model_location
|
63
|
+
folder_format(opt['model_location']) || "app/"
|
64
|
+
end
|
65
|
+
|
66
|
+
# --model-namespace=App
|
67
|
+
def model_namespace
|
68
|
+
namespace_format(opt['model_namespace']) || "App"
|
69
|
+
end
|
70
|
+
|
71
|
+
# View #
|
72
|
+
|
73
|
+
# --model-location=App
|
74
|
+
def view_location
|
75
|
+
folder_format(opt['view_location']) || "resources/views/"
|
76
|
+
end
|
77
|
+
|
78
|
+
##########
|
79
|
+
## UTIL ##
|
80
|
+
##########
|
81
|
+
|
82
|
+
def folder_format(name)
|
83
|
+
return if name == nil
|
84
|
+
return name + '/'
|
85
|
+
end
|
86
|
+
|
87
|
+
def namespace_format(name)
|
88
|
+
return if name == nil
|
89
|
+
return name
|
90
|
+
end
|
43
91
|
end
|
44
92
|
end
|
45
93
|
end
|
@@ -5,15 +5,15 @@ module Larator
|
|
5
5
|
class Scaffold < Base
|
6
6
|
|
7
7
|
def controller
|
8
|
-
template("controller.tt", "
|
8
|
+
template("controller.tt", "#{controller_location}#{controller_class_name}Controller.php")
|
9
9
|
end
|
10
10
|
|
11
11
|
def views
|
12
|
-
template("views/index.tt", "
|
13
|
-
template("views/create.tt", "
|
14
|
-
template("views/show.tt", "
|
15
|
-
template("views/edit.tt", "
|
16
|
-
template("views/_form.tt", "
|
12
|
+
template("views/index.tt", "#{view_location}#{plular_table_name}/index.blade.php")
|
13
|
+
template("views/create.tt", "#{view_location}#{plular_table_name}/create.blade.php")
|
14
|
+
template("views/show.tt", "#{view_location}#{plular_table_name}/show.blade.php")
|
15
|
+
template("views/edit.tt", "#{view_location}#{plular_table_name}/edit.blade.php")
|
16
|
+
template("views/_form.tt", "#{view_location}#{plular_table_name}/_form.blade.php")
|
17
17
|
end
|
18
18
|
|
19
19
|
def request
|
@@ -21,7 +21,7 @@ module Larator
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def model
|
24
|
-
template("model.tt", "
|
24
|
+
template("model.tt", "#{model_location}#{model_class_name}.php")
|
25
25
|
end
|
26
26
|
|
27
27
|
def migration
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<?php
|
2
|
-
namespace
|
2
|
+
namespace <%= controller_namespace %>;
|
3
3
|
|
4
|
-
use
|
4
|
+
use <%= model_namespace %>\<%= model_class_name %>;
|
5
5
|
use App\Http\Requests\<%= model_class_name %>Request;
|
6
6
|
use App\Http\Controllers\Controller;
|
7
7
|
|
data/lib/larator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: larator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Budianto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/larator/generators/templates/scaffold/default/views/edit.tt
|
145
145
|
- lib/larator/generators/templates/scaffold/default/views/index.tt
|
146
146
|
- lib/larator/generators/templates/scaffold/default/views/show.tt
|
147
|
+
- lib/larator/templates/init.tt
|
147
148
|
- lib/larator/version.rb
|
148
149
|
homepage: https://guiltry.github.io/larator/
|
149
150
|
licenses:
|