arethusa-cli 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/arethusa-cli.gemspec +1 -0
- data/lib/arethusa/cli.rb +2 -0
- data/lib/arethusa/cli/transformer.rb +65 -0
- data/lib/arethusa/cli/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00569634f1ab3c084d084f04b1a69831c041f58e
|
4
|
+
data.tar.gz: 2ad0fd525633daa0b5a08338ad8cae25a77486da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 872094e3326c8ccdaa3a1f437826ce12705c756f37b6349696b6d552139899f5d0d2779a720e440b765262b46cd6ac76ce64b61b8b664583709a2694305d5ea7
|
7
|
+
data.tar.gz: 00bc6daa7a58040615262a9354f01a80b4bd12813464c3a26bc76e77b3562915dcf09a335b79e767b05c3341d19e81e69d6d80f77711dbbfba79b3c354cb0fec
|
data/arethusa-cli.gemspec
CHANGED
data/lib/arethusa/cli.rb
CHANGED
@@ -6,10 +6,12 @@ module Arethusa
|
|
6
6
|
require 'arethusa/cli/subcommand'
|
7
7
|
|
8
8
|
require 'arethusa/cli/generator'
|
9
|
+
require 'arethusa/cli/transformer'
|
9
10
|
|
10
11
|
include Thor::Actions
|
11
12
|
|
12
13
|
register(Generator, Generator.namespace, "#{Generator.namespace} [ACTION]", 'Generates Arethusa files. Call "arethusa generate" to learn more')
|
14
|
+
register(Transformer, Transformer.namespace, "#{Transformer.namespace} [ACTION]", 'Tranforms Alpheios conf files. Call "arethusa transform" to learn more')
|
13
15
|
|
14
16
|
desc 'build', 'Creates a tar archive to be used for deployment'
|
15
17
|
method_option :minify, aliases: '-m', type: :boolean, default: true,
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Arethusa::CLI
|
5
|
+
class Transformer < Subcommand
|
6
|
+
as_subcommand :transform
|
7
|
+
|
8
|
+
desc 'relations [FILE]', 'Transforms relation configurations'
|
9
|
+
def relations(file)
|
10
|
+
@doc = Nokogiri::XML(open(file))
|
11
|
+
@conf = Relations.new
|
12
|
+
|
13
|
+
parse('relation', :add_label)
|
14
|
+
parse('subrelation', :add_suffix)
|
15
|
+
|
16
|
+
puts JSON.pretty_generate(@conf, indent: ' ')
|
17
|
+
end
|
18
|
+
|
19
|
+
no_commands do
|
20
|
+
def parse(type, method)
|
21
|
+
@doc.xpath("//xmlns:table[@type = '#{type}']/xmlns:entry").each do |entry|
|
22
|
+
short = entry.xpath('./xmlns:tb').text
|
23
|
+
next if short == '-' || short.empty?
|
24
|
+
long = entry.xpath('./xmlns:menu').text
|
25
|
+
@conf.send(method, stripped(short), stripped(long))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def stripped(str)
|
30
|
+
str.sub(/^_/, '')
|
31
|
+
end
|
32
|
+
|
33
|
+
class Relations
|
34
|
+
def initialize
|
35
|
+
@labels = {}
|
36
|
+
@suffixes = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_label(short, long)
|
40
|
+
@labels[short] = Relation.new(short, long)
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_suffix(short, long)
|
44
|
+
@suffixes[short] = Relation.new(short, long)
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_json(options = {})
|
48
|
+
hsh = { relations: { labels: @labels, suffixes: @suffixes } }
|
49
|
+
hsh.to_json(options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Relation
|
54
|
+
def initialize(short, long)
|
55
|
+
@short = short
|
56
|
+
@long = long
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_json(options = {})
|
60
|
+
{ short: @short, long: @long }.to_json(options)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/arethusa/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arethusa-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LFDM
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Command line tools for Arethusa
|
84
98
|
email:
|
85
99
|
- 1986gh@gmail.com
|
@@ -104,6 +118,7 @@ files:
|
|
104
118
|
- lib/arethusa/cli/templates/html_template.tt
|
105
119
|
- lib/arethusa/cli/templates/module.tt
|
106
120
|
- lib/arethusa/cli/templates/service.tt
|
121
|
+
- lib/arethusa/cli/transformer.rb
|
107
122
|
- lib/arethusa/cli/version.rb
|
108
123
|
- spec/lib/arethusa_cli_spec.rb
|
109
124
|
- spec/spec_helper.rb
|