jefe 1.1.0 → 1.2.0

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.
data/README.md CHANGED
@@ -2,4 +2,13 @@
2
2
 
3
3
  Through the magic of [Thor](https://github.com/wycats/thor) and [EventMachine](http://rubyeventmachine.com/), we give you the equivalent to [Foreman](https://github.com/ddollar/foreman) in just 200 lines of sweet unadulterated Ruby.
4
4
 
5
- Run `gem install jefe` and you're all set!
5
+ ###Installing
6
+
7
+ Do a `gem install jefe` and you're all set!
8
+
9
+ ### Using
10
+
11
+ Run `jefe`. Just five keystrokes!
12
+
13
+ You can also try `jefe start -p 5000` or `jefe start -c web=1,db=1,worker=47`. Run `jefe help` for more options.
14
+
@@ -10,13 +10,17 @@ class Jefe::CLI < Thor
10
10
  class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: Procfile"
11
11
 
12
12
  desc "start [COMMAND...]", "Start the application"
13
+ default_task :start
13
14
 
14
15
  method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
15
16
  method_option :port, :type => :numeric, :aliases => "-p"
16
17
  method_option :concurrency, :type => :string, :aliases => "-c", :banner => '"alpha=5,bar=3"'
17
18
 
18
19
  def start(*args)
19
- error("#{procfile} does not exist") unless File.exists? procfile
20
+ if ! File.exists? procfile
21
+ help
22
+ error("#{procfile} does not exist")
23
+ end
20
24
 
21
25
  loader = Jefe::Loader.new File.read procfile
22
26
  engine = Jefe::EM.new(Jefe::ColorPrinter.new)
@@ -25,9 +29,8 @@ class Jefe::CLI < Thor
25
29
  puts
26
30
  engine.stop
27
31
  end
28
- names = args.empty? ? loader.process_types.keys : args
29
32
  engine.start do
30
- loader.tasks(concurrency(names), port).each do |(name, command)|
33
+ loader.scale(concurrency_options(args), port).each do |(name, command)|
31
34
  engine.add name, command
32
35
  end
33
36
  end
@@ -35,6 +38,7 @@ class Jefe::CLI < Thor
35
38
 
36
39
  def help(*args)
37
40
  puts "Jefe #{Jefe::VERSION}, the featherweight Procfile manager"
41
+ puts "By default, calling `jefe' acts as `jefe start'. Your other options are:"
38
42
  puts
39
43
  super
40
44
  end
@@ -45,17 +49,11 @@ private
45
49
  options[:port] || 5000
46
50
  end
47
51
 
48
- def concurrency names
52
+ def concurrency_options names
49
53
  ret = {}
50
- if options[:concurrency]
51
- options[:concurrency].split(",").each do |kv|
52
- k, v = kv.split "="
53
- ret[k] = v.to_i
54
- end
55
- else
56
- names.each do |name|
57
- ret[name] = 1
58
- end
54
+ options[:concurrency].to_s.split(",").each do |kv|
55
+ k, v = kv.split "="
56
+ ret[k] = v.to_i
59
57
  end
60
58
  ret
61
59
  end
@@ -1,17 +1,20 @@
1
1
  class Jefe::Loader
2
2
  attr_reader :process_types
3
3
  def initialize(file)
4
- @process_types = {}
5
- file.split("\n").each do |line|
6
- if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
7
- @process_types[$1] = $2
8
- else
9
- raise ArgumentError
10
- end
4
+ @process_types = Hash[file.lines.map &method(:decompose_line)]
5
+ end
6
+ def decompose_line line
7
+ if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
8
+ [$1, $2]
9
+ else
10
+ raise ArgumentError
11
11
  end
12
12
  end
13
- def tasks(concurrency, port)
13
+ def scale(concurrency, port)
14
14
  tasks = []
15
+ if concurrency.empty?
16
+ concurrency = Hash[process_types.keys.map { |name| [name, 1] }]
17
+ end
15
18
  concurrency.each do |(name, num)|
16
19
  num.times do |i|
17
20
  env = { "PORT" => (port + i) }
@@ -1 +1 @@
1
- Jefe::VERSION = "1.1.0"
1
+ Jefe::VERSION = "1.2.0"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jefe
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 31
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
- - 1
8
+ - 2
8
9
  - 0
9
- version: 1.1.0
10
+ version: 1.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Maltese
@@ -14,16 +15,17 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-04-01 00:00:00 -07:00
18
- default_executable:
18
+ date: 2012-04-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: eventmachine
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
28
+ hash: 3
27
29
  segments:
28
30
  - 0
29
31
  version: "0"
@@ -33,9 +35,11 @@ dependencies:
33
35
  name: micromachine
34
36
  prerelease: false
35
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
36
39
  requirements:
37
40
  - - ">="
38
41
  - !ruby/object:Gem::Version
42
+ hash: 3
39
43
  segments:
40
44
  - 0
41
45
  version: "0"
@@ -45,9 +49,11 @@ dependencies:
45
49
  name: thor
46
50
  prerelease: false
47
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
48
53
  requirements:
49
54
  - - ">="
50
55
  - !ruby/object:Gem::Version
56
+ hash: 3
51
57
  segments:
52
58
  - 0
53
59
  version: "0"
@@ -71,7 +77,6 @@ files:
71
77
  - lib/jefe.rb
72
78
  - bin/jefe
73
79
  - README.md
74
- has_rdoc: true
75
80
  homepage: http://github.com/mikemaltese/jefe
76
81
  licenses: []
77
82
 
@@ -81,23 +86,27 @@ rdoc_options: []
81
86
  require_paths:
82
87
  - - lib
83
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
84
90
  requirements:
85
91
  - - ">="
86
92
  - !ruby/object:Gem::Version
93
+ hash: 3
87
94
  segments:
88
95
  - 0
89
96
  version: "0"
90
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
91
99
  requirements:
92
100
  - - ">="
93
101
  - !ruby/object:Gem::Version
102
+ hash: 3
94
103
  segments:
95
104
  - 0
96
105
  version: "0"
97
106
  requirements: []
98
107
 
99
108
  rubyforge_project:
100
- rubygems_version: 1.3.6
109
+ rubygems_version: 1.8.22
101
110
  signing_key:
102
111
  specification_version: 3
103
112
  summary: The featherweight Procfile manager