hmx_client 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -4
- data/Gemfile +4 -4
- data/Rakefile +1 -1
- data/bin/hmx +33 -33
- data/hmx_client.gemspec +27 -27
- data/lib/hmx/client.rb +167 -167
- data/lib/hmx/command.rb +140 -140
- data/lib/hmx/command/base.rb +195 -194
- data/lib/hmx/command/bootstrap.rb +18 -18
- data/lib/hmx/command/check.rb +170 -0
- data/lib/hmx/command/clone.rb +77 -77
- data/lib/hmx/command/config.rb +67 -67
- data/lib/hmx/command/dump.rb +67 -67
- data/lib/hmx/command/fn.rb +125 -43
- data/lib/hmx/command/fountain.rb +46 -46
- data/lib/hmx/command/get.rb +20 -20
- data/lib/hmx/command/getContent.rb +20 -20
- data/lib/hmx/command/help.rb +114 -114
- data/lib/hmx/command/partition.rb +38 -38
- data/lib/hmx/command/query.rb +22 -22
- data/lib/hmx/command/session.rb +35 -35
- data/lib/hmx/command/task.rb +32 -32
- data/lib/hmx/command/type.rb +45 -45
- data/lib/hmx/command/user.rb +68 -68
- data/lib/hmx/command/view.rb +161 -155
- data/lib/hmx/helpers.rb +76 -61
- data/lib/hmx/hmx.rb +148 -215
- data/lib/hmx/version.rb +3 -3
- data/lib/hmx_client.rb +7 -7
- data/sampleCommands.txt +5 -5
- metadata +12 -11
data/lib/hmx/command/dump.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Dump data from a type in hmx and load it back again
|
6
|
-
#
|
7
|
-
class Dump < Base
|
8
|
-
|
9
|
-
# dump
|
10
|
-
#
|
11
|
-
# Dump data from hmx into the local filesystem. Used
|
12
|
-
# as a preface to a backup, or a change then restore
|
13
|
-
#
|
14
|
-
# <typeName> <folderPath>
|
15
|
-
def index
|
16
|
-
unless args.size > 0
|
17
|
-
raise CommandFailed, "Usage: hmx dump <typeName> <folderPath>"
|
18
|
-
end
|
19
|
-
# The filenames will come from the name of the type and their displayName, appended onto
|
20
|
-
# the folder path given. We will also attempt to create the folder path and the type
|
21
|
-
# sub folder
|
22
|
-
typeName = args.shift
|
23
|
-
rootFolder = args.shift
|
24
|
-
|
25
|
-
Dir.mkdir(rootFolder) if !Dir.exist?(rootFolder)
|
26
|
-
Dir.mkdir(rootFolder + "/" + typeName) if !Dir.exist?(rootFolder + "/" + typeName)
|
27
|
-
displayNames = hmx.
|
28
|
-
displayNames.each { | displayName |
|
29
|
-
fileName = rootFolder + "/" + displayName
|
30
|
-
display "Writing to #{ fileName }"
|
31
|
-
File.open(fileName, 'w') { | f | f.write(JSON.pretty_generate(hmx.
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
# dump:load
|
36
|
-
#
|
37
|
-
# Load data that has previously been dumped using the main dump command
|
38
|
-
#
|
39
|
-
# <typeName> <folderPath>
|
40
|
-
#
|
41
|
-
# The real path for the files is in the folder formed by concatenating the typename to the rootFolder
|
42
|
-
def load
|
43
|
-
unless args.size > 0
|
44
|
-
raise CommandFailed, "Usage: hmx dump:load <typeName> <folderPath>"
|
45
|
-
end
|
46
|
-
typeName = args.shift
|
47
|
-
rootFolder = args.shift
|
48
|
-
|
49
|
-
folderName = rootFolder + "/" + typeName
|
50
|
-
Dir.foreach(folderName) { | f |
|
51
|
-
display "Loading #{ f } "
|
52
|
-
fullFile = folderName + "/" + f
|
53
|
-
if (File.file?(fullFile))
|
54
|
-
content = File.open(fullFile) { | h |
|
55
|
-
c = '';
|
56
|
-
while(line = h.gets)
|
57
|
-
c = c + line
|
58
|
-
end
|
59
|
-
c
|
60
|
-
}
|
61
|
-
puts "Content is #{ content } "
|
62
|
-
hmx.
|
63
|
-
end
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Dump data from a type in hmx and load it back again
|
6
|
+
#
|
7
|
+
class Dump < Base
|
8
|
+
|
9
|
+
# dump
|
10
|
+
#
|
11
|
+
# Dump data from hmx into the local filesystem. Used
|
12
|
+
# as a preface to a backup, or a change then restore
|
13
|
+
#
|
14
|
+
# <typeName> <folderPath>
|
15
|
+
def index
|
16
|
+
unless args.size > 0
|
17
|
+
raise CommandFailed, "Usage: hmx dump <typeName> <folderPath>"
|
18
|
+
end
|
19
|
+
# The filenames will come from the name of the type and their displayName, appended onto
|
20
|
+
# the folder path given. We will also attempt to create the folder path and the type
|
21
|
+
# sub folder
|
22
|
+
typeName = args.shift
|
23
|
+
rootFolder = args.shift
|
24
|
+
|
25
|
+
Dir.mkdir(rootFolder) if !Dir.exist?(rootFolder)
|
26
|
+
Dir.mkdir(rootFolder + "/" + typeName) if !Dir.exist?(rootFolder + "/" + typeName)
|
27
|
+
displayNames = hmx.doQuery([typeName, nil])
|
28
|
+
displayNames.each { | displayName |
|
29
|
+
fileName = rootFolder + "/" + displayName
|
30
|
+
display "Writing to #{ fileName }"
|
31
|
+
File.open(fileName, 'w') { | f | f.write(JSON.pretty_generate(hmx.doGetData([displayName]))) }
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# dump:load
|
36
|
+
#
|
37
|
+
# Load data that has previously been dumped using the main dump command
|
38
|
+
#
|
39
|
+
# <typeName> <folderPath>
|
40
|
+
#
|
41
|
+
# The real path for the files is in the folder formed by concatenating the typename to the rootFolder
|
42
|
+
def load
|
43
|
+
unless args.size > 0
|
44
|
+
raise CommandFailed, "Usage: hmx dump:load <typeName> <folderPath>"
|
45
|
+
end
|
46
|
+
typeName = args.shift
|
47
|
+
rootFolder = args.shift
|
48
|
+
|
49
|
+
folderName = rootFolder + "/" + typeName
|
50
|
+
Dir.foreach(folderName) { | f |
|
51
|
+
display "Loading #{ f } "
|
52
|
+
fullFile = folderName + "/" + f
|
53
|
+
if (File.file?(fullFile))
|
54
|
+
content = File.open(fullFile) { | h |
|
55
|
+
c = '';
|
56
|
+
while(line = h.gets)
|
57
|
+
c = c + line
|
58
|
+
end
|
59
|
+
c
|
60
|
+
}
|
61
|
+
puts "Content is #{ content } "
|
62
|
+
hmx.doPutData([content])
|
63
|
+
end
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/hmx/command/fn.rb
CHANGED
@@ -1,43 +1,125 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Load and Save functions in hmx
|
6
|
-
#
|
7
|
-
class Fn < Base
|
8
|
-
|
9
|
-
# fn
|
10
|
-
#
|
11
|
-
# Manipulate HMX functions
|
12
|
-
#
|
13
|
-
#
|
14
|
-
def index
|
15
|
-
unless args.size > 0
|
16
|
-
raise CommandFailed, "Usage: hmx fn <fnName>"
|
17
|
-
end
|
18
|
-
dout hmx.
|
19
|
-
end
|
20
|
-
|
21
|
-
# fn:list
|
22
|
-
#
|
23
|
-
# List all functions in HMX
|
24
|
-
#
|
25
|
-
def list
|
26
|
-
fns = hmx.
|
27
|
-
fns.each { | f |
|
28
|
-
display f.rpartition('/')[2]
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
# fn:put
|
33
|
-
#
|
34
|
-
# Create or update a function
|
35
|
-
#
|
36
|
-
def put
|
37
|
-
unless args.size > 0
|
38
|
-
raise CommandFailed, "Usage: hmx fn:put <fnName> <f:function>"
|
39
|
-
end
|
40
|
-
dout hmx.
|
41
|
-
end
|
42
|
-
|
43
|
-
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Load and Save functions in hmx
|
6
|
+
#
|
7
|
+
class Fn < Base
|
8
|
+
|
9
|
+
# fn
|
10
|
+
#
|
11
|
+
# Manipulate HMX functions
|
12
|
+
#
|
13
|
+
#
|
14
|
+
def index
|
15
|
+
unless args.size > 0
|
16
|
+
raise CommandFailed, "Usage: hmx fn <fnName>"
|
17
|
+
end
|
18
|
+
dout hmx.doGetFn([args.shift])
|
19
|
+
end
|
20
|
+
|
21
|
+
# fn:list
|
22
|
+
#
|
23
|
+
# List all functions in HMX
|
24
|
+
#
|
25
|
+
def list
|
26
|
+
fns = hmx.doQuery(["sys.fn", nil])
|
27
|
+
fns.each { | f |
|
28
|
+
display f.rpartition('/')[2]
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# fn:put
|
33
|
+
#
|
34
|
+
# Create or update a function
|
35
|
+
#
|
36
|
+
def put
|
37
|
+
unless args.size > 0
|
38
|
+
raise CommandFailed, "Usage: hmx fn:put <fnName> <f:function>"
|
39
|
+
end
|
40
|
+
dout hmx.doPutFn([args])
|
41
|
+
end
|
42
|
+
|
43
|
+
# fn:export
|
44
|
+
#
|
45
|
+
# Exports the functions to a series of files (and perhaps) folders, grounded
|
46
|
+
# in the folder specified by the first parameter.
|
47
|
+
# The file extension of the function is determined by the language of the function
|
48
|
+
def export
|
49
|
+
unless args.size > 0
|
50
|
+
raise CommandFailed, "Usage: hmx fn:export <folder>"
|
51
|
+
end
|
52
|
+
rootFolder = args.shift
|
53
|
+
Dir.mkdir(rootFolder) if !Dir.exist?(rootFolder)
|
54
|
+
displayNames = hmx.doQuery(['sys.fn', nil])
|
55
|
+
displayNames.each { | displayName |
|
56
|
+
# Just get function
|
57
|
+
fnInfo = hmx.doGetData([displayName])
|
58
|
+
fnName = fnInfo['document']['MXFunction']['fnName']
|
59
|
+
fnLang = fnInfo['document']['MXFunction']['fnLang']
|
60
|
+
fnContent = fnInfo['document']['MXFunction']['content']
|
61
|
+
outFile = fileName(rootFolder, fnName, fnLang)
|
62
|
+
puts "Writing #{outFile}"
|
63
|
+
File.open(outFile, 'w') { | f | f.write(fnContent) }
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# fn:import
|
68
|
+
# The opposite of export, takes files (and folders) in the root folder given
|
69
|
+
# and constructs and updates the functions back into hmx. The extension of the file
|
70
|
+
# determines the language of the function.
|
71
|
+
|
72
|
+
def import
|
73
|
+
unless args.size > 0
|
74
|
+
raise CommandFailed, "Usage: hmx fn:import <folder>"
|
75
|
+
end
|
76
|
+
rootFolder = args.shift
|
77
|
+
Dir.foreach(rootFolder) { | f |
|
78
|
+
display "Loading #{ f } "
|
79
|
+
fullFile = File.expand_path("#{rootFolder}/#{f}")
|
80
|
+
if (File.file?(fullFile))
|
81
|
+
content = File.open(fullFile) { | h |
|
82
|
+
c = ''
|
83
|
+
while(line = h.gets)
|
84
|
+
c = c + line
|
85
|
+
end
|
86
|
+
c
|
87
|
+
}
|
88
|
+
# Function name is the base of the filename
|
89
|
+
# Function language is based on the extension
|
90
|
+
# content is the content
|
91
|
+
ext = File.extname(f)
|
92
|
+
language = case File.extname(f)
|
93
|
+
when '.rb' then 'RUBY'
|
94
|
+
when '.clj' then 'CLOJURE'
|
95
|
+
when '.js' then 'JAVASCRIPT'
|
96
|
+
else 'UNKNOWN'
|
97
|
+
end
|
98
|
+
|
99
|
+
document = {}
|
100
|
+
document['document'] = {}
|
101
|
+
document['displayName'] = "sys.fn/#{ File.basename(f, ext) }"
|
102
|
+
fn = {}
|
103
|
+
fn['fnName'] = File.basename(f, ext)
|
104
|
+
fn['fnLang'] = language
|
105
|
+
fn['content'] = content
|
106
|
+
document['document']['MXFunction'] = fn
|
107
|
+
hmx.doPutData([JSON.generate(document)])
|
108
|
+
end
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
protected
|
114
|
+
|
115
|
+
def fileName(rootFolder, fnName, fnLang)
|
116
|
+
extension = case fnLang
|
117
|
+
when 'CLOJURE' then ".clj"
|
118
|
+
when 'RUBY' then ".rb"
|
119
|
+
when 'JAVASCRIPT' then '.js'
|
120
|
+
else ''
|
121
|
+
end
|
122
|
+
"#{ rootFolder }/#{fnName}#{extension}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/hmx/command/fountain.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module HmxClient::Command
|
5
|
-
|
6
|
-
# Manipulate hmx fountains (auto id generators)
|
7
|
-
#
|
8
|
-
class Fountain < Base
|
9
|
-
|
10
|
-
# fountain
|
11
|
-
#
|
12
|
-
# Lists all of the fountains and their values
|
13
|
-
def index
|
14
|
-
fountainState = hmx.
|
15
|
-
# fountainState is a map of fountainName => value
|
16
|
-
# Flip this into an array of "name" => name, "value" => value
|
17
|
-
objs = []
|
18
|
-
fountainState.each_pair do | key, value |
|
19
|
-
objs << { "name" => key, "value" => value }
|
20
|
-
end
|
21
|
-
cols = [ 'name', 'value' ]
|
22
|
-
headers = [ 'Fountain', 'Value' ]
|
23
|
-
display_table(objs, cols, headers)
|
24
|
-
end
|
25
|
-
|
26
|
-
# fountain:set
|
27
|
-
#
|
28
|
-
# Sets the new id for the fountain
|
29
|
-
#
|
30
|
-
def set
|
31
|
-
unless args.size > 1
|
32
|
-
raise CommandFailed, "Usage: hmx fountain:set <fountainId> <newValue>"
|
33
|
-
end
|
34
|
-
hmx.
|
35
|
-
end
|
36
|
-
# fountain:get
|
37
|
-
#
|
38
|
-
# Increments and returns a fountain value
|
39
|
-
def get
|
40
|
-
unless args.size > 0
|
41
|
-
raise CommandFailed, "Usage: hmx fountain:get <fountainId>"
|
42
|
-
end
|
43
|
-
display hmx.
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module HmxClient::Command
|
5
|
+
|
6
|
+
# Manipulate hmx fountains (auto id generators)
|
7
|
+
#
|
8
|
+
class Fountain < Base
|
9
|
+
|
10
|
+
# fountain
|
11
|
+
#
|
12
|
+
# Lists all of the fountains and their values
|
13
|
+
def index
|
14
|
+
fountainState = hmx.doGetFountainState([])
|
15
|
+
# fountainState is a map of fountainName => value
|
16
|
+
# Flip this into an array of "name" => name, "value" => value
|
17
|
+
objs = []
|
18
|
+
fountainState.each_pair do | key, value |
|
19
|
+
objs << { "name" => key, "value" => value }
|
20
|
+
end
|
21
|
+
cols = [ 'name', 'value' ]
|
22
|
+
headers = [ 'Fountain', 'Value' ]
|
23
|
+
display_table(objs, cols, headers)
|
24
|
+
end
|
25
|
+
|
26
|
+
# fountain:set
|
27
|
+
#
|
28
|
+
# Sets the new id for the fountain
|
29
|
+
#
|
30
|
+
def set
|
31
|
+
unless args.size > 1
|
32
|
+
raise CommandFailed, "Usage: hmx fountain:set <fountainId> <newValue>"
|
33
|
+
end
|
34
|
+
hmx.doSetFountainId(args)
|
35
|
+
end
|
36
|
+
# fountain:get
|
37
|
+
#
|
38
|
+
# Increments and returns a fountain value
|
39
|
+
def get
|
40
|
+
unless args.size > 0
|
41
|
+
raise CommandFailed, "Usage: hmx fountain:get <fountainId>"
|
42
|
+
end
|
43
|
+
display hmx.doGetFountain(args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/hmx/command/get.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Get full document from hmx
|
6
|
-
#
|
7
|
-
class Get < Base
|
8
|
-
|
9
|
-
# get
|
10
|
-
#
|
11
|
-
# get a document from hmx, given its display name
|
12
|
-
#
|
13
|
-
def index
|
14
|
-
unless args.size > 0
|
15
|
-
raise CommandFailed, "Usage: hmx get displayname"
|
16
|
-
end
|
17
|
-
dout JSON.pretty_generate(hmx.
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Get full document from hmx
|
6
|
+
#
|
7
|
+
class Get < Base
|
8
|
+
|
9
|
+
# get
|
10
|
+
#
|
11
|
+
# get a document from hmx, given its display name
|
12
|
+
#
|
13
|
+
def index
|
14
|
+
unless args.size > 0
|
15
|
+
raise CommandFailed, "Usage: hmx get displayname"
|
16
|
+
end
|
17
|
+
dout JSON.pretty_generate(hmx.doGetData(args))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Get document content from hmx
|
6
|
-
#
|
7
|
-
class GetContent < Base
|
8
|
-
|
9
|
-
# getContent
|
10
|
-
#
|
11
|
-
# get the data part of a document from hmx, given its display name
|
12
|
-
#
|
13
|
-
def index
|
14
|
-
unless args.size > 0
|
15
|
-
raise CommandFailed, "Usage: hmx getContent displayname"
|
16
|
-
end
|
17
|
-
dout hmx.
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Get document content from hmx
|
6
|
+
#
|
7
|
+
class GetContent < Base
|
8
|
+
|
9
|
+
# getContent
|
10
|
+
#
|
11
|
+
# get the data part of a document from hmx, given its display name
|
12
|
+
#
|
13
|
+
def index
|
14
|
+
unless args.size > 0
|
15
|
+
raise CommandFailed, "Usage: hmx getContent displayname"
|
16
|
+
end
|
17
|
+
dout hmx.doGetContent(args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|