alt-foreman 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alt-foreman.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/alt-foreman/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Geoff Youngs\n"]
6
+ gem.email = ["git@intersect-uk.co.uk"]
7
+ gem.description = %q{Lightweight procfile runner}
8
+ gem.summary = %q{rubbish dev version of foreman}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "alt-foreman"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Alt::Foreman::VERSION
17
+ gem.add_dependency "term-ansicolor"
18
+ end
data/bin/alt-foreman ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'alt-foreman'
4
+ require 'alt-foreman/process'
5
+
6
+ Dir.chdir(File.dirname(ARGV[0]))
7
+
8
+ if File.exist?('Gemfile')
9
+ ENV["BUNDLE_GEMFILE"]= File.expand_path("Gemfile")
10
+ end
11
+
12
+ processes = IO.readlines(ARGV[0]).map do |line|
13
+ line = line.chomp.gsub(/#.*$/, '')
14
+ if line =~ /:/
15
+ Alt::Foreman::Process.new(*line.split(/:/,2))
16
+ else
17
+ nil
18
+ end
19
+ end.compact
20
+
21
+ threads = processes.map do |process|
22
+ Thread.new { process.run }
23
+ end.each { |t| t.join }
24
+
@@ -0,0 +1,17 @@
1
+ module Alt
2
+ module Foreman
3
+ class Process
4
+ attr_reader :name, :cmd
5
+ def initialize(name, cmd)
6
+ @name, @cmd = name, cmd
7
+ end
8
+ def run
9
+ IO.popen(@cmd, 'rb') do |io|
10
+ while line = io.gets
11
+ Alt::Foreman.log(@name, line)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Alt
2
+ module Foreman
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ require "alt-foreman/version"
2
+ require 'thread'
3
+ require 'term/ansicolor'
4
+
5
+ module Alt
6
+ module Foreman
7
+ @mutex = Mutex.new
8
+ @senders = {}
9
+ @colours = [:blue, :red, :yellow, :cyan, :green]
10
+ def self.log(sender, line)
11
+ @mutex.synchronize do
12
+ colour = @senders[sender]
13
+ unless colour
14
+ colour = @senders[sender] = @colours[@senders.size % @colours.size]
15
+ end
16
+ puts Term::ANSIColor.send(colour, Term::ANSIColor.bold(sprintf '%s %15s | ', Time.now.strftime('%H:%M:%S'), sender) + line.chomp)
17
+ end
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alt-foreman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ! 'Geoff Youngs
9
+
10
+ '
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-10-26 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: term-ansicolor
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ description: Lightweight procfile runner
33
+ email:
34
+ - git@intersect-uk.co.uk
35
+ executables:
36
+ - alt-foreman
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - .gitignore
41
+ - Gemfile
42
+ - Rakefile
43
+ - alt-foreman.gemspec
44
+ - bin/alt-foreman
45
+ - lib/alt-foreman.rb
46
+ - lib/alt-foreman/process.rb
47
+ - lib/alt-foreman/version.rb
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: rubbish dev version of foreman
72
+ test_files: []
73
+ has_rdoc: