invoker 1.2.0.pre1 → 1.2.0.pre2

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: b5f7948dc467e955d06dc212305b0d58dea40073
4
- data.tar.gz: 1c4a51d9cc8657a266abcc5c20ec994a5419cbb9
3
+ metadata.gz: 0522d780189e4589e2b918f4b3618ca6b84b0759
4
+ data.tar.gz: fd335e383fde399c6970a287c07d5b24ca5a7f6e
5
5
  SHA512:
6
- metadata.gz: 80c642caaff5297ecc6cacbadc33c0e3a5261f61e72d621e0c5e512cec982e296c1e3434805da300f3a3c4a83a320d70e66fc2ffed3187f6a567c9965021c4c3
7
- data.tar.gz: e55662e5c00a63f54223ba93a550ae25a71d7e8eb89d778dd03b6495145ef9295460288b171456392c1a0fc028dedb904fb106b1b4a73817025672fae9856a45
6
+ metadata.gz: cc0847a296deb3db14ac14342a3c7acdd42bd1642954aff5807333bf71699793d29d488f89477df843a12fb451af4e6dc4b379b02926b70dd050c4bfaf8680c1
7
+ data.tar.gz: 2a24694f1ebf7262478a376b7b23a4fcdf3386cfbf55101e0380299e34414ed8805e993f3f4bb45c0b2e429890922907f55d65c38c735417eede8336e8fb5436
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'pry'
6
- gem "rubydns", git: "git@github.com:ioquatix/rubydns.git"
6
+ gem "rubydns", git: "https://github.com/ioquatix/rubydns.git"
7
7
 
8
8
  gem 'coveralls', require: false
9
9
  gem "simplecov", require: false
data/invoker.gemspec CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_dependency("em-proxy", "~> 0.1")
34
34
  s.add_dependency("rubydns", "~> 0.7")
35
35
  s.add_dependency("uuid", "~> 2.3")
36
+ s.add_dependency("facter", "~> 2.0")
36
37
  s.add_dependency("http-parser-lite", "~> 0.6")
37
38
  s.add_dependency("dotenv", "~> 0.9")
38
39
  s.add_development_dependency("rspec")
data/lib/invoker.rb CHANGED
@@ -8,6 +8,7 @@ require "uuid"
8
8
  require "json"
9
9
  require "rainbow"
10
10
  require "rainbow/ext/string"
11
+ require "etc"
11
12
 
12
13
  require "invoker/version"
13
14
  require "invoker/logger"
@@ -64,7 +65,7 @@ module Invoker
64
65
  end
65
66
 
66
67
  def can_run_balancer?(throw_warning = true)
67
- return true if File.exist?(Invoker::Power::Config::CONFIG_LOCATION)
68
+ return true if File.exist?(Invoker::Power::Config.config_file)
68
69
 
69
70
  if throw_warning
70
71
  Invoker::Logger.puts("Invoker has detected setup has not been run. Domain feature will not work without running setup command.".color(:red))
@@ -73,18 +74,18 @@ module Invoker
73
74
  end
74
75
 
75
76
  def setup_config_location
76
- config_location = File.join(Dir.home, '.invoker')
77
- return config_location if Dir.exist?(config_location)
77
+ config_dir = Invoker::Power::Config.config_dir
78
+ return config_dir if Dir.exist?(config_dir)
78
79
 
79
- if File.exist?(config_location)
80
- old_config = File.read(config_location)
81
- FileUtils.rm_f(config_location)
80
+ if File.exist?(config_dir)
81
+ old_config = File.read(config_dir)
82
+ FileUtils.rm_f(config_dir)
82
83
  end
83
84
 
84
- FileUtils.mkdir(config_location)
85
+ FileUtils.mkdir(config_dir)
85
86
 
86
- migrate_old_config(old_config, config_location) if old_config
87
- config_location
87
+ migrate_old_config(old_config, config_dir) if old_config
88
+ config_dir
88
89
  end
89
90
 
90
91
  def run_without_bundler
@@ -116,5 +117,18 @@ module Invoker
116
117
  file.write(old_config)
117
118
  end
118
119
  end
120
+
121
+ # On some platforms `Dir.home` or `ENV['HOME']` does not return home directory of user.
122
+ # this is especially true, after effective and real user id of process
123
+ # has been changed.
124
+ #
125
+ # @return [String] home directory of the user
126
+ def home
127
+ if File.writable?(Dir.home)
128
+ Dir.home
129
+ else
130
+ Etc.getpwuid(Process.uid).dir
131
+ end
132
+ end
119
133
  end
120
134
  end
@@ -24,7 +24,7 @@ module Invoker
24
24
  end
25
25
 
26
26
  def pid_file
27
- File.join(Dir.home, ".invoker", "#{process_name}.pid")
27
+ File.join(Invoker.home, ".invoker", "#{process_name}.pid")
28
28
  end
29
29
 
30
30
  def pid
@@ -32,7 +32,7 @@ module Invoker
32
32
  end
33
33
 
34
34
  def log_file
35
- File.join(Dir.home, ".invoker", "#{process_name}.log")
35
+ File.join(Invoker.home, ".invoker", "#{process_name}.log")
36
36
  end
37
37
 
38
38
  def daemonize
@@ -1,5 +1,6 @@
1
1
  require 'em-proxy'
2
2
  require 'http-parser'
3
+ require "invoker/power/http_parser"
3
4
 
4
5
  module Invoker
5
6
  module Power
@@ -19,37 +20,6 @@ module Invoker
19
20
  end
20
21
  end
21
22
 
22
- class BalancerParser
23
- attr_accessor :host, :parser
24
- def initialize
25
- @parser = HTTP::Parser.new()
26
- @header = {}
27
- @parser.on_headers_complete { headers_received() }
28
- @parser.on_header_field { |field_name|
29
- @last_key = field_name
30
- }
31
- @parser.on_header_value { |value| header_value_received(value) }
32
- end
33
-
34
- def headers_received
35
- @header_completion_callback.call(@header)
36
- end
37
-
38
- def header_value_received(value)
39
- @header[@last_key] = value
40
- end
41
-
42
- def on_headers_complete(&block)
43
- @header_completion_callback = block
44
- end
45
-
46
- def reset; @parser.reset(); end
47
-
48
- def <<(data)
49
- @parser << data
50
- end
51
- end
52
-
53
23
  class Balancer
54
24
  attr_accessor :connection, :http_parser, :session, :protocol
55
25
  DEV_MATCH_REGEX = /([\w-]+)\.dev(\:\d+)?$/
@@ -71,49 +41,42 @@ module Invoker
71
41
  def initialize(connection, protocol)
72
42
  @connection = connection
73
43
  @protocol = protocol
74
- @http_parser = BalancerParser.new()
44
+ @http_parser = HttpParser.new(protocol)
75
45
  @session = nil
76
46
  @buffer = []
77
47
  end
78
48
 
79
- # insert X_FORWARDED_PROTO_ so as rails can identify the request as coming from
80
- # https
81
- def insert_forwarded_proto_header(data)
82
- if data =~ /\r\n\r\n/ && data !~ /X_FORWARDED_PROTO/i && protocol == 'https'
83
- data.gsub(/\r\n\r\n/, "\r\nX_FORWARDED_PROTO: #{protocol}\r\n\r\n")
84
- else
85
- data
86
- end
87
- end
88
-
89
49
  def install_callbacks
90
- http_parser.on_headers_complete { |header| headers_received(header) }
50
+ http_parser.on_headers_complete { |headers| headers_received(headers) }
51
+ http_parser.on_message_complete { |full_message| complete_message_received(full_message) }
91
52
  connection.on_data { |data| upstream_data(data) }
92
53
  connection.on_response { |backend, data| backend_data(backend, data) }
93
54
  connection.on_finish { |backend, name| frontend_disconnect(backend, name) }
94
55
  end
95
56
 
96
- def headers_received(header)
57
+ def complete_message_received(full_message)
58
+ connection.relay_to_servers(full_message)
59
+ http_parser.reset
60
+ end
61
+
62
+ def headers_received(headers)
63
+ if @session
64
+ return
65
+ end
97
66
  @session = UUID.generate()
98
- dns_check_response = select_backend_config(header['Host'])
67
+ dns_check_response = select_backend_config(headers['Host'])
99
68
  if dns_check_response && dns_check_response.port
100
69
  connection.server(session, host: '0.0.0.0', port: dns_check_response.port)
101
- connection.relay_to_servers(insert_forwarded_proto_header(@buffer.join))
102
- @buffer = []
103
70
  else
104
71
  return_error_page(404)
72
+ http_parser.reset
105
73
  connection.close_connection_after_writing
106
74
  end
107
75
  end
108
76
 
109
77
  def upstream_data(data)
110
- unless session
111
- @buffer << data
112
- append_for_http_parsing(data)
113
- nil
114
- else
115
- insert_forwarded_proto_header(data)
116
- end
78
+ append_for_http_parsing(data)
79
+ nil
117
80
  end
118
81
 
119
82
  def append_for_http_parsing(data)
@@ -131,7 +94,6 @@ module Invoker
131
94
  def frontend_disconnect(backend, name)
132
95
  http_parser.reset
133
96
  unless @backend_data
134
- Invoker::Logger.puts("\nApplication #{name} not running. Returning error page.".color(:red))
135
97
  return_error_page(503)
136
98
  end
137
99
  @backend_data = false
@@ -6,32 +6,38 @@ module Invoker
6
6
  class ConfigExists < StandardError; end
7
7
 
8
8
  class Config
9
- CONFIG_LOCATION = File.join(Dir.home, ".invoker", "config")
10
-
11
9
  def self.has_config?
12
- File.exist?(CONFIG_LOCATION)
10
+ File.exist?(config_file)
13
11
  end
14
12
 
15
13
  def self.create(options = {})
16
14
  if has_config?
17
- raise ConfigExists, "Config file already exists at location #{CONFIG_LOCATION}"
15
+ raise ConfigExists, "Config file already exists at location #{config_file}"
18
16
  end
19
17
  config = new(options)
20
18
  config.save
21
19
  end
22
20
 
23
21
  def self.delete
24
- if File.exist?(CONFIG_LOCATION)
25
- File.delete(CONFIG_LOCATION)
22
+ if File.exist?(config_file)
23
+ File.delete(config_file)
26
24
  end
27
25
  end
28
26
 
27
+ def self.config_file
28
+ File.join(Invoker.home, ".invoker", "config")
29
+ end
30
+
31
+ def self.config_dir
32
+ File.join(Invoker.home, ".invoker")
33
+ end
34
+
29
35
  def initialize(options = {})
30
36
  @config = options
31
37
  end
32
38
 
33
39
  def self.load_config
34
- config_hash = File.open(CONFIG_LOCATION, "r") { |fl| YAML.load(fl) }
40
+ config_hash = File.open(config_file, "r") { |fl| YAML.load(fl) }
35
41
  new(config_hash)
36
42
  end
37
43
 
@@ -60,7 +66,7 @@ module Invoker
60
66
  end
61
67
 
62
68
  def save
63
- File.open(CONFIG_LOCATION, "w") do |fl|
69
+ File.open(self.class.config_file, "w") do |fl|
64
70
  YAML.dump(@config, fl)
65
71
  end
66
72
  self
@@ -0,0 +1,68 @@
1
+ module Invoker
2
+ module Power
3
+ class HttpParser
4
+ attr_accessor :host, :parser, :protocol
5
+
6
+ def initialize(protocol)
7
+ @protocol = protocol
8
+ @parser = HTTP::Parser.new
9
+ @header = {}
10
+ initialize_message_content
11
+ parser.on_headers_complete { complete_headers_received }
12
+ parser.on_header_field { |field_name| @last_key = field_name }
13
+ parser.on_header_value { |field_value| header_value_received(field_value) }
14
+
15
+ parser.on_message_complete { complete_message_received }
16
+ end
17
+
18
+ # define a callback for invoking when complete header is parsed
19
+ def on_headers_complete(&block)
20
+ @on_headers_complete_callback = block
21
+ end
22
+
23
+ def header_value_received(value)
24
+ @header[@last_key] = value
25
+ end
26
+
27
+ # define a callback to invoke when a full http message is received
28
+ def on_message_complete(&block)
29
+ @on_message_complete_callback = block
30
+ end
31
+
32
+ def reset
33
+ @header = {}
34
+ initialize_message_content
35
+ parser.reset
36
+ end
37
+
38
+ def << data
39
+ @full_message.write(data)
40
+ parser << data
41
+ end
42
+
43
+ private
44
+
45
+ def complete_message_received
46
+ full_message_string = @full_message.string.dup
47
+ if full_message_string =~ /\r\n\r\n/
48
+ full_message_string.sub!(/\r\n\r\n/, "\r\nX_FORWARDED_PROTO: #{protocol}\r\n\r\n")
49
+ end
50
+ if @on_message_complete_callback
51
+ @on_message_complete_callback.call(full_message_string)
52
+ end
53
+ end
54
+
55
+ def initialize_message_content
56
+ @full_message = StringIO.new
57
+ @full_message.set_encoding('ASCII-8BIT')
58
+ end
59
+
60
+ # gets invoker when complete header is received
61
+ def complete_headers_received
62
+ if @on_headers_complete_callback
63
+ @on_headers_complete_callback.call(@header)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -44,7 +44,7 @@ module Invoker
44
44
  end
45
45
 
46
46
  def check_if_setup_can_run?
47
- !File.exists?(Invoker::Power::Config::CONFIG_LOCATION)
47
+ !File.exists?(Invoker::Power::Config.config_file)
48
48
  end
49
49
  end
50
50
  end
@@ -0,0 +1,41 @@
1
+ module Invoker
2
+ module Power
3
+ module Distro
4
+ class Base
5
+ RESOLVER_FILE = "/etc/dnsmasq.d/dev-tld"
6
+ RINETD_FILE = "/etc/rinetd.conf"
7
+
8
+ def self.distro_installer
9
+ case Facter[:operatingsystem].value
10
+ when "Ubuntu"
11
+ require "invoker/power/setup/distro/ubuntu"
12
+ Ubuntu.new
13
+ when "Fedora"
14
+ require "invoker/power/setup/distro/redhat"
15
+ Redhat.new
16
+ else
17
+ raise "Your selected distro is not supported by Invoker"
18
+ end
19
+ end
20
+
21
+ def resolver_file
22
+ RESOLVER_FILE
23
+ end
24
+
25
+ def rinetd_file
26
+ RINETD_FILE
27
+ end
28
+
29
+ # Install required software
30
+ def install_required_software
31
+ raise "Unimplemented"
32
+ end
33
+
34
+ def restart_services
35
+ system("service rinetd restart")
36
+ system("service dnsmasq restart")
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ module Invoker
2
+ module Power
3
+ module Distro
4
+ class Redhat < Base
5
+ def install_required_software
6
+ system("yum --assumeyes install dnsmasq rinetd")
7
+ end
8
+
9
+ def restart_services
10
+ system("systemctl enable rinetd")
11
+ system("service rinetd restart")
12
+ system("service dnsmasq restart")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Invoker
2
+ module Power
3
+ module Distro
4
+ class Ubuntu < Base
5
+ def install_required_software
6
+ system("apt-get --assume-yes install dnsmasq rinetd")
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,16 +1,19 @@
1
+ require "invoker/power/setup/distro/base"
2
+ require "facter"
3
+
1
4
  module Invoker
2
5
  module Power
3
6
  class LinuxSetup < Setup
4
- RESOLVER_FILE = "/etc/dnsmasq.d/dev-tld"
5
- RINETD_FILE = "/etc/rinetd.conf"
7
+ attr_accessor :distro_installer
6
8
 
7
9
  def setup_invoker
8
10
  if get_user_confirmation?
11
+ initialize_distro_installer
9
12
  find_open_ports
10
- install_required_software
13
+ distro_installer.install_required_software
11
14
  install_resolver
12
15
  install_port_forwarder
13
- restart_services
16
+ distro_installer.restart_services
14
17
  drop_to_normal_user
15
18
  create_config_file
16
19
  else
@@ -34,23 +37,18 @@ module Invoker
34
37
 
35
38
  private
36
39
 
37
- def restart_services
38
- system("/etc/init.d/rinetd restart")
39
- system("/etc/init.d/dnsmasq restart")
40
- end
41
-
42
- def install_required_software
43
- system("apt-get --assume-yes install dnsmasq rinetd")
40
+ def initialize_distro_installer
41
+ @distro_installer = Invoker::Power::Distro::Base.distro_installer
44
42
  end
45
43
 
46
44
  def install_resolver
47
- File.open(RESOLVER_FILE, "w") do |fl|
45
+ File.open(distro_installer.resolver_file, "w") do |fl|
48
46
  fl.write(tld_setup)
49
47
  end
50
48
  end
51
49
 
52
50
  def install_port_forwarder
53
- File.open(RINETD_FILE, "a") do |fl|
51
+ File.open(distro_installer.rinetd_file, "a") do |fl|
54
52
  fl << "\n"
55
53
  fl << rinetd_setup(port_finder.http_port, port_finder.https_port)
56
54
  end
@@ -1,3 +1,3 @@
1
1
  module Invoker
2
- VERSION = "1.2.0.pre1"
2
+ VERSION = "1.2.0.pre2"
3
3
  end
@@ -114,7 +114,7 @@ command = ls
114
114
  end
115
115
 
116
116
  it "loads config if platform is darwin and power config file exists" do
117
- File.open(Invoker::Power::Config::CONFIG_LOCATION, "w") { |fl| fl.puts "sample" }
117
+ File.open(Invoker::Power::Config.config_file, "w") { |fl| fl.puts "sample" }
118
118
  Invoker::Power::Config.expects(:load_config).once
119
119
  Invoker::Parsers::Config.new(@file.path, 9000)
120
120
  end
@@ -19,7 +19,7 @@ describe "Invoker" do
19
19
  end
20
20
 
21
21
  it "should return true if setup was run properly" do
22
- File.open(Invoker::Power::Config::CONFIG_LOCATION, "w") {|fl|
22
+ File.open(Invoker::Power::Config.config_file, "w") {|fl|
23
23
  fl.write("hello")
24
24
  }
25
25
  expect(Invoker.can_run_balancer?).to be_true
@@ -61,4 +61,10 @@ describe "Invoker" do
61
61
  end
62
62
  end
63
63
  end
64
+
65
+ describe "#home" do
66
+ it "should return home directory using etc module" do
67
+ expect(Invoker.home).to eql ENV['HOME']
68
+ end
69
+ end
64
70
  end
@@ -3,22 +3,15 @@ require "spec_helper"
3
3
  describe "Invoker Power configuration" do
4
4
  describe "#create" do
5
5
  it "should create a config file given a hash" do
6
- begin
7
- File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
8
- File.delete(Invoker::Power::Config::CONFIG_LOCATION)
9
- config = Invoker::Power::Config.create(
10
- dns_port: 1200, http_port: 1201, ipfw_rule_number: 010
11
- )
12
- expect(File.exists?(Invoker::Power::Config::CONFIG_LOCATION)).to be_true
6
+ config = Invoker::Power::Config.create(
7
+ dns_port: 1200, http_port: 1201, ipfw_rule_number: 010
8
+ )
9
+ expect(File.exist?(Invoker::Power::Config.config_file)).to be_true
13
10
 
14
- config = Invoker::Power::Config.load_config()
15
- expect(config.dns_port).to eq(1200)
16
- expect(config.http_port).to eq(1201)
17
- expect(config.ipfw_rule_number).to eq(010)
18
- ensure
19
- File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
20
- File.delete(Invoker::Power::Config::CONFIG_LOCATION)
21
- end
11
+ config = Invoker::Power::Config.load_config()
12
+ expect(config.dns_port).to eq(1200)
13
+ expect(config.http_port).to eq(1201)
14
+ expect(config.ipfw_rule_number).to eq(010)
22
15
  end
23
16
  end
24
17
  end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Invoker::Power::HttpParser do
4
+ let(:parser) { Invoker::Power::HttpParser.new('https') }
5
+
6
+ describe "complete message received" do
7
+ before { parser.reset }
8
+ it "should call header received with full header" do
9
+ @header = nil
10
+ parser.on_headers_complete { |header| @header = header }
11
+ parser << "HTTP/1.1 200 OK\r\n"
12
+ parser << "Content-Type: text/plain;charset=utf-8\r\n"
13
+ parser << "Content-Length: 5\r\n"
14
+ parser << "Connection: close\r\n\r\n"
15
+ parser << "hello"
16
+
17
+ expect(@header['Content-Type']).to eql "text/plain;charset=utf-8"
18
+ end
19
+
20
+ it "should return complete message with x_forwarded added" do
21
+ complete_message = nil
22
+ parser.on_message_complete { |message| complete_message = message }
23
+ parser.on_headers_complete { |header| @header = header }
24
+ parser << "HTTP/1.1 200 OK\r\n"
25
+ parser << "Content-Type: text/plain;charset=utf-8\r\n"
26
+ parser << "Content-Length: 5\r\n"
27
+ parser << "Connection: close\r\n\r\n"
28
+ parser << "hello"
29
+ expect(complete_message).to match(/X_FORWARDED_PROTO:/i)
30
+ end
31
+ end
32
+ end
@@ -1,16 +1,23 @@
1
1
  require "spec_helper"
2
+ require "invoker/power/setup/distro/ubuntu"
2
3
 
3
4
  describe Invoker::Power::LinuxSetup do
4
5
  let(:invoker_setup) { Invoker::Power::LinuxSetup.new }
6
+ let(:distro_installer) { Invoker::Power::Distro::Ubuntu.new }
7
+
5
8
  describe "should only proceed after user confirmation" do
9
+ before { invoker_setup.distro_installer = distro_installer }
10
+
6
11
  it "should create config file with port" do
12
+ invoker_setup.expects(:initialize_distro_installer).returns(true)
7
13
  invoker_setup.expects(:get_user_confirmation?).returns(true)
8
- invoker_setup.expects(:install_required_software).returns(true)
9
14
  invoker_setup.expects(:install_resolver).returns(true)
10
15
  invoker_setup.expects(:install_port_forwarder).returns(true)
11
- invoker_setup.expects(:restart_services).returns(true)
12
16
  invoker_setup.expects(:drop_to_normal_user).returns(true)
13
17
 
18
+ distro_installer.expects(:install_required_software)
19
+ distro_installer.expects(:restart_services)
20
+
14
21
  invoker_setup.setup_invoker
15
22
 
16
23
  config = Invoker::Power::Config.load_config
@@ -21,21 +28,25 @@ describe Invoker::Power::LinuxSetup do
21
28
  end
22
29
 
23
30
  describe "configuring dnsmasq and rinetd" do
31
+ before { invoker_setup.distro_installer = distro_installer }
32
+
24
33
  it "should create proper config file" do
34
+ invoker_setup.expects(:initialize_distro_installer).returns(true)
25
35
  invoker_setup.expects(:get_user_confirmation?).returns(true)
26
- invoker_setup.expects(:install_required_software).returns(true)
27
- invoker_setup.expects(:restart_services).returns(true)
28
36
  invoker_setup.expects(:drop_to_normal_user).returns(true)
29
37
 
38
+ distro_installer.expects(:install_required_software)
39
+ distro_installer.expects(:restart_services)
40
+
30
41
  invoker_setup.setup_invoker
31
42
 
32
43
  config = Invoker::Power::Config.load_config
33
44
 
34
- dnsmasq_content = File.read(Invoker::Power::LinuxSetup::RESOLVER_FILE)
45
+ dnsmasq_content = File.read(distro_installer.resolver_file)
35
46
  expect(dnsmasq_content.strip).to_not be_empty
36
47
  expect(dnsmasq_content).to match(/dev/)
37
48
 
38
- rinetd_content = File.read(Invoker::Power::LinuxSetup::RINETD_FILE)
49
+ rinetd_content = File.read(distro_installer.rinetd_file)
39
50
  expect(rinetd_content.strip).to_not be_empty
40
51
  expect(rinetd_content.strip).to match(/#{config.https_port}/)
41
52
  expect(rinetd_content.strip).to match(/#{config.http_port}/)
@@ -20,7 +20,7 @@ describe Invoker::Power::OsxSetup do
20
20
 
21
21
  describe "when a setup file exists" do
22
22
  it "should throw error about existing file" do
23
- File.open(Invoker::Power::Config::CONFIG_LOCATION, "w") {|fl|
23
+ File.open(Invoker::Power::Config.config_file, "w") {|fl|
24
24
  fl.write("foo test")
25
25
  }
26
26
  Invoker::Power::Setup.any_instance.expects(:setup_invoker).never
@@ -23,16 +23,14 @@ module MockSetupFile
23
23
  private
24
24
 
25
25
  def setup_invoker_config
26
- @old_config = Invoker::Power::Config::CONFIG_LOCATION
27
- Invoker::Power::Config.const_set(:CONFIG_LOCATION, "/tmp/.invoker/config")
26
+ Invoker::Power::Config.stubs(:config_file).returns("/tmp/.invoker/config")
27
+ Invoker::Power::Config.stubs(:config_dir).returns("/tmp/.invoker")
28
28
  safe_make_directory("/tmp/.invoker")
29
- safe_remove_file(Invoker::Power::Config::CONFIG_LOCATION)
29
+ safe_remove_file(Invoker::Power::Config.config_file)
30
30
  end
31
31
 
32
32
  def restore_invoker_config
33
- safe_remove_file(Invoker::Power::Config::CONFIG_LOCATION)
34
- Invoker::Power::Config.const_set(:CONFIG_LOCATION, @old_config)
35
- $VERBOSE = @original_verbosity
33
+ safe_remove_file(Invoker::Power::Config.config_file)
36
34
  end
37
35
 
38
36
  def restore_osx_resolver_setup
@@ -51,18 +49,16 @@ module MockSetupFile
51
49
  end
52
50
 
53
51
  def setup_linux_resolver_path
54
- @old_linux_resolver = Invoker::Power::LinuxSetup::RESOLVER_FILE
55
- @old_rinetd_config = Invoker::Power::LinuxSetup::RINETD_FILE
56
- Invoker::Power::LinuxSetup.const_set(:RESOLVER_FILE, "/tmp/dev-tld")
57
- Invoker::Power::LinuxSetup.const_set(:RINETD_FILE, "/tmp/rinetd.conf")
58
- safe_remove_file(Invoker::Power::LinuxSetup::RESOLVER_FILE)
59
- safe_remove_file(Invoker::Power::LinuxSetup::RINETD_FILE)
52
+ @old_linux_resolver = Invoker::Power::Distro::Base::RESOLVER_FILE
53
+ @old_rinetd_config = Invoker::Power::Distro::Base::RINETD_FILE
54
+ Invoker::Power::Distro::Base.const_set(:RESOLVER_FILE, "/tmp/dev-tld")
55
+ Invoker::Power::Distro::Base.const_set(:RINETD_FILE, "/tmp/rinetd.conf")
60
56
  end
61
57
 
62
58
  def restore_linux_resolver_path
63
- safe_remove_file(Invoker::Power::LinuxSetup::RESOLVER_FILE)
64
- safe_remove_file(Invoker::Power::LinuxSetup::RINETD_FILE)
65
- Invoker::Power::LinuxSetup.const_set(:RESOLVER_FILE, @old_linux_resolver)
66
- Invoker::Power::LinuxSetup.const_set(:RINETD_FILE, @old_rinetd_config)
59
+ safe_remove_file(Invoker::Power::Distro::Base::RESOLVER_FILE)
60
+ safe_remove_file(Invoker::Power::Distro::Base::RINETD_FILE)
61
+ Invoker::Power::Distro::Base.const_set(:RESOLVER_FILE, @old_linux_resolver)
62
+ Invoker::Power::Distro::Base.const_set(:RINETD_FILE, @old_rinetd_config)
67
63
  end
68
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.pre1
4
+ version: 1.2.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hemant Kumar
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-26 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -123,6 +123,20 @@ dependencies:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '2.3'
126
+ - !ruby/object:Gem::Dependency
127
+ name: facter
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '2.0'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.0'
126
140
  - !ruby/object:Gem::Dependency
127
141
  name: http-parser-lite
128
142
  requirement: !ruby/object:Gem::Requirement
@@ -245,11 +259,15 @@ files:
245
259
  - lib/invoker/power/balancer.rb
246
260
  - lib/invoker/power/config.rb
247
261
  - lib/invoker/power/dns.rb
262
+ - lib/invoker/power/http_parser.rb
248
263
  - lib/invoker/power/http_response.rb
249
264
  - lib/invoker/power/port_finder.rb
250
265
  - lib/invoker/power/power.rb
251
266
  - lib/invoker/power/powerup.rb
252
267
  - lib/invoker/power/setup.rb
268
+ - lib/invoker/power/setup/distro/base.rb
269
+ - lib/invoker/power/setup/distro/redhat.rb
270
+ - lib/invoker/power/setup/distro/ubuntu.rb
253
271
  - lib/invoker/power/setup/linux_setup.rb
254
272
  - lib/invoker/power/setup/osx_setup.rb
255
273
  - lib/invoker/power/templates/404.html
@@ -276,6 +294,7 @@ files:
276
294
  - spec/invoker/ipc/unix_client_spec.rb
277
295
  - spec/invoker/power/balancer_spec.rb
278
296
  - spec/invoker/power/config_spec.rb
297
+ - spec/invoker/power/http_parser_spec.rb
279
298
  - spec/invoker/power/http_response_spec.rb
280
299
  - spec/invoker/power/port_finder_spec.rb
281
300
  - spec/invoker/power/setup/linux_setup_spec.rb
@@ -309,5 +328,31 @@ rubygems_version: 2.2.2
309
328
  signing_key:
310
329
  specification_version: 4
311
330
  summary: Something small for Process management
312
- test_files: []
331
+ test_files:
332
+ - spec/invoker/cli/pinger_spec.rb
333
+ - spec/invoker/cli/tail_watcher_spec.rb
334
+ - spec/invoker/cli_spec.rb
335
+ - spec/invoker/command_worker_spec.rb
336
+ - spec/invoker/commander_spec.rb
337
+ - spec/invoker/config_spec.rb
338
+ - spec/invoker/daemon_spec.rb
339
+ - spec/invoker/event/manager_spec.rb
340
+ - spec/invoker/invoker_spec.rb
341
+ - spec/invoker/ipc/client_handler_spec.rb
342
+ - spec/invoker/ipc/dns_check_command_spec.rb
343
+ - spec/invoker/ipc/message/list_response_spec.rb
344
+ - spec/invoker/ipc/message_spec.rb
345
+ - spec/invoker/ipc/unix_client_spec.rb
346
+ - spec/invoker/power/balancer_spec.rb
347
+ - spec/invoker/power/config_spec.rb
348
+ - spec/invoker/power/http_parser_spec.rb
349
+ - spec/invoker/power/http_response_spec.rb
350
+ - spec/invoker/power/port_finder_spec.rb
351
+ - spec/invoker/power/setup/linux_setup_spec.rb
352
+ - spec/invoker/power/setup/osx_setup_spec.rb
353
+ - spec/invoker/power/setup_spec.rb
354
+ - spec/invoker/process_manager_spec.rb
355
+ - spec/invoker/reactor_spec.rb
356
+ - spec/spec_helper.rb
357
+ - spec/support/mock_setup_file.rb
313
358
  has_rdoc: