ella 0.1.2
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 +7 -0
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -0
- data/ella-0.1.0.gem +0 -0
- data/ella.gemspec +26 -0
- data/exe/ella +14 -0
- data/lib/ella.rb +45 -0
- data/lib/ella/cli.rb +114 -0
- data/lib/ella/controller.rb +36 -0
- data/lib/ella/generator.rb +42 -0
- data/lib/ella/generator/config_generator.rb +16 -0
- data/lib/ella/generator/controller_generator.rb +34 -0
- data/lib/ella/generator/destroyer.rb +44 -0
- data/lib/ella/generator/gemfile_generator.rb +15 -0
- data/lib/ella/generator/model_generator.rb +27 -0
- data/lib/ella/generator/project_generator.rb +88 -0
- data/lib/ella/generator/rackfile_generator.rb +76 -0
- data/lib/ella/generator/view_generator.rb +42 -0
- data/lib/ella/log.rb +70 -0
- data/lib/ella/model.rb +0 -0
- data/lib/ella/name_formatter.rb +32 -0
- data/lib/ella/pipeline.rb +99 -0
- data/lib/ella/reloader.rb +430 -0
- data/lib/ella/server.rb +107 -0
- data/lib/ella/template.rb +46 -0
- data/lib/ella/test.rb +9 -0
- data/lib/ella/version.rb +3 -0
- data/lib/ella/view.rb +0 -0
- data/templates/Gemfile +12 -0
- data/templates/configs/css.rb +20 -0
- data/templates/configs/js.rb +19 -0
- data/templates/configs/puma.rb +5 -0
- data/templates/controller +9 -0
- data/templates/controllers/root.rb +7 -0
- data/templates/main.rb +8 -0
- data/templates/model +6 -0
- data/templates/test +22 -0
- data/templates/views/layout.erb +18 -0
- data/templates/views/root/index.erb +3 -0
- data/version.txt +1 -0
- metadata +94 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 69b651c073b90ba525900d545f69fc444d33e373921c50e43fe276e37cc3e0f6
|
|
4
|
+
data.tar.gz: 0625fcaf0b4800b3bf016c733443395bf0f1aba5155a62cf14f7274c31bcc5e6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ba92e4f9896b93c7e96bdb6151e2f92c1e2bc51d2417ae7ba010d49a2a3f2ed05301119d0f3852a223efb462bc1adfc0e83fdb939fcbff4c77e53a8e89ec4d73
|
|
7
|
+
data.tar.gz: 1d49e9b5e025287b6a3cfd86fdfa9ddfc90b9dfec0b5247d946309dddfcfdf063e15b89c39f3d40719336e8a750a38398e0055c59eee13b9a36812db8325f855
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at kyle@kylechur.ch. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: https://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
colorize (0.8.1)
|
|
5
|
+
diff-lcs (1.4.4)
|
|
6
|
+
ffi (1.13.1)
|
|
7
|
+
listen (3.3.1)
|
|
8
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
9
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
10
|
+
mustermann (1.1.1)
|
|
11
|
+
ruby2_keywords (~> 0.0.1)
|
|
12
|
+
nio4r (2.5.4)
|
|
13
|
+
puma (5.0.4)
|
|
14
|
+
nio4r (~> 2.0)
|
|
15
|
+
rack (2.2.3)
|
|
16
|
+
rack-protection (2.1.0)
|
|
17
|
+
rack
|
|
18
|
+
rb-fsevent (0.10.4)
|
|
19
|
+
rb-inotify (0.10.1)
|
|
20
|
+
ffi (~> 1.0)
|
|
21
|
+
rspec (3.10.0)
|
|
22
|
+
rspec-core (~> 3.10.0)
|
|
23
|
+
rspec-expectations (~> 3.10.0)
|
|
24
|
+
rspec-mocks (~> 3.10.0)
|
|
25
|
+
rspec-core (3.10.0)
|
|
26
|
+
rspec-support (~> 3.10.0)
|
|
27
|
+
rspec-expectations (3.10.0)
|
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
29
|
+
rspec-support (~> 3.10.0)
|
|
30
|
+
rspec-mocks (3.10.0)
|
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
32
|
+
rspec-support (~> 3.10.0)
|
|
33
|
+
rspec-support (3.10.0)
|
|
34
|
+
ruby2_keywords (0.0.2)
|
|
35
|
+
sinatra (2.1.0)
|
|
36
|
+
mustermann (~> 1.0)
|
|
37
|
+
rack (~> 2.2)
|
|
38
|
+
rack-protection (= 2.1.0)
|
|
39
|
+
tilt (~> 2.0)
|
|
40
|
+
tilt (2.0.10)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
colorize (~> 0.8)
|
|
47
|
+
listen (~> 3.3)
|
|
48
|
+
puma (~> 5.0)
|
|
49
|
+
rspec (~> 3.1)
|
|
50
|
+
sinatra (~> 2.1)
|
|
51
|
+
|
|
52
|
+
RUBY VERSION
|
|
53
|
+
ruby 2.7.2p137
|
|
54
|
+
|
|
55
|
+
BUNDLED WITH
|
|
56
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Kyle Church
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Ella
|
|
2
|
+
|
|
3
|
+
Ella is a backend web framework using [Ruby](https://www.ruby-lang.org/en/), [Sinatra](http://sinatrarb.com/), [Puma](https://puma.io/), and [Rack](https://github.com/rack/rack). The basic goal is to have some of the basic conveniences of RoR, but cleaner, smaller, more flexible, and with minimal depencies.
|
|
4
|
+
|
|
5
|
+
Ella is still in early beta, so there are still a few things to work out!
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
* [Ella](#markdown-header-ella)
|
|
10
|
+
* [Table of Contents](#markdown-header-table-of-contents)
|
|
11
|
+
* [Hello World - Simple](#markdown-header-hello-world)
|
|
12
|
+
* [Hello World - Build a Blog](#markdown-build-a-blog)
|
|
13
|
+
* [Docs](#markdown-header-docs)
|
|
14
|
+
|
|
15
|
+
## Hello World
|
|
16
|
+
|
|
17
|
+
Doing this will give you a basic web app on port 7654:
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
ella new foo
|
|
21
|
+
cd foo
|
|
22
|
+
ella s
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Build A Blog
|
|
26
|
+
|
|
27
|
+
Just a simple blog to get an idea of how to use Ella:
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
ella new test-blog
|
|
31
|
+
cd test-blog
|
|
32
|
+
ella mvc user index show new destroy
|
|
33
|
+
ella mvc post index show new destroy
|
|
34
|
+
```
|
|
35
|
+
This will create the appropriate files and routes for models, views, and controllers. The actual implementation is up to you, the developer. While this is not as convenient as RoR, it is easier to learn and much more flexible. The primary inspiration for Ella was that very few real-world projects fit the exact RoR model, which requires a lot of ugly hacking to get around.
|
|
36
|
+
|
|
37
|
+
To pass things from a controller to a view, use instance variables:
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
# models/foo.rb
|
|
41
|
+
class Foo
|
|
42
|
+
def some_method
|
|
43
|
+
'Hello World!'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
# controllers/foo.rb
|
|
50
|
+
get '/foo/new' do
|
|
51
|
+
@this_foo = Foo.new
|
|
52
|
+
end
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# views/foo/new.erb
|
|
57
|
+
<p><%= @this_foo.some_method %></p>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Routing is handled by the controllers, and is taken directly from Sinatra. See the [Sinatra documentation](http://sinatrarb.com/intro.html) for more info.
|
|
61
|
+
|
|
62
|
+
Ella does not feature an ORM, but an plugin is in the works. In the meantime, try [Sequel](https://github.com/jeremyevans/sequel).
|
|
63
|
+
|
|
64
|
+
## Docs
|
|
65
|
+
|
|
66
|
+
To get help:
|
|
67
|
+
|
|
68
|
+
```shell
|
|
69
|
+
ella h
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To create a new project:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
ella new (project name)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To run a server:
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
ella s (optional: development/production) (optional: port number)
|
|
82
|
+
```
|
|
83
|
+
The port can also be set in config/puma.rb
|
|
84
|
+
|
|
85
|
+
To create a new controller:
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
ella c (controller name) (optional: route names)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To create a new model:
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
ella m (model name) (optional: route names)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
To create a new view subdirectory:
|
|
98
|
+
|
|
99
|
+
```shell
|
|
100
|
+
ella v (view name) (optional: route names)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
These can be combined, although a controller is necessary for routing. The following example will just create the controller and the view:
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
ella cv foo
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The css/js pipelines are configured in the "config/" directory, and the assets themselves can be found in the "assets/" directory. The assets config files have more detailed explanations in the comments.
|
|
110
|
+
|
|
111
|
+
Ella uses RSpec for tests. To run your test suite:
|
|
112
|
+
|
|
113
|
+
```shell
|
|
114
|
+
ella t
|
|
115
|
+
```
|
data/ella-0.1.0.gem
ADDED
|
File without changes
|
data/ella.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'lib/ella/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "ella"
|
|
5
|
+
spec.version = Ella::VERSION
|
|
6
|
+
spec.authors = ["Kyle Church"]
|
|
7
|
+
spec.email = ["kyle@kylechur.ch"]
|
|
8
|
+
spec.summary = %q{A convenience-focused mesoframework for web development.}
|
|
9
|
+
spec.description = %q{Ella is a web framework which seeks which seeks to find a balance between the simplicity of a microframework and the conveniences of a large, opinionated framework. Ella uses Sinatra for its controllers and routing.}
|
|
10
|
+
spec.homepage = "https://bitbucket.org/SurdEgg/ella/src/master/"
|
|
11
|
+
spec.license = "MIT"
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
|
13
|
+
|
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
15
|
+
spec.metadata["source_code_uri"] = "https://bitbucket.org/SurdEgg/ella/src/master/"
|
|
16
|
+
spec.metadata["changelog_uri"] = "https://bitbucket.org/SurdEgg/ella/src/master/CHANGELOG.md"
|
|
17
|
+
|
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
|
+
end
|
|
23
|
+
spec.bindir = "exe"
|
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
|
+
end
|
data/exe/ella
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift("#{__dir__}/../lib")
|
|
5
|
+
|
|
6
|
+
require 'ella'
|
|
7
|
+
|
|
8
|
+
# This is the executable that the user will use Ella through. Ideally, this
|
|
9
|
+
# should be completely replaceable without having to change ella.rb.
|
|
10
|
+
module Ella
|
|
11
|
+
version = File.open(File.join(__dir__, '../version.txt')).read.chomp
|
|
12
|
+
Log.yell("Ella v.#{version}")
|
|
13
|
+
CLI.new(ARGV)
|
|
14
|
+
end
|
data/lib/ella.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'listen'
|
|
4
|
+
|
|
5
|
+
require_relative 'ella/log'
|
|
6
|
+
require_relative 'ella/name_formatter'
|
|
7
|
+
|
|
8
|
+
require_relative 'ella/generator'
|
|
9
|
+
require_relative 'ella/generator/project_generator'
|
|
10
|
+
require_relative 'ella/generator/model_generator'
|
|
11
|
+
require_relative 'ella/generator/view_generator'
|
|
12
|
+
require_relative 'ella/generator/controller_generator'
|
|
13
|
+
require_relative 'ella/generator/gemfile_generator'
|
|
14
|
+
require_relative 'ella/generator/config_generator'
|
|
15
|
+
require_relative 'ella/generator/rackfile_generator'
|
|
16
|
+
require_relative 'ella/generator/destroyer'
|
|
17
|
+
|
|
18
|
+
require_relative 'ella/template'
|
|
19
|
+
require_relative 'ella/controller'
|
|
20
|
+
require_relative 'ella/test'
|
|
21
|
+
require_relative 'ella/server'
|
|
22
|
+
require_relative 'ella/cli'
|
|
23
|
+
|
|
24
|
+
# The main module for the Ella framework-framework.
|
|
25
|
+
module Ella
|
|
26
|
+
# This custom function exists because, ideally, the program will always abort
|
|
27
|
+
# with a logged message.
|
|
28
|
+
def self.abort(message)
|
|
29
|
+
Log.error(message)
|
|
30
|
+
Kernel.abort
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Most of what Ella does requires a valid Ella project, however, the user
|
|
34
|
+
# could potentially be in a subdirectory.
|
|
35
|
+
def self.find_root
|
|
36
|
+
until Dir.entries(Dir.pwd).include?('main.rb')
|
|
37
|
+
if Dir.pwd == '/'
|
|
38
|
+
puts 'Error! This is not a valid Ella project directory!'
|
|
39
|
+
exit!
|
|
40
|
+
else
|
|
41
|
+
Dir.chdir('..')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/ella/cli.rb
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ella
|
|
4
|
+
# The code for handling command-line arguments was getting complicated and
|
|
5
|
+
# ugly, so now it is a class.
|
|
6
|
+
# This is the least-integral part of Ella, and everything here should be
|
|
7
|
+
# replaceable without having to change the non-static classes.
|
|
8
|
+
class CLI
|
|
9
|
+
def initialize(args)
|
|
10
|
+
@args = args
|
|
11
|
+
@errors = []
|
|
12
|
+
|
|
13
|
+
try_no_args
|
|
14
|
+
try_help
|
|
15
|
+
try_new_project
|
|
16
|
+
try_mvc
|
|
17
|
+
try_destroy
|
|
18
|
+
try_server
|
|
19
|
+
try_test
|
|
20
|
+
|
|
21
|
+
exit_with_help('Ella does not understand your command.')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def try_no_args
|
|
27
|
+
return unless @args[0].nil?
|
|
28
|
+
|
|
29
|
+
exit_with_help('No arguments given.')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def try_help
|
|
33
|
+
return unless ['h', 'help', '?'].include?(@args[0])
|
|
34
|
+
|
|
35
|
+
exit_with_help(nil)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def try_new_project
|
|
39
|
+
return unless ['n', 'new'].include?(@args[0])
|
|
40
|
+
|
|
41
|
+
exit_with_help('You need to give your project a name.') if @args[1].nil?
|
|
42
|
+
ProjectGenerator.new(directory: @args[1]).run
|
|
43
|
+
exit
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def try_mvc
|
|
47
|
+
return unless @args[0] =~ /^[mvc]*$/
|
|
48
|
+
|
|
49
|
+
ModelGenerator.new(directory: @args[1]).run if @args[0] =~ /m/
|
|
50
|
+
ViewGenerator.new(directory: @args[1], files: @args[2..-1]).run if @args[0] =~ /v/
|
|
51
|
+
ControllerGenerator.new(directory: @args[1], files: @args[2..-1]).run if @args[0] =~ /c/
|
|
52
|
+
exit
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def try_destroy
|
|
56
|
+
return unless ['d', 'destroy'].include?(@args[0])
|
|
57
|
+
|
|
58
|
+
Destroyer.new(directory: @args[1]).run
|
|
59
|
+
exit
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def try_server
|
|
63
|
+
return unless ['s', 'server', 'r', 'run'].include?(@args[0])
|
|
64
|
+
|
|
65
|
+
Server.new(mode: @args[1] || 'development', port: @args[2]).run
|
|
66
|
+
exit
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def try_test
|
|
70
|
+
return unless ['t', 'test'].include?(@args[0])
|
|
71
|
+
|
|
72
|
+
Test.run
|
|
73
|
+
exit
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def exit_with_help(message)
|
|
77
|
+
Log.error(message) if message
|
|
78
|
+
print_help
|
|
79
|
+
exit
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def print_help
|
|
83
|
+
puts <<~HELP
|
|
84
|
+
-------------------
|
|
85
|
+
| Ella - Help |
|
|
86
|
+
-------------------
|
|
87
|
+
|
|
88
|
+
To create a new project:
|
|
89
|
+
> ella new (project name)
|
|
90
|
+
|
|
91
|
+
To run a server:
|
|
92
|
+
> ella s
|
|
93
|
+
|
|
94
|
+
To create a new controller:
|
|
95
|
+
> ella c (controller name)
|
|
96
|
+
|
|
97
|
+
To create a new model:
|
|
98
|
+
> ella m (model name)
|
|
99
|
+
|
|
100
|
+
To create a new view subdirectory:
|
|
101
|
+
> ella v (view name)
|
|
102
|
+
|
|
103
|
+
To create a view in a subdirectory:
|
|
104
|
+
> ella v foo bar # (saves to views/foo/bar.erb)
|
|
105
|
+
|
|
106
|
+
The model, view, and controller commands can be combined:
|
|
107
|
+
> ella mvc blog_post
|
|
108
|
+
|
|
109
|
+
To run tests:
|
|
110
|
+
> ella t
|
|
111
|
+
HELP
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|