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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48d6a3ce3ccb53394037d82d9955f168a01abf05
4
- data.tar.gz: e7bec3b385bbfbd07a02ca68a4ebddec1df70471
3
+ metadata.gz: 00569634f1ab3c084d084f04b1a69831c041f58e
4
+ data.tar.gz: 2ad0fd525633daa0b5a08338ad8cae25a77486da
5
5
  SHA512:
6
- metadata.gz: e0d1b7afea4b3e6c52d1f464e92e617f9a3626c074b9df798b7eec63507bd63074e78977497f947a7cb91eb2a3e042a5e8cab7ec07cecf5571ebcd4ed7bbb969
7
- data.tar.gz: 927596359bd10607d56112cb1fbfcd5e14ecc2273ffb694176d441f021ddbc5b74df64aa28db5689aac3f6fc26b5652634eb9eacca27ba27efa371a7334758a8
6
+ metadata.gz: 872094e3326c8ccdaa3a1f437826ce12705c756f37b6349696b6d552139899f5d0d2779a720e440b765262b46cd6ac76ce64b61b8b664583709a2694305d5ea7
7
+ data.tar.gz: 00bc6daa7a58040615262a9354f01a80b4bd12813464c3a26bc76e77b3562915dcf09a335b79e767b05c3341d19e81e69d6d80f77711dbbfba79b3c354cb0fec
data/arethusa-cli.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "simplecov", "~> 0.7"
25
25
  spec.add_dependency "thor"
26
+ spec.add_dependency "nokogiri"
26
27
  end
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
@@ -1,5 +1,5 @@
1
1
  module Arethusa
2
2
  class CLI
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
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.5
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-13 00:00:00.000000000 Z
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