cumuli 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bfa663cb4c3c5fcc6e5261054285825cc07d9cd
4
- data.tar.gz: 5b59ab58a2e88280208833e5f88f8b1a11572e69
3
+ metadata.gz: 1f273b5230330006e3325b4d0e314f98592cd613
4
+ data.tar.gz: f5888db3dd0621ae18b35f846ff03b1c22274b52
5
5
  SHA512:
6
- metadata.gz: 527d7f0339e41ad676c64a24787ae823ead0b1b9560b01a4707f2c7d3d1f641e8ee442dfb4a81968dff894a5bb089caf5cd5985e4a990ea7ed3c946a7c81de12
7
- data.tar.gz: 0484e05b60c25a9be15951c7838c2e6d602a85b8a4aa7bc224c7ca1ca79f2a8beb0887ce274b670a0ebd2b0ea7c2a7e3b785a6e35acf88a9a77c56b33929132d
6
+ metadata.gz: 55dbad295e1f5613786f87ae39c454b7b1817ce7325440258c164438f03dd74a1d11aec2f2d7734052d681672b680d525f3b27fc14b92f796f8b0052a6f74306
7
+ data.tar.gz: 6567664b296c3107bf61297e50d94c0cea1b6edeaf2a7fdcd19bdc000900bc2dc25173c8b85bcecea8d1a04cabf6825138658edf501297d7d8c3f718c6ddf2d2
data/README.md CHANGED
@@ -69,6 +69,25 @@ framework.
69
69
 
70
70
  app.stop # gracefully kills all the related processes
71
71
 
72
+ ### Running command line tools in remote directories
73
+
74
+ When working with a whole series of apps and processes, developers will need to run remote tasks that use that app's ruby version.
75
+ Cumuli has a solution, rake tasks that can be run in those remote locations:
76
+
77
+ rake cumuli:remote['rake db:migrate RAILS_ENV=test'] DIR=../../mactivator
78
+
79
+ The argument passed into the square brackets is the command that will be run in the directory with its Ruby environment. The DIR environmental
80
+ variable is where this command will be performed.
81
+
82
+ ### Other useful rake tasks
83
+
84
+ Sometimes things go wrong in the spinning up and spinning down of child processes. There are two rake files for inspecting and killing proceses that
85
+ are likely related to cumuli.
86
+
87
+ rake cumuli:ps # shows a list of all the related processes
88
+
89
+ rake cumuli:kill # kills all those processes shown above
90
+
72
91
  ## Known Issues
73
92
 
74
93
  If you start the Cumuli app and stop it the first time, it will successfully start and stop all processes. However, if you use the same Cumuli app class to
data/cumuli.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'cumuli/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "cumuli"
8
8
  spec.version = Cumuli::VERSION
9
- spec.authors = ["SocialChorus", "Kane Baccigalupi", "Fito von Zastrow", "Roy Pfaffman"]
9
+ spec.authors = ["SocialChorus", "Kane Baccigalupi", "Fito von Zastrow", "Roy Pfaffman", "Sowjanya Mudunuri"]
10
10
  spec.email = ["developers@socialchorus.com"]
11
11
  spec.description = %q{Cumuli runs several foreman processes in different directories}
12
12
  spec.summary = %q{Cumuli makes SOA on Heroku easier by delegating to Foreman in a Procfile}
@@ -5,7 +5,7 @@ module Cumuli
5
5
  RESET = "\033[0m"
6
6
 
7
7
  def print(message)
8
- puts "Nimbus: #{GRAY}#{message}#{RESET}"
8
+ puts "Cumuli: #{GRAY}#{message}#{RESET}"
9
9
  end
10
10
 
11
11
  def add_space
@@ -12,7 +12,7 @@ module Cumuli
12
12
  listen_for_signals
13
13
 
14
14
  Dir.chdir(args.dir) do
15
- command = Commander.new(args).build
15
+ command = Commander.new("foreman start #{args.foreman_options}").build
16
16
  puts "starting ... #{command}"
17
17
  spawn_terminal(command)
18
18
  end
@@ -1,14 +1,14 @@
1
1
  module Cumuli
2
2
  class CLI
3
3
  class Commander
4
- attr_reader :args
4
+ attr_reader :command
5
5
 
6
- def initialize(args)
7
- @args = args
6
+ def initialize(command)
7
+ @command = command
8
8
  end
9
9
 
10
10
  def build
11
- "#{rvm_preface} foreman start #{args.foreman_options}"
11
+ "#{rvm_preface} #{command}"
12
12
  end
13
13
 
14
14
  def rvm_preface
@@ -0,0 +1,42 @@
1
+ module Cumuli
2
+ class CLI
3
+ class RemoteCommand
4
+ attr_reader :argv
5
+
6
+ DIR_ENV = 'DIR='
7
+ COMMAND_ENV= 'COMMAND='
8
+
9
+ def initialize(argv)
10
+ @argv = argv
11
+ end
12
+
13
+ def extract_env(env_var)
14
+ found_arg = argv.detect{|arg| arg.include?(env_var)}
15
+ found_arg && found_arg.gsub(env_var, '')
16
+ end
17
+
18
+ def dir
19
+ extract_env(DIR_ENV)
20
+ end
21
+
22
+ def raw_command
23
+ extract_env(COMMAND_ENV) || get_passed_command
24
+ end
25
+
26
+ def get_passed_command
27
+ matched = argv.first.match(/\[(.*)\]/)
28
+ matched && matched[1]
29
+ end
30
+
31
+ def command
32
+ Commander.new(raw_command).build
33
+ end
34
+
35
+ def perform
36
+ Dir.chdir(dir) do
37
+ Terminal.new(command).spawn
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
data/lib/cumuli/cli.rb CHANGED
@@ -2,3 +2,4 @@ require "cumuli/cli/args"
2
2
  require "cumuli/cli/cli"
3
3
  require "cumuli/cli/commander"
4
4
  require "cumuli/cli/terminal"
5
+ require "cumuli/cli/remote_command"
@@ -1,6 +1,9 @@
1
- namespace :cumuli do
2
- require_relative "../ps"
1
+ require_relative "../ps"
2
+ require_relative "../cli/remote_command"
3
+ require_relative "../cli/commander"
4
+ require_relative "../cli/terminal"
3
5
 
6
+ namespace :cumuli do
4
7
  desc "kill the processes showing up in the nimbus:ps task"
5
8
  task :kill do
6
9
  Cumuli::PS.new.kill
@@ -10,4 +13,9 @@ namespace :cumuli do
10
13
  task :ps do
11
14
  puts Cumuli::PS.new.matching
12
15
  end
16
+
17
+ desc "run a remote command with the right ruby: rake cumuli:remote ../my_app rake db:migrate"
18
+ task :remote do |command|
19
+ Cumuli::CLI::RemoteCommand.new(ARGV).perform
20
+ end
13
21
  end
@@ -1,3 +1,3 @@
1
1
  module Cumuli
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/spec/app/app_spec.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Cumuli::App do
4
4
  describe '#start' do
5
- let(:opts) {
5
+ let(:opts) {
6
6
  {
7
7
  env: 'test',
8
8
  wait: false,
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  describe Cumuli::CLI::Args do
4
4
  let(:argv) { ["../mactivator", "-p", "4000"] }
5
5
  let(:args) { Cumuli::CLI::Args.new(argv) }
6
-
6
+
7
7
  it "#dir will return the first element passed in" do
8
8
  args.dir.should == "../mactivator"
9
9
  end
10
-
10
+
11
11
  it "#name is correctly determined from the directory" do
12
12
  args.name.should == 'mactivator'
13
13
  end
14
-
14
+
15
15
  it "#foreman_options should be a string representation of the rest of the arguments" do
16
16
  args.foreman_options.should == '-p 4000'
17
17
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Cumuli::CLI::Commander do
4
4
  describe "#build" do
5
- let(:args) { mock({foreman_options: 'foreman-options-here'}) }
6
- let(:commander) { Cumuli::CLI::Commander.new(args) }
5
+ let(:command) { 'foreman start -p 3030' }
6
+ let(:commander) { Cumuli::CLI::Commander.new(command) }
7
7
 
8
8
  context "application directory has no .rvmrc" do
9
9
  before do
@@ -26,8 +26,8 @@ describe Cumuli::CLI::Commander do
26
26
  end
27
27
  end
28
28
 
29
- it "ends with a call to foreman" do
30
- commander.build.should match(/foreman start foreman-options-here$/)
29
+ it "concludes with the command" do
30
+ commander.build.should match(/#{command}$/)
31
31
  end
32
32
 
33
33
  describe "reading from the file system" do
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cumuli::CLI::RemoteCommand do
4
+ let(:argv) { ["cumuli:remote[rake db:migrate]", "DIR=./mactivator"] }
5
+ let(:remote_command) { Cumuli::CLI::RemoteCommand.new(argv) }
6
+
7
+ it "parses the directory from the arguments" do
8
+ remote_command.dir.should == "./mactivator"
9
+ end
10
+
11
+ it "constructs a command using the Commander" do
12
+ commander = double(build: 'yup')
13
+ Cumuli::CLI::Commander.should_receive(:new)
14
+ .with("rake db:migrate")
15
+ .and_return(commander)
16
+ remote_command.command.should == 'yup'
17
+ end
18
+ end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cumuli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SocialChorus
8
8
  - Kane Baccigalupi
9
9
  - Fito von Zastrow
10
10
  - Roy Pfaffman
11
+ - Sowjanya Mudunuri
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2013-07-09 00:00:00.000000000 Z
15
+ date: 2013-07-16 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: foreman
@@ -96,6 +97,7 @@ files:
96
97
  - lib/cumuli/cli/args.rb
97
98
  - lib/cumuli/cli/cli.rb
98
99
  - lib/cumuli/cli/commander.rb
100
+ - lib/cumuli/cli/remote_command.rb
99
101
  - lib/cumuli/cli/terminal.rb
100
102
  - lib/cumuli/facade.rb
101
103
  - lib/cumuli/ps.rb
@@ -107,6 +109,7 @@ files:
107
109
  - spec/app/procs_spec.rb
108
110
  - spec/cli/args_spec.rb
109
111
  - spec/cli/commander_spec.rb
112
+ - spec/cli/remote_command_spec.rb
110
113
  - spec/cli/terminal_spec.rb
111
114
  - spec/fixtures/app_set/Procfile
112
115
  - spec/fixtures/app_set/loopy/.rvmrc
@@ -149,6 +152,7 @@ test_files:
149
152
  - spec/app/procs_spec.rb
150
153
  - spec/cli/args_spec.rb
151
154
  - spec/cli/commander_spec.rb
155
+ - spec/cli/remote_command_spec.rb
152
156
  - spec/cli/terminal_spec.rb
153
157
  - spec/fixtures/app_set/Procfile
154
158
  - spec/fixtures/app_set/loopy/.rvmrc