karo 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of karo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dd6cd3053afd3a77746aae662bdfc278244f9f6
4
- data.tar.gz: 07267c303a943a821d030b0448e04f2db365c8a1
3
+ metadata.gz: e6bb2f2f052f4233b76e74240444ff57dad0198b
4
+ data.tar.gz: 472ec29a410344e0794d8403b0bc578f1d330420
5
5
  SHA512:
6
- metadata.gz: beb1c0ff512feaa49a5d40309cdac879960567feb67a62eccfa0e6160dead270bef3d6d5d3b8dd268d5ce8d6695f3c8c84a57f672aeedb087c513cedada2addc
7
- data.tar.gz: 5b7a45d10b86a3d4c76ad6c4b6dcc16b60d3681f2dc8ae821743dc2c4e3a378c83ad8154a5d0da361b2d132e1deee03a78ae47f0237f71af6f0de59d49987624
6
+ metadata.gz: 8b4e80082714410de9882d1b924273131cf4324fabd98dc2f6d9e309e4b7461972ce3ebb5ed506f9a477b225a624923685b4d0bcd8b6bc17ea426dce7d5bbe87
7
+ data.tar.gz: ff3db3a5ee10f35d6dd2110ded09ae6b5bc09b458cf5c690362fa3e65ec15a1ad600e08b70c83684738b63eb360c465502f7992bab9fc4124cec875082926470
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.3.5
4
+
5
+ ### Bug Fixes
6
+
7
+ - Removed hard coded `localhost` host dependency from db server config
8
+
3
9
  ## v2.3.4
4
10
 
5
11
  ### Features
data/lib/karo/cli.rb CHANGED
@@ -36,7 +36,7 @@ module Karo
36
36
  def config
37
37
  configuration = Config.load_configuration(options)
38
38
 
39
- ap configuration if configuration
39
+ ap(configuration, indent: 2) if configuration
40
40
  end
41
41
 
42
42
  def self.source_root
data/lib/karo/config.rb CHANGED
@@ -1,43 +1,52 @@
1
+ require_relative 'extensions/hash'
1
2
  require 'yaml'
2
3
  require 'thor'
3
4
 
4
5
  module Karo
5
6
 
6
- class NoConfigFileFoundError < StandardError; end
7
-
8
- class Config
9
-
10
- def self.default_file_name
11
- ".karo.yml"
12
- end
13
-
14
- def self.load_configuration(options)
15
- begin
16
- config_file = File.expand_path(options[:config_file])
17
- configuration = read_configuration(config_file)[options[:environment]]
18
-
19
- if configuration.nil? || configuration.empty?
20
- raise Thor::Error, "Please pass a valid configuration for an environment '#{options[:environment]}' within this file '#{config_file}'"
21
- else
22
- configuration
23
- end
24
- rescue Karo::NoConfigFileFoundError
25
- puts "You can use 'karo generate' to generate a skeleton .karo.yml file"
26
- puts "Please make sure that this configuration file exists? '#{config_file}'"
27
- raise Thor::Error, "and run the command again"
28
- end
29
- end
30
-
31
- private
32
-
33
- def self.read_configuration(file_name)
34
- if File.exist?(file_name)
35
- YAML.load_file(file_name)
36
- else
37
- raise NoConfigFileFoundError
38
- end
39
- end
40
-
41
- end
7
+ class Config
8
+
9
+ def self.default_file_name
10
+ ".karo.yml"
11
+ end
12
+
13
+ def self.load_configuration(options)
14
+ configuration = lookup_configuration(Dir.getwd, options[:config_file])
15
+ configuration = configuration[options[:environment]]
16
+
17
+ if configuration.nil? || configuration.empty?
18
+ puts "Please pass a valid configuration for an environment '#{options[:environment]}' within this file '#{File.expand_path(options[:config_file])}'"
19
+ raise Thor::Error, "You can use 'karo generate' to generate a skeleton .karo.yml file"
20
+ else
21
+ configuration
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def self.lookup_configuration(dir, config_file, configuration={})
28
+ return configuration if dir.empty?
29
+
30
+ config_file_path = File.join(dir, config_file)
31
+ config = read_configuration(config_file_path)
32
+
33
+ lookup_configuration(pop_dir(dir), config_file, config.deep_merge(configuration))
34
+ end
35
+
36
+ def self.pop_dir(dir)
37
+ dirs = dir.split("/")
38
+ dirs.pop
39
+ dirs.join("/")
40
+ end
41
+
42
+ def self.read_configuration(file_name)
43
+ if File.exist?(file_name)
44
+ YAML.load_file(file_name)
45
+ else
46
+ {}
47
+ end
48
+ end
49
+
50
+ end
42
51
 
43
52
  end
data/lib/karo/db.rb CHANGED
@@ -95,7 +95,7 @@ module Karo
95
95
  def sync_server_to_local_database(server_db_config, local_db_config)
96
96
  ssh = "ssh #{@configuration["user"]}@#{@configuration["host"]}"
97
97
 
98
- command = "#{ssh} \"mysqldump --opt -C -u#{server_db_config["username"]} -p#{server_db_config["password"]} #{server_db_config["database"]}\" | mysql -v -h #{local_db_config["host"]} -C -u#{local_db_config["username"]} -p#{local_db_config["password"]} #{local_db_config["database"]}"
98
+ command = "#{ssh} \"mysqldump --opt -C -u#{server_db_config["username"]} -p#{server_db_config["password"]} -h#{server_db_config["host"]} #{server_db_config["database"]}\" | mysql -v -h #{local_db_config["host"]} -C -u#{local_db_config["username"]} -p#{local_db_config["password"]} #{local_db_config["database"]}"
99
99
 
100
100
  run_it command, options[:verbose]
101
101
  end
@@ -0,0 +1,11 @@
1
+ class Hash
2
+
3
+ def deep_merge(other_hash)
4
+ self.merge(other_hash) do |key, oldval, newval|
5
+ oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
6
+ newval = newval.to_hash if newval.respond_to?(:to_hash)
7
+ oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
8
+ end
9
+ end
10
+
11
+ end
data/lib/karo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Karo
2
- VERSION = "2.3.4"
2
+ VERSION = "2.3.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Trikha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -150,6 +150,7 @@ files:
150
150
  - lib/karo/common.rb
151
151
  - lib/karo/config.rb
152
152
  - lib/karo/db.rb
153
+ - lib/karo/extensions/hash.rb
153
154
  - lib/karo/templates/karo.yml
154
155
  - lib/karo/version.rb
155
156
  - lib/karo/workflow.rb
@@ -174,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  version: '0'
175
176
  requirements: []
176
177
  rubyforge_project:
177
- rubygems_version: 2.0.3
178
+ rubygems_version: 2.1.1
178
179
  signing_key:
179
180
  specification_version: 4
180
181
  summary: SSH toolbox to make running logs, sync, cache commands easier for a given