ginatra 3.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -15
- data/.travis.yml +7 -6
- data/CONTRIBUTING.md +30 -0
- data/Gemfile +1 -9
- data/LICENSE.txt +30 -0
- data/README.md +63 -114
- data/Rakefile +10 -12
- data/bin/ginatra +79 -63
- data/config.ru +35 -3
- data/ginatra.gemspec +29 -18
- data/lib/ginatra.rb +161 -148
- data/lib/ginatra/config.rb +18 -121
- data/lib/ginatra/errors.rb +10 -0
- data/lib/ginatra/helpers.rb +154 -139
- data/lib/ginatra/repo.rb +67 -82
- data/lib/ginatra/repo_list.rb +25 -18
- data/lib/ginatra/repo_stats.rb +93 -0
- data/lib/ginatra/version.rb +4 -0
- data/lib/git/webby.rb +292 -0
- data/lib/git/webby/extensions.rb +10 -0
- data/lib/git/webby/http_backend.rb +177 -0
- data/lib/sinatra/partials.rb +1 -1
- data/public/css/application.css +6 -0
- data/public/css/custom.css +57 -0
- data/public/css/lib/bootstrap-responsive.min.css +9 -0
- data/public/css/lib/bootstrap.min.css +9 -0
- data/public/css/lib/highlight.css +209 -0
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/img/spin.gif +0 -0
- data/public/js/application.js +5 -0
- data/public/js/custom.js +51 -0
- data/public/js/lib/bootstrap.min.js +6 -0
- data/public/js/lib/jquery.lazyload.min.js +2 -0
- data/public/js/lib/jquery.min.js +2 -0
- data/public/js/lib/jquery.pjax.js +739 -0
- data/repos/README.md +21 -8
- data/spec/ginatra/helpers_spec.rb +95 -0
- data/spec/ginatra/repo_list_spec.rb +66 -0
- data/spec/ginatra/repo_spec.rb +78 -0
- data/spec/ginatra/repo_stats_spec.rb +27 -0
- data/spec/ginatra_spec.rb +121 -0
- data/spec/spec_helper.rb +8 -17
- data/views/404.erb +18 -0
- data/views/500.erb +18 -0
- data/views/_footer.erb +7 -0
- data/views/_header.erb +12 -6
- data/views/_tree_nav.erb +53 -0
- data/views/atom.erb +32 -0
- data/views/blob.erb +27 -8
- data/views/commit.erb +95 -17
- data/views/empty_repo.erb +10 -0
- data/views/index.erb +27 -11
- data/views/layout.erb +16 -20
- data/views/log.erb +74 -54
- data/views/stats.erb +89 -0
- data/views/tree.erb +32 -20
- metadata +168 -94
- data/bin/ginatra-daemon +0 -87
- data/bin/ginatra-directory +0 -55
- data/bin/ginatra-server +0 -27
- data/bin/ginatra-setup +0 -28
- data/lib/ginatra/graph_commit.rb +0 -77
- data/public/img/add.png +0 -0
- data/public/img/diff.png +0 -0
- data/public/img/doc.png +0 -0
- data/public/img/rm.png +0 -0
- data/public/img/tree.png +0 -0
- data/public/src/branch-graph.js +0 -170
- data/public/src/colour.css +0 -86
- data/public/src/commit.css +0 -211
- data/public/src/ginatra.js +0 -7
- data/public/src/github.css +0 -129
- data/public/src/graph.css +0 -9
- data/public/src/highlight.pack.js +0 -1
- data/public/src/index.css +0 -92
- data/public/src/lists.css +0 -25
- data/public/src/raphael.js +0 -7
- data/public/src/reset.css +0 -49
- data/public/src/table.css +0 -33
- data/public/src/type.css +0 -30
- data/rackup.ru +0 -5
- data/spec/graph_commit_spec.rb +0 -54
- data/spec/repo_list_spec.rb +0 -84
- data/spec/repo_spec.rb +0 -61
- data/views/_actor_box.erb +0 -13
- data/views/_commit_info_box.erb +0 -27
- data/views/_tree_part.erb +0 -11
- data/views/atom.builder +0 -32
- data/views/graph.erb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: da7d713fca1a0a2164d09c4af9e0e68446f24e3b
|
4
|
+
data.tar.gz: 5dc258e8d928ba24192294dabc70be2b6555a124
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f724bc83773853892f4250f32858751dbc690ff629c0829c18cbb354affa9047557dfbfece6c1c3d39188cd291621c778540940a7629a9a6d4e55b4b20ca908
|
7
|
+
data.tar.gz: b8da76765605a82e326d2c4722644c49614934cda7a555758d3ff5dcf040e921a14a20250667282d7791fb4d0bafa2742bc1eabd8989c824872a35c1f6b1efa5
|
data/.gitignore
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
.
|
5
|
-
*.log
|
6
|
-
webrat*
|
7
|
-
spec/*.html
|
8
|
-
public/*.html
|
9
|
-
_site/
|
10
|
-
_layouts/
|
11
|
-
**/*.swp
|
12
|
-
*.swp
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
13
5
|
.yardoc
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
InstalledFiles
|
7
|
+
_yardoc
|
8
|
+
coverage
|
9
|
+
doc/
|
10
|
+
lib/bundler/man
|
11
|
+
pkg
|
12
|
+
rdoc
|
13
|
+
spec/reports
|
14
|
+
test/tmp
|
15
|
+
test/version_tmp
|
16
|
+
tmp
|
17
|
+
|
18
|
+
repos/
|
19
|
+
config.yml
|
data/.travis.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
---
|
2
1
|
rvm:
|
3
|
-
- 1.9.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
- 1.9.3
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.0
|
5
|
+
notifications:
|
6
|
+
email:
|
7
|
+
on_success: never # default: change
|
8
|
+
on_failure: change # default: always
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
In the spirit of open source software, **everyone** is encouraged to help
|
4
|
+
improve this project.
|
5
|
+
|
6
|
+
## Your Pull Request
|
7
|
+
|
8
|
+
To make it easy to review and understand your change please keep the following
|
9
|
+
things in mind before submitting your pull request:
|
10
|
+
|
11
|
+
* Work on the latest possible state of **ginatra/master**
|
12
|
+
* Create a branch which is dedicated to your change
|
13
|
+
* Test your changes before creating a pull request (`bundle exec rake`)
|
14
|
+
* If possible write a test case which confirms your change
|
15
|
+
* Don't mix several features or bug-fixes in one pull request
|
16
|
+
* Create a meaningful commit message
|
17
|
+
* Explain your change (i.e. with a link to the issue you are fixing)
|
18
|
+
* Keep it simple: don't overcomplicate things and add extra dependencies unless
|
19
|
+
you have a *special* reason
|
20
|
+
|
21
|
+
**IMPORTANT**:
|
22
|
+
|
23
|
+
Before you start working on a larger contribution, you should get in touch first
|
24
|
+
through the issue tracker with your idea so that the project's developers can
|
25
|
+
help out and possibly guide you. Coordinating up front makes it much easier to
|
26
|
+
avoid frustration later on.
|
27
|
+
|
28
|
+
# Thank you
|
29
|
+
|
30
|
+
Each contribution is extremely helpful - thank you!
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Copyright (c) 2009-2012 Samuel Elliott
|
2
|
+
Copyright (c) 2012-2015 Nihad Abbasov
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
Contains data from external sources:
|
28
|
+
|
29
|
+
depuracao/git-webby (https://github.com/depuracao/git-webby)
|
30
|
+
license: https://github.com/depuracao/git-webby/blob/master/LICENSE.txt
|
data/README.md
CHANGED
@@ -1,149 +1,98 @@
|
|
1
1
|
# Ginatra
|
2
|
-
[![](http://stillmaintained.com/lenary/ginatra.png)](http://stillmaintained.com/lenary/ginatra)
|
3
2
|
|
4
|
-
[![](
|
3
|
+
[![Build Status](https://img.shields.io/travis/NARKOZ/ginatra/master.svg?style=flat)](https://travis-ci.org/NARKOZ/ginatra)
|
4
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/NARKOZ/ginatra.svg?style=flat)](https://codeclimate.com/github/NARKOZ/ginatra)
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/ginatra.svg?style=flat)](https://rubygems.org/gems/ginatra)
|
6
|
+
[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/NARKOZ/ginatra/blob/master/LICENSE.txt)
|
5
7
|
|
8
|
+
**Ginatra** is a simple web-based git repository browser built on Ruby Sinatra.
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
paths. I have plans to make it function just as gitweb does, including leeching
|
10
|
-
config files and suchlike.
|
10
|
+
[ [website](http://narkoz.github.io/ginatra) |
|
11
|
+
[screenshots](http://narkoz.github.io/ginatra/screenshots) ]
|
11
12
|
|
12
|
-
|
13
|
-
------------
|
13
|
+
## Features
|
14
14
|
|
15
|
-
|
15
|
+
+ Hassle free installation
|
16
|
+
+ Multiple repository support
|
17
|
+
+ Multiple branch/tag support
|
18
|
+
+ Commit history, diff, patch
|
19
|
+
+ Feeds in Atom format
|
20
|
+
+ Syntax highlighting
|
21
|
+
+ Repository stats
|
22
|
+
+ Smart HTTP support
|
23
|
+
+ [and more](http://narkoz.github.io/ginatra#features)
|
16
24
|
|
17
|
-
|
25
|
+
## Installation
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
$ ginatra setup
|
22
|
-
checked deps
|
23
|
-
installed config
|
27
|
+
There are 2 ways to install Ginatra: as a packaged Ruby gem or as a Sinatra app.
|
28
|
+
It's recommended to install it as a ruby gem, unless you know what you're doing.
|
24
29
|
|
25
|
-
|
26
|
-
has gone wrong.
|
30
|
+
### Ginatra gem
|
27
31
|
|
28
|
-
|
32
|
+
Run the following command to install Ginatra from RubyGems:
|
29
33
|
|
30
|
-
|
34
|
+
```sh
|
35
|
+
gem install ginatra -v 4.0.0
|
36
|
+
```
|
31
37
|
|
32
|
-
|
33
|
-
git version 1.6.3
|
38
|
+
Create config file (see [Configuration](#configuration) section in README).
|
34
39
|
|
35
|
-
|
36
|
-
To check whether you have it, run:
|
40
|
+
Start the Ginatra server:
|
37
41
|
|
38
|
-
|
42
|
+
```sh
|
43
|
+
ginatra run
|
44
|
+
```
|
39
45
|
|
40
|
-
|
41
|
-
If not you'll need to install pygments. Look at the last section of the
|
42
|
-
[jekyll wiki "install" page](http://wiki.github.com/mojombo/jekyll/install)
|
43
|
-
to see how to install it. Also make sure again that the `pygmentize` binary
|
44
|
-
is on your path.
|
46
|
+
By default Ginatra will run on `localhost:9797`
|
45
47
|
|
46
|
-
|
47
|
-
to use a special rackup file to mount it where you wish. I am yet to sort out some of the
|
48
|
-
details of running Ginatra from a gem with a rackup.ru file.
|
48
|
+
### Ginatra app
|
49
49
|
|
50
|
-
|
51
|
-
-----
|
50
|
+
Run the following commands to install Ginatra from source:
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
```sh
|
53
|
+
git clone git://github.com/NARKOZ/ginatra.git
|
54
|
+
cd ginatra/
|
55
|
+
bundle
|
56
|
+
```
|
55
57
|
|
56
|
-
|
57
|
-
$ ginatra server status
|
58
|
-
$ ginatra server stop
|
58
|
+
Create config file or modify existing (see [Configuration](#configuration) section in README).
|
59
59
|
|
60
|
-
|
60
|
+
Start the Ginatra server:
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
```sh
|
63
|
+
./bin/ginatra run
|
64
|
+
```
|
64
65
|
|
65
|
-
|
66
|
+
By default Ginatra will run on `localhost:9797`
|
66
67
|
|
67
|
-
|
68
|
-
$ ginatra daemon status
|
69
|
-
$ ginatra daemon stop
|
68
|
+
## Configuration
|
70
69
|
|
71
|
-
|
70
|
+
Create `~/.ginatra/config.yml` file with your own settings. See
|
71
|
+
[`config.yml`](https://github.com/NARKOZ/ginatra/blob/master/config.yml) for a reference.
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
`git_dirs` - Ginatra will look into these folders for git repositories. It's
|
74
|
+
required to append `*` at the end of path. Example: `/home/Development/repos/*`
|
75
75
|
|
76
|
-
|
77
|
-
$ ginatra directory list
|
78
|
-
$ ginatra directory remove '~/Git/ginatra/*'
|
76
|
+
`ignored_files` - files to ignore in `git_dirs`
|
79
77
|
|
80
|
-
|
81
|
-
or by not specifying a sub-command like start, status, stop, add, list or remove.
|
78
|
+
`description` - description of web interface. Used in index page.
|
82
79
|
|
80
|
+
`port` - port that Ginatra server will run at.
|
83
81
|
|
84
|
-
|
85
|
-
-----------
|
82
|
+
`host` - host that Ginatra server will run at.
|
86
83
|
|
87
|
-
|
84
|
+
`prefix` - prefix for the host serving Ginatra. Used when Ginatra is installed
|
85
|
+
in subdirectory.
|
88
86
|
|
89
|
-
-
|
90
|
-
|
91
|
-
- Jan Topiński (simcha)
|
87
|
+
`git_clone_enabled?` - enables smart HTTP support and allows to clone git
|
88
|
+
repopsitories.
|
92
89
|
|
93
|
-
|
90
|
+
If you installed Ginatra as an app, you can change settings by editing
|
91
|
+
`config.yml` file in root folder.
|
94
92
|
|
95
|
-
|
96
|
-
- Elia Schito (elia)
|
97
|
-
- Scott Wisely (Syd)
|
98
|
-
- Jonathan Stott (namelessjon)
|
99
|
-
- Michael James (umjames)
|
93
|
+
You need to restart web server after applying changes to config file.
|
100
94
|
|
101
|
-
|
95
|
+
## How to Contribute
|
102
96
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
**Index**
|
107
|
-
|
108
|
-
![Ginatra Index](http://cloud.github.com/downloads/lenary/ginatra/o%20\(5\).png "Ginatra Index")
|
109
|
-
|
110
|
-
**Log**
|
111
|
-
|
112
|
-
![Ginatra Log](http://cloud.github.com/downloads/lenary/ginatra/o%20\(3\).png "Ginatra Log")
|
113
|
-
|
114
|
-
**Commit**
|
115
|
-
|
116
|
-
![Ginatra Commit](http://cloud.github.com/downloads/lenary/ginatra/o%20\(4\).png "Ginatra Commit")
|
117
|
-
|
118
|
-
**Tree**
|
119
|
-
|
120
|
-
![Ginatra Tree](http://cloud.github.com/downloads/lenary/ginatra/o%20\(2\).png "Ginatra Tree")
|
121
|
-
|
122
|
-
**Branch graph**
|
123
|
-
|
124
|
-
![Branch graph](http://cloud.github.com/downloads/simcha/ginatra/branch-graph.png "Branch Graph")
|
125
|
-
|
126
|
-
|
127
|
-
Licence
|
128
|
-
-------
|
129
|
-
|
130
|
-
The MIT License
|
131
|
-
|
132
|
-
Copyright (c) 2009 Samuel Elliott
|
133
|
-
|
134
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
135
|
-
this software and associated documentation files (the "Software"), to deal in
|
136
|
-
the Software without restriction, including without limitation the rights to
|
137
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
138
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
139
|
-
subject to the following conditions:
|
140
|
-
|
141
|
-
The above copyright notice and this permission notice shall be included in all
|
142
|
-
copies or substantial portions of the Software.
|
143
|
-
|
144
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
145
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
146
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
147
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
148
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
149
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
97
|
+
Open issues are labeled per perceived difficulty. See [contributing
|
98
|
+
guidelines](https://github.com/NARKOZ/ginatra/blob/master/CONTRIBUTING.md).
|
data/Rakefile
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
require
|
2
|
-
Bundler.setup(:default, :development)
|
1
|
+
require 'bundler/gem_tasks'
|
3
2
|
require 'rspec/core/rake_task'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
FileUtils.cd(File.join(File.dirname(__FILE__), "repos")) do
|
4
|
+
desc "Clone test repository"
|
5
|
+
task :clone_repo do
|
6
|
+
repos_dir = File.expand_path('./repos')
|
7
|
+
FileUtils.cd(repos_dir) do
|
10
8
|
puts `git clone git://github.com/atmos/hancock-client.git test`
|
11
|
-
end
|
9
|
+
end unless Dir.exists?("#{repos_dir}/test")
|
12
10
|
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
r.rspec_opts = ['--color']
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
13
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
14
|
+
spec.rspec_opts = ['--color']
|
18
15
|
end
|
19
16
|
|
17
|
+
task default: ['clone_repo', 'spec']
|
data/bin/ginatra
CHANGED
@@ -1,78 +1,94 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Ginatra
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
HELP
|
35
|
-
|
36
|
-
def self.daemon
|
37
|
-
path = File.expand_path(File.dirname(__FILE__))
|
38
|
-
load "#{path}/ginatra-daemon"
|
39
|
-
end
|
3
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'ginatra'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {
|
9
|
+
port: Ginatra.config.port,
|
10
|
+
host: Ginatra.config.host
|
11
|
+
}
|
12
|
+
|
13
|
+
global_opts = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: ginatra <options> <command>"
|
15
|
+
|
16
|
+
opts.separator ""
|
17
|
+
opts.separator "Options:"
|
18
|
+
|
19
|
+
opts.on('-v', '--version', 'Print version and exit') do
|
20
|
+
require_relative '../lib/ginatra/version'
|
21
|
+
puts "Ginatra #{Ginatra::VERSION} #{Ginatra::RELEASE_NAME}"
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on_tail('-h', '--help', 'Show this help message') do
|
26
|
+
puts opts
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
server_opts = {
|
32
|
+
'run' => OptionParser.new do |opts|
|
33
|
+
opts.banner = "Usage: ginatra run <options>"
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
opts.separator ""
|
36
|
+
opts.separator "Options:"
|
37
|
+
|
38
|
+
opts.on('-p', '--port PORT', 'Port to bind to (defaults from config file)') do |port|
|
39
|
+
options[:port] = port.to_i
|
44
40
|
end
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
load("#{path}/ginatra-server")
|
42
|
+
opts.on('-h', '--host HOST', 'Host address to bind to (defaults from config file)') do |host|
|
43
|
+
options[:host] = host
|
49
44
|
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
opts.on 'Start Ginatra web server' do
|
47
|
+
environment = ENV['RACK_ENV'] || 'production'
|
48
|
+
rack_config = File.expand_path("#{__FILE__}/../../config.ru")
|
49
|
+
pid_file = File.expand_path("#{__FILE__}/../../ginatra.pid")
|
50
|
+
|
51
|
+
system "rackup -D -E #{environment} -P #{pid_file} -p #{options[:port]} -o #{options[:host]} #{rack_config}"
|
52
|
+
puts "Ginatra runs on #{options[:host]}:#{options[:port]}"
|
54
53
|
end
|
54
|
+
end,
|
55
|
+
|
56
|
+
'stop' => OptionParser.new do |opts|
|
57
|
+
opts.banner = "Usage: ginatra stop"
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
daemon
|
65
|
-
when "directory"
|
66
|
-
directory
|
67
|
-
when "server"
|
68
|
-
server
|
69
|
-
else
|
70
|
-
puts Ginatra::Executable::HELP
|
59
|
+
opts.on 'Stop Ginatra web server' do
|
60
|
+
pid_file = File.expand_path("#{__FILE__}/../../ginatra.pid")
|
61
|
+
|
62
|
+
if File.exist?(pid_file)
|
63
|
+
pid = File.read(pid_file)
|
64
|
+
Process.kill('INT', pid.to_i)
|
65
|
+
File.delete(pid_file)
|
66
|
+
puts "Stopped Ginatra web server"
|
71
67
|
end
|
72
68
|
end
|
69
|
+
end,
|
70
|
+
|
71
|
+
'status' => OptionParser.new do |opts|
|
72
|
+
opts.banner = "Usage: ginatra status"
|
73
|
+
|
74
|
+
opts.on 'Get status of Ginatra web server' do
|
75
|
+
pid_file = File.expand_path("#{__FILE__}/../../ginatra.pid")
|
76
|
+
status = File.exist?(pid_file) ? "running.. (pid: #{File.read(pid_file).to_i})" : 'NOT running'
|
77
|
+
puts "Ginatra is #{status}"
|
78
|
+
end
|
73
79
|
end
|
74
|
-
|
80
|
+
}
|
75
81
|
|
76
|
-
|
82
|
+
if ARGV.size.zero?
|
83
|
+
puts global_opts
|
77
84
|
|
85
|
+
%w(run stop status).each do |cmd|
|
86
|
+
puts
|
87
|
+
puts server_opts[cmd]
|
88
|
+
end
|
89
|
+
|
90
|
+
exit 1
|
91
|
+
end
|
78
92
|
|
93
|
+
global_opts.order!
|
94
|
+
server_opts[ARGV.shift].order!
|