threeman 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: f1e9986865f5793ca44df0526752032ba752ead8
4
- data.tar.gz: 2c67b7d65d24fde54a34edaecc1c948ca6462915
3
+ metadata.gz: b25bc984843d78d6720d7ed033b102702ee329b5
4
+ data.tar.gz: b8f40aad4965ee08615ddc75d30eb817ca766c2a
5
5
  SHA512:
6
- metadata.gz: 1f8d44ceb95cf54d61d99b604c6d741b12c56e2569d42e74cdb6f7b7580ef5d44ce5475cc6f9bd27deff532114d43d5451f863d79118e4680d5e5ad2f4d58761
7
- data.tar.gz: 8f00316bc0cf43729364a03ae1c1f1c453cc0686be6badf0b370bbaf50ac12e2ca4844c84152c518625acdcd94b68328d401553a7f1b3dd438df162afccdf01d
6
+ metadata.gz: c5a3094b8af3c5d285f01a01bb91e48b2277b44d95a9285ed69ead87013e8d230476e9782b775283c556605228623e1c20bab26f7f6fa9deb1079b66b2f85e3d
7
+ data.tar.gz: 5a0cd436300781c90ab7f0fd4f57575ca13c13d8b36c5ad75c77771f2bb4c1e5930532a17646a7d5fdd976b920c8f35830d830851fb2765779b982b01f6ddb24
@@ -1,3 +1,8 @@
1
+ # 0.3.0 - November 11, 2016
2
+
3
+ * Support tmux! (Thanks @sagotsky for his help.)
4
+ * Set the PORT environment variable
5
+
1
6
  # 0.2.1 - March 30, 2016
2
7
 
3
8
  * Split cd'ing into the workdir out of the bash script, so that if the process terminates you'll wind up in the right directory
@@ -10,6 +10,10 @@ module Threeman
10
10
  :mac_terminal => lambda {
11
11
  require 'threeman/frontends/mac_terminal'
12
12
  Threeman::Frontends::MacTerminal.new
13
+ },
14
+ :tmux => lambda {
15
+ require 'threeman/frontends/tmux'
16
+ Threeman::Frontends::Tmux.new
13
17
  }
14
18
  }
15
19
 
@@ -17,11 +21,12 @@ module Threeman
17
21
  default_task :start
18
22
 
19
23
  desc "start", "Start the application"
20
- option :frontend
24
+ option :frontend, desc: "Which frontend to use. One of: #{FRONTENDS.keys.sort.join(', ')}"
25
+ option :port, desc: "The port to run the application on. This will set the PORT environment variable.", type: :numeric, default: 5000
21
26
  def start
22
27
  pwd = Dir.pwd
23
28
  procfile = Threeman::Procfile.new(File.expand_path("Procfile", pwd))
24
- commands = procfile.commands(pwd)
29
+ commands = procfile.commands(pwd, options[:port])
25
30
 
26
31
  frontend_name = options[:frontend] || auto_frontend
27
32
  unless frontend_name
@@ -54,6 +59,11 @@ module Threeman
54
59
  if File.exist?('/Applications/Utilities/Terminal.app/Contents/Info.plist')
55
60
  return :mac_terminal
56
61
  end
62
+
63
+ `which tmux`
64
+ if $?.success?
65
+ return :tmux
66
+ end
57
67
  end
58
68
 
59
69
  def print_valid_frontend_names
@@ -2,16 +2,17 @@ require 'shellwords'
2
2
 
3
3
  module Threeman
4
4
  class Command
5
- attr_accessor :name, :command, :workdir
5
+ attr_accessor :name, :command, :workdir, :port
6
6
 
7
- def initialize(name, command, workdir)
7
+ def initialize(name, command, workdir, port)
8
8
  @name = name
9
9
  @command = command
10
10
  @workdir = workdir
11
+ @port = port
11
12
  end
12
13
 
13
14
  def bash_script
14
- command
15
+ "PORT=#{port} #{command}"
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,33 @@
1
+ require 'threeman/frontend'
2
+
3
+ module Threeman
4
+ module Frontends
5
+ class Tmux < Threeman::Frontend
6
+ attr_reader :session
7
+
8
+ def initialize
9
+ @session = "threeman_#{Time.now.to_i}"
10
+ end
11
+
12
+ def run_commands(commands)
13
+ commands.each_with_index do |command, index|
14
+ run_command(command, index)
15
+ end
16
+
17
+ system "tmux attach-session -t #{session}"
18
+ end
19
+
20
+ private
21
+ def run_command(command, index)
22
+ bash_cmd = "bash -c #{Shellwords.escape bash_script(command)}"
23
+
24
+ common_opts = "-n #{Shellwords.escape command.name} -c #{Shellwords.escape command.workdir} #{Shellwords.escape bash_cmd}"
25
+ if index == 0
26
+ system "tmux new-session -d -s #{session} #{common_opts}"
27
+ else
28
+ system "tmux -v new-window -t #{session}:#{index} #{common_opts}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -3,11 +3,11 @@ require 'threeman/command'
3
3
 
4
4
  module Threeman
5
5
  class Procfile < Foreman::Procfile
6
- def commands(workdir)
6
+ def commands(workdir, port)
7
7
  commands = []
8
8
 
9
9
  entries do |name, command|
10
- commands << Threeman::Command.new(name, command, workdir)
10
+ commands << Threeman::Command.new(name, command, workdir, port)
11
11
  end
12
12
 
13
13
  commands
@@ -1,3 +1,3 @@
1
1
  module Threeman
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: threeman
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
  - Nat Budin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman
@@ -120,6 +120,7 @@ files:
120
120
  - lib/threeman/frontend.rb
121
121
  - lib/threeman/frontends/iterm3.rb
122
122
  - lib/threeman/frontends/mac_terminal.rb
123
+ - lib/threeman/frontends/tmux.rb
123
124
  - lib/threeman/procfile.rb
124
125
  - lib/threeman/version.rb
125
126
  - threeman.gemspec
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  requirements: []
145
146
  rubyforge_project:
146
- rubygems_version: 2.4.5.1
147
+ rubygems_version: 2.2.2
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: Runs Procfile commands in iTerm 2 tabs