public
Description: A tool for controlling and configuring Merb applications
Homepage: http://crazycool.co.uk/2008/04/16/manage-your-merb
Clone URL: git://github.com/eldiablo/merb-manage.git
Made -c ARG glob pattern friendly - allows you to specify a single config 
file inside your app itself
fabien (author)
Mon May 05 19:17:19 -0700 2008
commit  52446bbc882b32e16be95f9f6244adbbb2a44908
tree    2f75db4da914193b1aade5e734578a008bac85d0
parent  ae1e1b8a972631c92c457f1b54eeffa5ddc7b778
...
1
 
2
3
4
...
7
8
9
10
 
11
12
13
14
15
 
16
17
 
18
19
20
...
22
23
24
25
 
26
27
28
...
52
53
54
55
 
56
57
58
59
60
61
 
62
63
64
65
 
66
67
68
69
70
 
71
72
73
74
75
 
76
77
...
 
1
2
3
4
...
7
8
9
 
10
11
12
13
14
 
15
16
 
17
18
19
20
...
22
23
24
 
25
26
27
28
...
52
53
54
 
55
56
57
58
59
60
 
61
62
63
64
 
65
66
67
68
69
 
70
71
72
73
74
 
75
76
77
0
@@ -1,4 +1,4 @@
0
-#!/usr/bin/ruby
0
+#!/usr/bin/env ruby
0
 #
0
 # Copyright (c) 2008 El Draper, el@eldiablo.co.uk
0
 #
0
@@ -7,14 +7,14 @@
0
 require "yaml"
0
 
0
 # Default config directory
0
-configuration_directory = "/etc/merb-manage"
0
+configuration_pattern = "/etc/merb-manage/*.yml"
0
 
0
 # This iterates through each config found in the configuration directory, executing the specified block for each
0
 def each_config(config, &block)
0
   begin
0
- Dir.entries(config).select { |e| e[e.length - 3, 3] == "yml" }.each do |yml|
0
+ Dir.glob(config) do |yml|
0
       begin
0
- result = yield YAML.load(open(File.join(config, yml)))
0
+ result = yield YAML.load(open(File.join(yml)))
0
         puts "#{yml}:"
0
         result.split("\n").each { |r| puts r }
0
       rescue Exception => err
0
@@ -22,7 +22,7 @@ def each_config(config, &block)
0
       end
0
     end
0
   rescue Errno::ENOENT
0
- puts "Unable to find directory - #{config}"
0
+ puts "Unable to find #{config}"
0
   rescue Errno::ENOTDIR
0
     puts "Not a directory - #{config}"
0
   end
0
@@ -52,25 +52,25 @@ end
0
 if ARGV.include?("-c")
0
   # Attempt to grab the specified config directory
0
   config = ARGV[ARGV.index("-c") + 1]
0
- configuration_directory = config unless config.nil?
0
+ configuration_pattern = config unless config.nil?
0
 end
0
 
0
 # Evaluate and execute the action being requested
0
 case ARGV[0]
0
   when "start":
0
- each_config(configuration_directory) do |yml|
0
+ each_config(configuration_pattern) do |yml|
0
       start(yml)
0
     end
0
   when "restart":
0
- each_config(configuration_directory) do |yml|
0
+ each_config(configuration_pattern) do |yml|
0
       stop(yml)
0
       start(yml)
0
     end
0
   when "stop":
0
- each_config(configuration_directory) do |yml|
0
+ each_config(configuration_pattern) do |yml|
0
       stop(yml)
0
     end
0
 else
0
   # Print out the usage as the arguments didn't match a known action
0
- puts "Usage: merb-manage-ctl {start|stop|restart} (-c CONFIG_DIR)"
0
+ puts "Usage: merb-manage-ctl {start|stop|restart} (-c CONFIG_GLOB)"
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.