nodes 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/command.rb +81 -0
- data/bin/node +68 -14
- data/lib/nodes.rb +48 -1
- metadata +5 -8
data/bin/command.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# == Synopsis
|
4
|
+
# Nodes is a data warehouse in the form of meta tags, which may have additional values.
|
5
|
+
# Users can add, delete, edit nodes, manage access rights, etc.
|
6
|
+
#
|
7
|
+
# == Examples
|
8
|
+
# This command add new node.
|
9
|
+
# node add "{ name: 'test node', tag: test, zero, one: 1, two: [1,2] }"
|
10
|
+
#
|
11
|
+
# Other examples:
|
12
|
+
# node find "{ name, tag, zero }"
|
13
|
+
# node del "{ name, tag, zero, one, two }"
|
14
|
+
#
|
15
|
+
# == Usage
|
16
|
+
# node [options] json_text/file.yml
|
17
|
+
#
|
18
|
+
# For help use: node -h
|
19
|
+
#
|
20
|
+
# == Options
|
21
|
+
# -h, --help Displays help message
|
22
|
+
# -v, --version Display the version, then exit
|
23
|
+
# TO DO - add additional options
|
24
|
+
#
|
25
|
+
# == Author
|
26
|
+
# Eugene Markine
|
27
|
+
#
|
28
|
+
# == Copyright
|
29
|
+
# Copyright (c) 2010 EugeneLab. Licensed under the GNU General Public License (GPL), Version 2:
|
30
|
+
# http://www.opensource.org/licenses/gpl-2.0.php
|
31
|
+
|
32
|
+
# TO DO - change license if necessary
|
33
|
+
|
34
|
+
#require 'rubygems'
|
35
|
+
require "#{__FILE__}/../../lib/nodes"
|
36
|
+
|
37
|
+
commands_help = "Commands:\n" \
|
38
|
+
" init Init new point\n" \
|
39
|
+
" del Delete point \n" \
|
40
|
+
" clone Clone point from server\n" \
|
41
|
+
" put Put changes to server\n" \
|
42
|
+
" get Get changes from server\n" \
|
43
|
+
"\n"
|
44
|
+
# " country <ip> Extract a country name from IP address\n"
|
45
|
+
usage_help = "usage: node command [arguments...] [options...]\n\n" + commands_help
|
46
|
+
|
47
|
+
unless ARGV.first
|
48
|
+
puts "Nodes #{Nodes::VERSION}"
|
49
|
+
puts usage_help
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
|
53
|
+
command = ARGV.shift
|
54
|
+
|
55
|
+
case command
|
56
|
+
when 'version'
|
57
|
+
puts "Nodes #{Nodes::VERSION}"
|
58
|
+
when 'init'
|
59
|
+
dir = ARGV.shift
|
60
|
+
Nodes.init dir
|
61
|
+
Nodes.put dir
|
62
|
+
when 'clone'
|
63
|
+
name = ARGV.shift
|
64
|
+
unless name
|
65
|
+
puts "You must specify a name to clone.\n\n"
|
66
|
+
puts "usage: node clone <name>\n\n"
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
Nodes.clone name
|
70
|
+
when 'put'
|
71
|
+
Nodes.put ARGV.shift
|
72
|
+
when 'get'
|
73
|
+
Nodes.get ARGV.shift
|
74
|
+
when 'del'
|
75
|
+
Nodes.del ARGV.shift
|
76
|
+
when 'country'
|
77
|
+
Nodes.country(ARGV.shift)
|
78
|
+
else
|
79
|
+
puts "Unknown command: #{command}\n"
|
80
|
+
puts commands_help
|
81
|
+
end
|
data/bin/node
CHANGED
@@ -1,27 +1,81 @@
|
|
1
|
-
#!/usr/
|
2
|
-
#
|
3
|
-
|
4
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# == Synopsis
|
4
|
+
# Nodes is a data warehouse in the form of meta tags, which may have additional values.
|
5
|
+
# Users can add, delete, edit nodes, manage access rights, etc.
|
6
|
+
#
|
7
|
+
# == Examples
|
8
|
+
# This command add new node.
|
9
|
+
# node add "{ name: 'test node', tag: test, zero, one: 1, two: [1,2] }"
|
10
|
+
#
|
11
|
+
# Other examples:
|
12
|
+
# node find "{ name, tag, zero }"
|
13
|
+
# node del "{ name, tag, zero, one, two }"
|
14
|
+
#
|
15
|
+
# == Usage
|
16
|
+
# node [options] json_text/file.yml
|
17
|
+
#
|
18
|
+
# For help use: node -h
|
19
|
+
#
|
20
|
+
# == Options
|
21
|
+
# -h, --help Displays help message
|
22
|
+
# -v, --version Display the version, then exit
|
23
|
+
# TO DO - add additional options
|
24
|
+
#
|
25
|
+
# == Author
|
26
|
+
# Eugene Markine
|
27
|
+
#
|
28
|
+
# == Copyright
|
29
|
+
# Copyright (c) 2010 EugeneLab. Licensed under the GNU General Public License (GPL), Version 2:
|
30
|
+
# http://www.opensource.org/licenses/gpl-2.0.php
|
31
|
+
|
32
|
+
# TO DO - change license if necessary
|
33
|
+
|
34
|
+
#require 'rubygems'
|
35
|
+
require "#{__FILE__}/../../lib/nodes"
|
5
36
|
|
6
37
|
commands_help = "Commands:\n" \
|
7
|
-
|
38
|
+
" init Init new point\n" \
|
39
|
+
" del Delete point \n" \
|
40
|
+
" clone Clone point from server\n" \
|
41
|
+
" put Put changes to server\n" \
|
42
|
+
" get Get changes from server\n" \
|
43
|
+
"\n"
|
44
|
+
# " country <ip> Extract a country name from IP address\n"
|
8
45
|
usage_help = "usage: node command [arguments...] [options...]\n\n" + commands_help
|
9
|
-
|
10
|
-
|
46
|
+
|
11
47
|
unless ARGV.first
|
12
48
|
puts "Nodes #{Nodes::VERSION}"
|
13
49
|
puts usage_help
|
14
50
|
exit
|
15
|
-
end
|
16
|
-
|
17
|
-
command = ARGV.first
|
18
|
-
ARGV.shift
|
51
|
+
end
|
19
52
|
|
53
|
+
command = ARGV.shift
|
20
54
|
|
21
55
|
case command
|
22
|
-
when '
|
23
|
-
puts "
|
56
|
+
when 'version'
|
57
|
+
puts "Nodes #{Nodes::VERSION}"
|
58
|
+
when 'init'
|
59
|
+
dir = ARGV.shift
|
60
|
+
Nodes.init dir
|
61
|
+
Nodes.put dir
|
62
|
+
when 'clone'
|
63
|
+
name = ARGV.shift
|
64
|
+
unless name
|
65
|
+
puts "You must specify a name to clone.\n\n"
|
66
|
+
puts "usage: node clone <name>\n\n"
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
Nodes.clone name
|
70
|
+
when 'put'
|
71
|
+
Nodes.put ARGV.shift
|
72
|
+
when 'get'
|
73
|
+
Nodes.get ARGV.shift
|
74
|
+
when 'del'
|
75
|
+
Nodes.del ARGV.shift
|
76
|
+
when 'country'
|
77
|
+
Nodes.country(ARGV.shift)
|
24
78
|
else
|
25
|
-
puts "Unknown command: #{command}"
|
79
|
+
puts "Unknown command: #{command}\n"
|
26
80
|
puts commands_help
|
27
81
|
end
|
data/lib/nodes.rb
CHANGED
@@ -1,3 +1,50 @@
|
|
1
1
|
module Nodes
|
2
|
-
VERSION = "0.1.
|
2
|
+
VERSION = "0.1.4"
|
3
|
+
|
4
|
+
|
5
|
+
def self.init(dir=nil)
|
6
|
+
dir = Dir.pwd unless dir
|
7
|
+
puts "Init new point '#{File.basename(dir)}' in #{dir}"
|
8
|
+
src = "#{File.dirname(__FILE__)}/../.node"
|
9
|
+
system("cp -r #{src} #{dir}")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.clone(name)
|
13
|
+
puts "Clone from server point '#{name}'"
|
14
|
+
dir = "#{Dir.pwd}/#{name}"
|
15
|
+
return unless system("mkdir #{dir}")
|
16
|
+
init dir
|
17
|
+
get dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.put(dir=nil)
|
21
|
+
dir = Dir.pwd unless dir
|
22
|
+
system("cd #{dir} && #{dir}/.node/put")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get(dir=nil)
|
26
|
+
dir = Dir.pwd unless dir
|
27
|
+
system("cd #{dir} && #{dir}/.node/get")
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.del(dir=nil)
|
31
|
+
dir = Dir.pwd unless dir
|
32
|
+
return unless system("cd #{dir} && #{dir}/.node/del")
|
33
|
+
system("cd #{dir} && rm -rf #{dir}/.node")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.country ip
|
37
|
+
require 'geoip'
|
38
|
+
print ip
|
39
|
+
geoip = GeoIP.new("data/GeoIP.dat")
|
40
|
+
location = geoip.country(p)
|
41
|
+
country = location[2] if location != nil
|
42
|
+
print " - #{country}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.call cmd
|
46
|
+
successfully = system(cmd)
|
47
|
+
exit "blach" unless successfully
|
48
|
+
end
|
49
|
+
|
3
50
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Eugene Markine
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-11-12 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -42,6 +40,7 @@ extensions: []
|
|
42
40
|
extra_rdoc_files: []
|
43
41
|
|
44
42
|
files:
|
43
|
+
- bin/command.rb
|
45
44
|
- bin/node
|
46
45
|
- lib/nodes.rb
|
47
46
|
- LICENSE
|
@@ -49,7 +48,7 @@ files:
|
|
49
48
|
- ROADMAP.md
|
50
49
|
- CHANGELOG.md
|
51
50
|
has_rdoc: true
|
52
|
-
homepage: http://nodes
|
51
|
+
homepage: http://eugenelab.com/nodes
|
53
52
|
licenses: []
|
54
53
|
|
55
54
|
post_install_message:
|
@@ -62,7 +61,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
61
|
requirements:
|
63
62
|
- - ">="
|
64
63
|
- !ruby/object:Gem::Version
|
65
|
-
hash: 3
|
66
64
|
segments:
|
67
65
|
- 0
|
68
66
|
version: "0"
|
@@ -71,7 +69,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
69
|
requirements:
|
72
70
|
- - ">="
|
73
71
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 23
|
75
72
|
segments:
|
76
73
|
- 1
|
77
74
|
- 3
|