Thin_Upstart 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/README.md +104 -0
- data/Rakefile +3 -0
- data/Thin_Upstart.gemspec +32 -0
- data/bin/Thin_Upstart +38 -0
- data/lib/Thin_Upstart/version.rb +3 -0
- data/lib/Thin_Upstart.rb +127 -0
- data/lib/templates/{{name}}-{{app}}.conf +11 -0
- data/lib/templates/{{name}}.conf +0 -0
- data/spec/helper.rb +15 -0
- data/spec/main.rb +96 -0
- data/spec/templates/{{name}}-{{app}}.conf +8 -0
- data/spec/templates/{{name}}.conf +10 -0
- data/spec/tests/bin.rb +84 -0
- data/spec/tests/create.rb +65 -0
- data/spec/tests/mustache.rb +32 -0
- data/spec/tests/settings.rb +13 -0
- data/spec/tests/trash.rb +21 -0
- metadata +178 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
Thin\_Upstart
|
3
|
+
================
|
4
|
+
|
5
|
+
This is an alternative to [Foreman + Upstart](http://michaelvanrooijen.com/articles/2011/06/08-managing-and-monitoring-your-ruby-application-with-foreman-and-upstart/)
|
6
|
+
generating your Upstart conf files. It ignores your Procfile,
|
7
|
+
and insteads uses your Thin .yml config file. The following files
|
8
|
+
are generated (assuming you call your group of Thin apps 'web-app'):
|
9
|
+
|
10
|
+
# App dirs
|
11
|
+
|- app1
|
12
|
+
|- app2
|
13
|
+
|
14
|
+
# Template dir
|
15
|
+
|- {{name}}.conf
|
16
|
+
|- {{name}}-{{app}}.conf
|
17
|
+
|
18
|
+
# Files generated
|
19
|
+
|- output-dir
|
20
|
+
|- web-apps.conf
|
21
|
+
|- web-apps-app1.conf
|
22
|
+
|- web-apps-app2.conf
|
23
|
+
|- ...
|
24
|
+
|
25
|
+
|
26
|
+
Installation
|
27
|
+
------------
|
28
|
+
|
29
|
+
gem install Thin_Upstart
|
30
|
+
|
31
|
+
Usage: Ruby
|
32
|
+
------
|
33
|
+
|
34
|
+
require "Thin_Upstart"
|
35
|
+
|
36
|
+
Thin_Upstart { |o|
|
37
|
+
o.name "web-apps"
|
38
|
+
o.apps "./apps"
|
39
|
+
o.templates "./templates/*.conf" # file glob
|
40
|
+
o.output "./upstart"
|
41
|
+
o.yml "config/thin.yml"
|
42
|
+
}
|
43
|
+
|
44
|
+
If you want to delete files generated by Thin\_Upstart, use:
|
45
|
+
|
46
|
+
Thin_Upstart.trash "my/conf/dir"
|
47
|
+
|
48
|
+
All files that end in ".conf" are deleted if they contain the following string:
|
49
|
+
|
50
|
+
# Generated by Thin_Upstart
|
51
|
+
|
52
|
+
Usage: Shell
|
53
|
+
------
|
54
|
+
|
55
|
+
Thin_Upstart
|
56
|
+
--name web-apps
|
57
|
+
--apps ./apps
|
58
|
+
--templates ./templates
|
59
|
+
--yml config/thin.yml
|
60
|
+
--output ./output
|
61
|
+
--trash my/conf/dir # When used, all other options are ignored.
|
62
|
+
--help
|
63
|
+
|
64
|
+
*Note:* Be sure to use quotation marks when using file globs:
|
65
|
+
|
66
|
+
Thin_Upstart --templates "template/*.conf"
|
67
|
+
Thin_Upstart --yml "config/*.yml"
|
68
|
+
|
69
|
+
Usage: Mustache Template
|
70
|
+
-----
|
71
|
+
In your Mustache templates, you have access to the following values:
|
72
|
+
|
73
|
+
* *name:* Name of app group: e.g. My-Web-Apps
|
74
|
+
* *apps\_dir:* Full path to directory of apps.
|
75
|
+
* *app:* Name of current app: e.g. Blog
|
76
|
+
* *app\_path:* Full path to app.
|
77
|
+
* *yml:* Relative path from current app directory to .yml file
|
78
|
+
* *yml\_path:* Full path to app directory.
|
79
|
+
|
80
|
+
You can use Mustache values in the file names of the templates.
|
81
|
+
For example:
|
82
|
+
|
83
|
+
* my/template/dir/*{{name}}*.conf
|
84
|
+
* my/template/dir/*{{name}}*-*{{app}}*.conf
|
85
|
+
|
86
|
+
The files are generated are:
|
87
|
+
|
88
|
+
* my/template/dir/My-Apps.conf
|
89
|
+
* my/template/dir/My-Apps-Hi.conf
|
90
|
+
|
91
|
+
Run Tests
|
92
|
+
---------
|
93
|
+
|
94
|
+
git clone git@github.com:da99/Thin_Upstart.git
|
95
|
+
cd Thin_Upstart
|
96
|
+
bundle update
|
97
|
+
bundle exec bacon spec/main.rb
|
98
|
+
|
99
|
+
"I hate writing."
|
100
|
+
-----------------------------
|
101
|
+
|
102
|
+
If you know of existing software that makes the above redundant,
|
103
|
+
please tell me. The last thing I want to do is maintain code.
|
104
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "Thin_Upstart/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "Thin_Upstart"
|
8
|
+
s.version = Thin_Upstart::VERSION
|
9
|
+
s.authors = ["da99"]
|
10
|
+
s.email = ["i-hate-spam-45671204@mailinator.com"]
|
11
|
+
s.homepage = "https://github.com/da99/Thin_Upstart"
|
12
|
+
s.summary = %q{Generate Upstart conf files for your Thin apps.}
|
13
|
+
s.description = %q{
|
14
|
+
Generates Upstart conf files for your Thin apps.
|
15
|
+
Uses Mustache templates for customization.
|
16
|
+
}
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_development_dependency 'bacon'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'Bacon_Colored'
|
26
|
+
s.add_development_dependency 'pry'
|
27
|
+
|
28
|
+
# Specify any dependencies here; for example:
|
29
|
+
s.add_runtime_dependency 'mustache'
|
30
|
+
s.add_runtime_dependency 'trollop'
|
31
|
+
s.add_runtime_dependency 'Exit_Zero'
|
32
|
+
end
|
data/bin/Thin_Upstart
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- ruby -*-
|
3
|
+
#
|
4
|
+
|
5
|
+
|
6
|
+
require "trollop"
|
7
|
+
require "Thin_Upstart"
|
8
|
+
|
9
|
+
h = Hash[
|
10
|
+
:name => "Name for Upstart service.",
|
11
|
+
:yml => ".yml config file path relative to app dir.: \"config/thin.yml\"",
|
12
|
+
:apps => "Path to dir containing apps.",
|
13
|
+
:templates => "File glob for templates: e.g. \"./templates/*.conf\"",
|
14
|
+
:output => "Output directory.",
|
15
|
+
:trash => "Dir to trash. All other arguments are ignored."
|
16
|
+
]
|
17
|
+
|
18
|
+
opts = Trollop::options do
|
19
|
+
h.each { |k,v|
|
20
|
+
opt k, v, :type=>String
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
if opts[:trash_given]
|
25
|
+
files = Thin_Upstart.trash opts[:trash]
|
26
|
+
files.each { |f|
|
27
|
+
puts "deleted: #{f}"
|
28
|
+
}
|
29
|
+
else
|
30
|
+
files = Thin_Upstart { |o|
|
31
|
+
h.each { |k, desc|
|
32
|
+
o.send(k, opts[k]) if opts[k]
|
33
|
+
}
|
34
|
+
}
|
35
|
+
files.each { |f|
|
36
|
+
puts "created: #{f}"
|
37
|
+
}
|
38
|
+
end
|
data/lib/Thin_Upstart.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'Thin_Upstart/version'
|
2
|
+
require 'Exit_Zero'
|
3
|
+
require 'mustache'
|
4
|
+
|
5
|
+
def Thin_Upstart
|
6
|
+
o = Thin_Upstart.new
|
7
|
+
yield o
|
8
|
+
o.write
|
9
|
+
end
|
10
|
+
|
11
|
+
class Thin_Upstart
|
12
|
+
|
13
|
+
module Class_Methods
|
14
|
+
|
15
|
+
def trash dir
|
16
|
+
cmd = `which trash`.strip.empty? || File.directory?("/tmp/Thin_Upstart") ? "rm" : "trash"
|
17
|
+
files = []
|
18
|
+
Dir.glob(File.join(dir, "*.conf")).each { |file|
|
19
|
+
next unless File.read(file)["# Generated by Thin_Upstart"]
|
20
|
+
files << file
|
21
|
+
Exit_Zero "#{cmd} #{file}"
|
22
|
+
}
|
23
|
+
|
24
|
+
files.sort
|
25
|
+
end
|
26
|
+
|
27
|
+
end # === Class_Methods
|
28
|
+
|
29
|
+
extend Class_Methods
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
name "My-Apps"
|
33
|
+
apps "./apps"
|
34
|
+
templates "./templates/*.conf"
|
35
|
+
output "./upstart"
|
36
|
+
yml "thin.yml"
|
37
|
+
yield(self) if block_given?
|
38
|
+
end
|
39
|
+
|
40
|
+
def remove_last_slash h
|
41
|
+
new_h = Hash[]
|
42
|
+
h.each { |k, v|
|
43
|
+
new_h[k] = v.sub(%r!\//Z!, '')
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def write
|
48
|
+
app_list = []
|
49
|
+
dirs = Dir.glob(File.join apps, "/*")
|
50
|
+
|
51
|
+
final = []
|
52
|
+
|
53
|
+
tmpls = Dir.glob(templates)
|
54
|
+
raise ArgumentError, "No templates found in: #{templates}" if tmpls.empty?
|
55
|
+
|
56
|
+
dirs.each { |raw_app|
|
57
|
+
app = File.basename(raw_app)
|
58
|
+
app_path = File.expand_path(raw_app)
|
59
|
+
|
60
|
+
|
61
|
+
yml_path = Dir.glob(File.join app_path, yml).first
|
62
|
+
next unless yml_path
|
63
|
+
app_list << app
|
64
|
+
|
65
|
+
yml = yml_path.sub( File.join(app_path, '/'), '')
|
66
|
+
|
67
|
+
vals = remove_last_slash Hash[
|
68
|
+
:name => name,
|
69
|
+
:app => app,
|
70
|
+
:app_path => app_path,
|
71
|
+
:yml => yml,
|
72
|
+
:yml_path => yml_path,
|
73
|
+
:apps_dir => File.expand_path(apps)
|
74
|
+
]
|
75
|
+
|
76
|
+
tmpls.each { |file|
|
77
|
+
temp_path = Mustache.render(file, vals)
|
78
|
+
file_name = File.basename(temp_path)
|
79
|
+
final_path= File.join(output, file_name)
|
80
|
+
tmpl_content = "# Generated by Thin_Upstart (Ruby gem)\n" + File.read(file)
|
81
|
+
content = Mustache.render(tmpl_content, vals)
|
82
|
+
|
83
|
+
File.write( final_path, content )
|
84
|
+
final << final_path
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
raise(ArgumentError, "No apps found in: #{apps}") if app_list.empty?
|
90
|
+
|
91
|
+
final.uniq.sort
|
92
|
+
end
|
93
|
+
|
94
|
+
def set_or_get attr, val = :RETURN
|
95
|
+
if val == :RETURN
|
96
|
+
instance_variable_get(:"@#{attr}")
|
97
|
+
else
|
98
|
+
instance_variable_set(:"@#{attr}", val)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
%w{ name yml }.each { |attr|
|
103
|
+
|
104
|
+
eval %~
|
105
|
+
def #{attr} *args
|
106
|
+
set_or_get :#{attr}, *args
|
107
|
+
end
|
108
|
+
~
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
%w{ apps templates output }.each { |attr|
|
113
|
+
|
114
|
+
eval %~
|
115
|
+
def #{attr} val = :RETURN
|
116
|
+
if val == :RETURN
|
117
|
+
set_or_get :#{attr}
|
118
|
+
else
|
119
|
+
set_or_get :#{attr}, File.expand_path(val)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
~
|
123
|
+
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
end # === class Thin_Upstart
|
File without changes
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.print e.message, "\n"
|
7
|
+
$stderr.print "Run `bundle install` to install missing gems\n"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'bacon'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
|
15
|
+
Bacon.summary_on_exit
|
data/spec/main.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('spec/helper')
|
3
|
+
require 'Thin_Upstart'
|
4
|
+
require 'Bacon_Colored'
|
5
|
+
require 'pry'
|
6
|
+
require 'Exit_Zero'
|
7
|
+
|
8
|
+
D = "/tmp/Thin_Upstart"
|
9
|
+
|
10
|
+
def Multi_0 str
|
11
|
+
str.strip.split("\n").each { |o|
|
12
|
+
next if o.strip.empty?
|
13
|
+
Exit_Zero o
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def recreate
|
18
|
+
Multi_0 %@
|
19
|
+
rm -rf #{D}
|
20
|
+
mkdir #{D}
|
21
|
+
|
22
|
+
mkdir #{D}/upstart
|
23
|
+
mkdir #{D}/templates
|
24
|
+
|
25
|
+
mkdir -p #{D}/apps/Hi
|
26
|
+
mkdir -p #{D}/apps/Hi/config
|
27
|
+
touch #{D}/apps/Hi/thin.yml
|
28
|
+
touch #{D}/apps/Hi/config/my.yml
|
29
|
+
|
30
|
+
|
31
|
+
mkdir -p #{D}/apps/Hello
|
32
|
+
mkdir -p #{D}/apps/Hello/config
|
33
|
+
touch #{D}/apps/Hello/config/my.yml
|
34
|
+
touch #{D}/apps/Hello/thin.yml
|
35
|
+
|
36
|
+
mkdir -p #{D}/templates
|
37
|
+
cp -r spec/templates #{D}/
|
38
|
+
@
|
39
|
+
end
|
40
|
+
|
41
|
+
recreate
|
42
|
+
|
43
|
+
def reset
|
44
|
+
Multi_0 %!
|
45
|
+
rm -rf #{D}/upstart
|
46
|
+
mkdir #{D}/upstart
|
47
|
+
!
|
48
|
+
end
|
49
|
+
|
50
|
+
def chdir
|
51
|
+
Dir.chdir(D) { yield }
|
52
|
+
end
|
53
|
+
|
54
|
+
def bin args
|
55
|
+
chdir {
|
56
|
+
Exit_Zero "Thin_Upstart #{args}"
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
module Bacon
|
61
|
+
class Context
|
62
|
+
|
63
|
+
def should_mustache name, val, file = nil
|
64
|
+
file ||= "upstart/#{@name}-Hi.conf"
|
65
|
+
target = %r!#{name}: #{val}$!
|
66
|
+
File.read(file)[target].should.match target
|
67
|
+
end
|
68
|
+
|
69
|
+
def generate name
|
70
|
+
chdir {
|
71
|
+
@name = name
|
72
|
+
generate!(name) unless File.file?("upstart/#{@name}.conf")
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def generate! name
|
77
|
+
@name = name
|
78
|
+
chdir {
|
79
|
+
reset
|
80
|
+
Thin_Upstart { |o| o.name @name }
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
end # === Context
|
87
|
+
end # === Bacon
|
88
|
+
|
89
|
+
# ======== Include the tests.
|
90
|
+
if ARGV.size > 1 && ARGV[1, ARGV.size - 1].detect { |a| File.exists?(a) }
|
91
|
+
# Do nothing. Bacon grabs the file.
|
92
|
+
else
|
93
|
+
Dir.glob('spec/tests/*.rb').each { |file|
|
94
|
+
require File.expand_path(file.sub('.rb', '')) if File.file?(file)
|
95
|
+
}
|
96
|
+
end
|
data/spec/tests/bin.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
bins = Dir.glob("bin/*")
|
3
|
+
|
4
|
+
describe "permissions of bin/" do
|
5
|
+
bins.each { |file|
|
6
|
+
it "should chmod 755 for: #{file}" do
|
7
|
+
`stat -c %a #{file}`.strip
|
8
|
+
.should.be == "755"
|
9
|
+
end
|
10
|
+
}
|
11
|
+
end # === permissions of bin/
|
12
|
+
|
13
|
+
describe "bin: Thin_Upstart" do
|
14
|
+
|
15
|
+
before {
|
16
|
+
chdir {
|
17
|
+
reset
|
18
|
+
`rm -r new-apps 2>&1`
|
19
|
+
`rm -r new-templates 2>&1`
|
20
|
+
`rm -r new-upstart 2>&1`
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
it "accepts --name" do
|
25
|
+
chdir {
|
26
|
+
bin "--name MINE"
|
27
|
+
should_mustache "name", "MINE", "upstart/MINE.conf"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "accepts --yml" do
|
32
|
+
chdir {
|
33
|
+
bin "--yml config/my.yml"
|
34
|
+
should_mustache "yml", "config/my.yml", "upstart/My-Apps-Hi.conf"
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "accepts --apps" do
|
39
|
+
chdir {
|
40
|
+
Exit_Zero "cp -r apps new-apps"
|
41
|
+
bin "--apps new-apps"
|
42
|
+
should_mustache "apps_dir", File.expand_path("new-apps"), "upstart/My-Apps-Hi.conf"
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
it "accepts --templates" do
|
47
|
+
chdir {
|
48
|
+
Exit_Zero "cp -r templates new-templates"
|
49
|
+
bin "--templates \"new-templates/*.conf\""
|
50
|
+
should_mustache "app", "Hi", "upstart/My-Apps-Hi.conf"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "accepts --output" do
|
55
|
+
chdir {
|
56
|
+
Exit_Zero "mkdir new-upstart"
|
57
|
+
bin "--output new-upstart"
|
58
|
+
should_mustache "name", "My-Apps", "new-upstart/My-Apps-Hi.conf"
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
end # === bin: Thin_Upstart
|
63
|
+
|
64
|
+
describe "Thin_Upstart --trash dir" do
|
65
|
+
|
66
|
+
it "it removes file from dir" do
|
67
|
+
chdir {
|
68
|
+
Multi_0 %@
|
69
|
+
mkdir bin_trash
|
70
|
+
echo "# Generated by Thin_Upstart (Ruby gem)" >> bin_trash/a.conf
|
71
|
+
echo "# Generated by Thin_Upstart " >> bin_trash/b.conf
|
72
|
+
echo "# Generated by Thin" >> bin_trash/c.conf
|
73
|
+
@
|
74
|
+
|
75
|
+
bin "--trash bin_trash"
|
76
|
+
File.file?("bin_trash/a.conf").should == false
|
77
|
+
File.file?("bin_trash/b.conf").should == false
|
78
|
+
File.file?("bin_trash/c.conf").should == true
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
end # === Thin_Upstart --trash dir
|
83
|
+
|
84
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
describe "Thin_Upstart create" do
|
3
|
+
|
4
|
+
before { reset }
|
5
|
+
|
6
|
+
it "creates main app file: upstart/{{name}}.conf" do
|
7
|
+
chdir {
|
8
|
+
Thin_Upstart { |o| o.name "My-Apps" }
|
9
|
+
should_mustache "name", "My-Apps", "upstart/My-Apps.conf"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "creates app file for each file: upstart/{{name}}-{{app}}.conf" do
|
14
|
+
chdir {
|
15
|
+
Thin_Upstart { |o| o.name "My" }
|
16
|
+
%w{ Hi Hello }.each { |n|
|
17
|
+
should_mustache "app", n, "upstart/My-#{n}.conf"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "prepends to each file: '# Generated by Thin_Upstart'" do
|
23
|
+
target = "# Generated by Thin_Upstart (Ruby gem)"
|
24
|
+
chdir {
|
25
|
+
Thin_Upstart { |o| o.name "My" }
|
26
|
+
File.read("upstart/My.conf")[target].should == target
|
27
|
+
File.read("upstart/My-Hi.conf")[target].should == target
|
28
|
+
File.read("upstart/My-Hello.conf")[target].should == target
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "raise ArgumentError if no templates are found." do
|
33
|
+
chdir {
|
34
|
+
lambda {
|
35
|
+
Thin_Upstart { |o| o.templates "ignored" }
|
36
|
+
}.should.raise(ArgumentError)
|
37
|
+
.message.should.match %r!No templates found in: #{`pwd`.strip}/ignored!
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises ArgumentError if no apps are found." do
|
42
|
+
target = File.expand_path("#{D}/..")
|
43
|
+
chdir {
|
44
|
+
lambda {
|
45
|
+
Thin_Upstart { |o|
|
46
|
+
o.apps target
|
47
|
+
}
|
48
|
+
}.should.raise(ArgumentError)
|
49
|
+
.message.should.match %r!No apps found in: #{target}!
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
it "ignores app with no .yml file" do
|
54
|
+
name = "Ignored"
|
55
|
+
chdir {
|
56
|
+
`mkdir apps/#{name}`
|
57
|
+
Thin_Upstart
|
58
|
+
Dir.glob("upstart/*").detect { |f| f[name] }
|
59
|
+
.should == nil
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
end # === Thin_Upstart create
|
64
|
+
|
65
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
describe "Thin_Upstart Mustache values" do
|
3
|
+
|
4
|
+
before { generate 'my-apps' }
|
5
|
+
|
6
|
+
it "sets: {{name}}" do
|
7
|
+
chdir { should_mustache 'name', "my-apps" }
|
8
|
+
end
|
9
|
+
|
10
|
+
it "sets: {{app}}" do
|
11
|
+
chdir { should_mustache 'app', 'Hi' }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "sets: {{app_path}}" do
|
15
|
+
chdir { should_mustache 'app_path', File.expand_path("apps/Hi") }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets: {{yml}}" do
|
19
|
+
chdir { should_mustache 'yml', "thin.yml" }
|
20
|
+
end
|
21
|
+
|
22
|
+
it "sets: {{yml_path}}" do
|
23
|
+
chdir { should_mustache 'yml_path', File.expand_path("apps/Hi/thin.yml") }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets: {{apps_dir}}" do
|
27
|
+
chdir { should_mustache 'apps_dir', File.expand_path("./apps") }
|
28
|
+
end
|
29
|
+
|
30
|
+
end # === Thin_Upstart Mustache values
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
describe "Thin_Upstart settings" do
|
3
|
+
|
4
|
+
%w{ apps output }.each { |dir|
|
5
|
+
it "removes ending slash of :#{dir}" do
|
6
|
+
target = File.expand_path('.')
|
7
|
+
o = Thin_Upstart.new
|
8
|
+
o.apps "./#{dir}/"
|
9
|
+
o.apps.should == "#{target}/#{dir}"
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
end # === Thin_Upstart settings
|
data/spec/tests/trash.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
describe "Thin_Upstart.trash" do
|
3
|
+
|
4
|
+
it "removes all files with string: # Generated by Thin_Upstart" do
|
5
|
+
chdir {
|
6
|
+
Multi_0 %@
|
7
|
+
mkdir trash
|
8
|
+
echo "# Generated by Thin_Upstart (Ruby gem)" >> trash/1.conf
|
9
|
+
echo "# Generated by Thin_Upstart " >> trash/2.conf
|
10
|
+
echo "# Generated by Thin" >> trash/3.conf
|
11
|
+
@
|
12
|
+
|
13
|
+
Thin_Upstart.trash "trash"
|
14
|
+
File.file?("trash/1.conf").should == false
|
15
|
+
File.file?("trash/2.conf").should == false
|
16
|
+
File.file?("trash/3.conf").should == true
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
end # === Thin_Upstart.trash
|
21
|
+
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Thin_Upstart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- da99
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bacon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: Bacon_Colored
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mustache
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: trollop
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: Exit_Zero
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: ! "\n Generates Upstart conf files for your Thin apps.\n Uses Mustache
|
127
|
+
templates for customization.\n "
|
128
|
+
email:
|
129
|
+
- i-hate-spam-45671204@mailinator.com
|
130
|
+
executables:
|
131
|
+
- Thin_Upstart
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- .gitignore
|
136
|
+
- Gemfile
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- Thin_Upstart.gemspec
|
140
|
+
- bin/Thin_Upstart
|
141
|
+
- lib/Thin_Upstart.rb
|
142
|
+
- lib/Thin_Upstart/version.rb
|
143
|
+
- lib/templates/{{name}}-{{app}}.conf
|
144
|
+
- lib/templates/{{name}}.conf
|
145
|
+
- spec/helper.rb
|
146
|
+
- spec/main.rb
|
147
|
+
- spec/templates/{{name}}-{{app}}.conf
|
148
|
+
- spec/templates/{{name}}.conf
|
149
|
+
- spec/tests/bin.rb
|
150
|
+
- spec/tests/create.rb
|
151
|
+
- spec/tests/mustache.rb
|
152
|
+
- spec/tests/settings.rb
|
153
|
+
- spec/tests/trash.rb
|
154
|
+
homepage: https://github.com/da99/Thin_Upstart
|
155
|
+
licenses: []
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 1.8.19
|
175
|
+
signing_key:
|
176
|
+
specification_version: 3
|
177
|
+
summary: Generate Upstart conf files for your Thin apps.
|
178
|
+
test_files: []
|