peas-cli 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1563acd00068fb352671fc5d5116dda66d42fb15
4
- data.tar.gz: e8f6d84f6a545e3d0d6e2b8fd5f8a38a48c44b73
3
+ metadata.gz: 7e21b1eaec8ee7ce0d7a7b76dbf2a0912c6eaa3c
4
+ data.tar.gz: 13c9d9ce95cfbebcea8cfb787ca9e0661f3c444a
5
5
  SHA512:
6
- metadata.gz: a0fcdcb620bef4ab17b0852c73e17fb464f5b06ccd65a9e2846312febe1fa88fc1f98a340329aa52a13ad820511e3f9dd7189641ecf4abd800bf132a9f757e9b
7
- data.tar.gz: f0ec4fdaf8822a33d3dd7cd3c7c4e5467030818b98d93ef18c6bfd6edcd599cfd35a2d6fd3d7f4f3a345d287b15621563eaf643797007829cf459540cb1e05c8
6
+ metadata.gz: 7405ef69c589de7140e5c463356b77d06f3836bd3788eca36401c74465ab6ced6ddc534f8bf362e69f26be829976d3d03466bb3511aa3c9a03ed491cd98064df
7
+ data.tar.gz: e377db4f59cc014a5cd10363d83d2235d11c55ea25c1cca358b8e833f68202d29283ba38b514acb75141239ded9f5f2f24cc311eb2f623a61699a3e8f755cf7f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/peas CHANGED
@@ -47,5 +47,10 @@ on_error do |exception|
47
47
  true
48
48
  end
49
49
 
50
+ # Exit 0 if sent SIGINT
51
+ trap('INT'){
52
+ exit!
53
+ }
54
+
50
55
  exit_status = run(ARGV)
51
56
  exit exit_status if ENV['GLI_ENV'] != 'test'
data/lib/peas/api.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'httparty'
2
+ require 'socket'
2
3
 
3
4
  class API
4
5
  include HTTParty
@@ -85,4 +86,8 @@ class API
85
86
  puts diff.join if diff.length > 0
86
87
  end
87
88
 
89
+ def self.switchboard_connection
90
+ TCPSocket.new Peas.host, Peas::SWITCHBOARD_PORT
91
+ end
92
+
88
93
  end
@@ -0,0 +1,13 @@
1
+ desc 'Show logs for an app'
2
+ command :logs do |c|
3
+ c.action do |global_options, options, args|
4
+ socket = API.switchboard_connection
5
+ socket.puts "stream_logs.#{Git.first_sha}"
6
+ begin
7
+ while line = socket.gets
8
+ puts line
9
+ end
10
+ rescue Interrupt, Errno::ECONNRESET
11
+ end
12
+ end
13
+ end
data/lib/peas/config.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  module Peas
2
2
 
3
+ # The port for Peas' Switchboard socket server
4
+ SWITCHBOARD_PORT = ENV['SWITCHBOARD_PORT'] || 9345
5
+
3
6
  def self.config_file
4
7
  "#{ENV['HOME']}/.peas"
5
8
  end
@@ -14,13 +17,22 @@ module Peas
14
17
 
15
18
  # Hierarchy of sources for the Peas API domain
16
19
  def self.api_domain
17
- if ENV['PEAS_API_ENDPOINT']
20
+ domain = if ENV['PEAS_API_ENDPOINT']
18
21
  ENV['PEAS_API_ENDPOINT']
19
22
  elsif Peas.config['domain']
20
23
  Peas.config['domain']
21
24
  else
22
25
  'localhost:4000'
23
26
  end
27
+ unless domain[/\Ahttp:\/\//] || domain[/\Ahttps:\/\//]
28
+ domain = "http://#{domain}"
29
+ else
30
+ domain
31
+ end
32
+ end
33
+
34
+ def self.host
35
+ URI.parse(Peas.api_domain).host
24
36
  end
25
37
 
26
38
  def self.error_message string
data/peas-cli.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: peas-cli 0.1.0 ruby lib
5
+ # stub: peas-cli 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "peas-cli"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Tom Buckley-Houston"]
14
- s.date = "2014-05-30"
14
+ s.date = "2014-06-14"
15
15
  s.description = "Peas is an open source Heroku-style PaaS written in Ruby and using Docker"
16
16
  s.email = "tom@tombh.co.uk"
17
17
  s.executables = ["peas", "peas-dev"]
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/peas/commands/admin.rb",
32
32
  "lib/peas/commands/app.rb",
33
33
  "lib/peas/commands/config.rb",
34
+ "lib/peas/commands/logs.rb",
34
35
  "lib/peas/config.rb",
35
36
  "lib/peas/git.rb",
36
37
  "lib/peas/version.rb",
data/spec/cli_spec.rb CHANGED
@@ -57,7 +57,7 @@ describe 'Peas CLI' do
57
57
  expect(output).to eq "scaling\n"
58
58
  end
59
59
 
60
- describe 'Config' do
60
+ describe 'Config ENV vars' do
61
61
  it 'should set config for an app' do
62
62
  stub_request(:put, TEST_DOMAIN + '/app/fakesha/config?vars=%7B%22FOO%22:%22BAR%22%7D')
63
63
  .to_return(body: response_mock("{'FOO' => 'BAR'}"))
@@ -81,6 +81,23 @@ describe 'Peas CLI' do
81
81
  end
82
82
  end
83
83
 
84
+ describe 'Logs' do
85
+ it 'should stream logs' do
86
+ stub_const 'Peas::SWITCHBOARD_PORT', 79345
87
+ Thread.new do
88
+ server = TCPServer.new Peas.host, Peas::SWITCHBOARD_PORT
89
+ if peer = server.accept
90
+ peer.puts "Here's ya logs"
91
+ peer.puts "MOAR logs"
92
+ peer.close
93
+ end
94
+ end
95
+ sleep 0.3
96
+ output = cli %w(logs)
97
+ expect(output).to eq "Here's ya logs\nMOAR logs\n"
98
+ end
99
+ end
100
+
84
101
  it 'should retrieve and output a long-running command' do
85
102
  stub_request(:get, /deploy/).to_return(body: '{"job": "123"}')
86
103
  stub_request(:get, /status/).to_return(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peas-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Buckley-Houston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -88,6 +88,7 @@ files:
88
88
  - lib/peas/commands/admin.rb
89
89
  - lib/peas/commands/app.rb
90
90
  - lib/peas/commands/config.rb
91
+ - lib/peas/commands/logs.rb
91
92
  - lib/peas/config.rb
92
93
  - lib/peas/git.rb
93
94
  - lib/peas/version.rb