dumper 1.7.1 → 1.7.2

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: 738929ed8f9f1892d7aba60b3522e82b1d980c4b
4
- data.tar.gz: 96d32207c0c292ff11d40fc6d5ba1184753b4996
3
+ metadata.gz: b601179630f672e78d097cc6b7bbe2a154a5b71e
4
+ data.tar.gz: 41058b3e711dc4ca68fade869be505c76d173358
5
5
  SHA512:
6
- metadata.gz: 05136b455cf44fef7dfa0937b0fdd1269141797eea397e4994723736e7f07c5861d3d93f19cd58eabd6eb798ce312fd84dc31dd070c77e2c5d5484d87db1bbc6
7
- data.tar.gz: 1d8cec2a5661f84c1d694e88222f9196575bd9278398a11d194c856deb038ba1cfd527e1b5b29119c849ddc8625ede6d3d1bbf5a7db61130b13f22324ae99eea
6
+ metadata.gz: 2ffc004b93fd9f0a936c9465edc864dfa266d4d02cb3302f1c0f07e2a162a63bde0ca98524adf0634963bfc9090b31c2e6ab4232574a30e0f39fed79343d9e45
7
+ data.tar.gz: b55a25b90634606ca9c19a214b42f8ae2d9ce990f0fdd4ccc669e9ccea81f58734234b8e00430e6d00409b75d6de7305d0d8cec213df2057e324a74f23a0cf29
@@ -6,7 +6,6 @@ module Dumper
6
6
  autoload :Dependency, 'dumper/dependency'
7
7
  autoload :Job, 'dumper/job'
8
8
  autoload :Stack, 'dumper/stack'
9
- autoload :Utility, 'dumper/utility'
10
9
  autoload :VERSION, 'dumper/version'
11
10
 
12
11
  module Database
@@ -16,4 +15,10 @@ module Dumper
16
15
  autoload :MongoDB, 'dumper/database/mongodb'
17
16
  autoload :Redis, 'dumper/database/redis'
18
17
  end
18
+
19
+ module Utility
20
+ autoload :IP, 'dumper/utility/ip'
21
+ autoload :Log, 'dumper/utility/log'
22
+ autoload :ObjectFinder, 'dumper/utility/object_finder'
23
+ end
19
24
  end
@@ -4,7 +4,7 @@ require 'dumper/patch'
4
4
 
5
5
  module Dumper
6
6
  class Agent
7
- include Dumper::Utility::LoggingMethods
7
+ include Dumper::Utility::Log
8
8
 
9
9
  API_VERSION = 1
10
10
  MAX_FILESIZE = 2147483648 # 2.gigabytes
@@ -16,12 +16,12 @@ module Dumper
16
16
  no_tasks do
17
17
  def check_ip
18
18
  print 'Checking IP address... '
19
- @ip = Dumper::Utility::IP.new
20
- print "#{@ip.ip} => "
21
- if @ip.ipaddr.private?
22
- puts "private IP, #{fetch_will_fail_warning}".color(:red)
19
+ ip = Dumper::Utility::IP.new
20
+ print "#{ip.address} => "
21
+ if ip.private?
22
+ puts "Private IP, #{fetch_will_fail_warning}".color(:red)
23
23
  else
24
- puts 'public IP, good'.color(:green)
24
+ puts 'Public IP, good'.color(:green)
25
25
  end
26
26
  end
27
27
 
@@ -64,7 +64,7 @@ module Dumper
64
64
  end
65
65
 
66
66
  def fetch_will_fail_warning
67
- 'warning - fetch from dumper.io to this server will fail, you will need to use the dumper gem with rails.'
67
+ 'warning - remote fetch from dumper.io to this server will fail. You will need to use the dumper gem with rails.'
68
68
  end
69
69
  end
70
70
  end
@@ -1,15 +1,16 @@
1
1
  module Dumper
2
2
  class Dependency
3
3
  LIBS = {
4
- 'thor' => { :require => 'thor', :version => '~> 0.14' },
5
- 'rainbow' => { :require => 'rainbow', :version => '~> 1.1.4' },
6
- 'net-ntp' => { :require => 'net/ntp', :version => '~> 2.1.1' },
4
+ 'thor' => { :version => '~> 0.19' },
5
+ 'rainbow' => { :version => '~> 2.1', :require => 'rainbow/ext/string' },
6
+ 'net-ntp' => { :version => '~> 2.1', :require => 'net/ntp' },
7
+ 'ipaddress' => { :version => '~> 0.8.3' },
7
8
  }
8
9
 
9
10
  def self.load(name)
10
11
  begin
11
- gem(name, LIBS[name][:version])
12
- require(LIBS[name][:require])
12
+ gem name, LIBS[name][:version]
13
+ require LIBS[name][:require] || name
13
14
  rescue LoadError
14
15
  abort <<-EOS
15
16
  Dependency missing: #{name}
@@ -4,7 +4,7 @@ require 'posix/spawn'
4
4
  module Dumper
5
5
  class Job
6
6
  include POSIX::Spawn
7
- include Dumper::Utility::LoggingMethods
7
+ include Dumper::Utility::Log
8
8
 
9
9
  def initialize(agent, job)
10
10
  @agent = agent
@@ -0,0 +1,20 @@
1
+ Dumper::Dependency.load('ipaddress')
2
+ require 'forwardable'
3
+
4
+ module Dumper
5
+ module Utility
6
+ class IP
7
+ extend Forwardable
8
+ def_delegators :@ip, :address, :private?
9
+
10
+ def initialize(*args)
11
+ UDPSocket.open do |s|
12
+ s.do_not_reverse_lookup = true
13
+ s.connect '64.233.187.99', 1
14
+ @ip = IPAddress(s.addr.last)
15
+ end
16
+ raise "#{@ip.address} is not IPv4!" unless @ip.ipv4?
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,39 +1,25 @@
1
- require 'ipaddr'
2
1
  require 'logger'
3
2
 
4
3
  module Dumper
5
4
  module Utility
6
- class IP
7
- attr_reader :ip, :ipaddr
8
-
9
- def initialize(*args)
10
- disable_reverse_lookup do
11
- UDPSocket.open do |s|
12
- s.connect '64.233.187.99', 1
13
- @ip = s.addr.last
14
- end
15
- end
16
- @ipaddr = Dumper::Utility::IPAddr.new(@ip)
5
+ module Log
6
+ def logger
7
+ @@logger ||= Dumper::Utility::SlimLogger.new("#{Rails.root}/log/dumper_agent.log", 1, 10.megabytes)
17
8
  end
18
9
 
19
- def disable_reverse_lookup
20
- orig = Socket.do_not_reverse_lookup
21
- Socket.do_not_reverse_lookup = true
22
- begin
23
- yield
24
- ensure
25
- Socket.do_not_reverse_lookup = orig
26
- end
10
+ def stdout_logger
11
+ @@stdout_logger ||= Dumper::Utility::SlimLogger.new(STDOUT)
27
12
  end
28
- end
29
13
 
30
- class IPAddr < ::IPAddr
31
- def private?
32
- return false unless self.ipv4?
14
+ def log(msg, level=:info)
15
+ stdout_logger.send level, "** [Dumper] " + msg
16
+ return unless true #should_log?
17
+ logger.send level, msg
18
+ end
33
19
 
34
- [ IPAddr.new("10.0.0.0/8"),
35
- IPAddr.new("172.16.0.0/12"),
36
- IPAddr.new("192.168.0.0/16") ].any?{|i| i.include? self }
20
+ def log_last_error
21
+ log [ $!.class.name, $!.to_s ].join(', ')
22
+ log ("\n" << $!.backtrace.join("\n")), :debug
37
23
  end
38
24
  end
39
25
 
@@ -52,32 +38,5 @@ module Dumper
52
38
  end
53
39
  end
54
40
  end
55
-
56
- module LoggingMethods
57
- def logger
58
- @@logger ||= Dumper::Utility::SlimLogger.new("#{Rails.root}/log/dumper_agent.log", 1, 10.megabytes)
59
- end
60
-
61
- def stdout_logger
62
- @@stdout_logger ||= Dumper::Utility::SlimLogger.new(STDOUT)
63
- end
64
-
65
- def log(msg, level=:info)
66
- stdout_logger.send level, "** [Dumper] " + msg
67
- return unless true #should_log?
68
- logger.send level, msg
69
- end
70
-
71
- def log_last_error
72
- log [ $!.class.name, $!.to_s ].join(', ')
73
- log ("\n" << $!.backtrace.join("\n")), :debug
74
- end
75
- end
76
-
77
- module ObjectFinder
78
- def find_instance_in_object_space(klass)
79
- ObjectSpace.each_object(klass).first
80
- end
81
- end
82
41
  end
83
42
  end
@@ -0,0 +1,9 @@
1
+ module Dumper
2
+ module Utility
3
+ module ObjectFinder
4
+ def find_instance_in_object_space(klass)
5
+ ObjectSpace.each_object(klass).first
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Dumper
2
- VERSION = '1.7.1'
2
+ VERSION = '1.7.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenn Ejima
@@ -165,7 +165,9 @@ files:
165
165
  - lib/dumper/job.rb
166
166
  - lib/dumper/patch.rb
167
167
  - lib/dumper/stack.rb
168
- - lib/dumper/utility.rb
168
+ - lib/dumper/utility/ip.rb
169
+ - lib/dumper/utility/log.rb
170
+ - lib/dumper/utility/object_finder.rb
169
171
  - lib/dumper/version.rb
170
172
  - lib/generators/dumper/install_generator.rb
171
173
  - lib/generators/dumper/templates/dumper.rb.erb