lib/nodes.rb in nodes-0.1.1 vs lib/nodes.rb in nodes-0.1.4
- old
+ new
@@ -1,3 +1,50 @@
module Nodes
- VERSION = "0.1.1"
+ VERSION = "0.1.4"
+
+
+ def self.init(dir=nil)
+ dir = Dir.pwd unless dir
+ puts "Init new point '#{File.basename(dir)}' in #{dir}"
+ src = "#{File.dirname(__FILE__)}/../.node"
+ system("cp -r #{src} #{dir}")
+ end
+
+ def self.clone(name)
+ puts "Clone from server point '#{name}'"
+ dir = "#{Dir.pwd}/#{name}"
+ return unless system("mkdir #{dir}")
+ init dir
+ get dir
+ end
+
+ def self.put(dir=nil)
+ dir = Dir.pwd unless dir
+ system("cd #{dir} && #{dir}/.node/put")
+ end
+
+ def self.get(dir=nil)
+ dir = Dir.pwd unless dir
+ system("cd #{dir} && #{dir}/.node/get")
+ end
+
+ def self.del(dir=nil)
+ dir = Dir.pwd unless dir
+ return unless system("cd #{dir} && #{dir}/.node/del")
+ system("cd #{dir} && rm -rf #{dir}/.node")
+ end
+
+ def self.country ip
+ require 'geoip'
+ print ip
+ geoip = GeoIP.new("data/GeoIP.dat")
+ location = geoip.country(p)
+ country = location[2] if location != nil
+ print " - #{country}"
+ end
+
+ def self.call cmd
+ successfully = system(cmd)
+ exit "blach" unless successfully
+ end
+
end
\ No newline at end of file