yml2erd 0.9.4 → 0.9.5

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: 6f82cb399f591b6bf170da10f871abc4b422b87e
4
- data.tar.gz: 2dfbb88248c1b791b153fe075c5cdb479d2c2a7c
3
+ metadata.gz: 166d9aea0ea8799713fb3f89d965fadc65824a26
4
+ data.tar.gz: a9937380ca26d72580e232a0c8f276519967251b
5
5
  SHA512:
6
- metadata.gz: 7950a484da139127e8fcb25b615a6a15106b069f1d808b184cf6aa901a6f535537c968e9effe5c37a74a84b0f811b9d81ab847b76da90f0050ce2853747485cd
7
- data.tar.gz: 1a8628453d98dd18ed3d1595d4c5b187ea50f479afcc1adc9c171121419dd7f427150d711d36a73d753d47f5049a31b6d0afdbee38d39e1dcc27904d499e993d
6
+ metadata.gz: 64b352491096eb2d9d7ecf35a6d0de6513924354a6225e5543117dbdc92965bd485e42451da73b57e1c62546fc46dd721e649a71af8f031d5a1e9011982a83cd
7
+ data.tar.gz: 47a40a5f02ebea24d73ac2e0e7edfc80d0a86b186c459bf5d25e813b0c33efdc94a0b36f73987963ae47df3ad95dafb530132156481b526c84406bd1b493c4f3
data/lib/yml2erd/cli.rb CHANGED
@@ -1,15 +1,19 @@
1
1
  require "yml2erd/parser"
2
2
  require "yml2erd/diagram"
3
3
  require "thor"
4
+ require "yaml"
4
5
 
5
6
  module Yml2erd
6
7
  class CLI < Thor
8
+ class YmlNotFoundError < StandardError;end
9
+
7
10
  desc "convert <path>", "Convert erd from yml"
8
11
  option :output, aliases: :o, banner: 'FILE_PATH', desc: 'default: output.png'
9
12
  option :projectname, aliases: :p, banner: 'PROJECT_NAME', desc: 'default: null'
10
13
  option :outputstyle, aliases: :s, banner: 'OUTPUT_STYLE', desc: 'svg or png, default: png'
11
14
  def convert(path)
12
- schema_structure = Yml2erd::Parser.parse(path)
15
+ abort_if_graphviz_isnt_installed
16
+ schema_structure = load_yml(path)
13
17
  opts = {
14
18
  output_path: options[:output_path],
15
19
  project_name: options[:projectname],
@@ -18,5 +22,19 @@ module Yml2erd
18
22
  Yml2erd::Diagram.create(schema_structure, opts)
19
23
  puts 'Successfully converted!'
20
24
  end
25
+
26
+ private
27
+
28
+ def load_yml(path)
29
+ abort "#{path} is not found, please check your .yml file path" unless File.exists?(path)
30
+ yml = YAML.load_file(path)
31
+ Yml2erd::Parser.parse(yml)
32
+ end
33
+
34
+ # This method has a bug around `which gvpr`.
35
+ # That is because which may not exist in except UNIX based OS.
36
+ def abort_if_graphviz_isnt_installed
37
+ abort "GraphViz is not installed, please install graphviz from http://www.graphviz.org/Download..php \n\nOr you can get by\n $ brew install graphviz # on macOS\n $ apt-get install graphviz # on Ubuntu" unless !`which gvpr`.empty?
38
+ end
21
39
  end
22
40
  end
@@ -1,13 +1,11 @@
1
1
  require 'yml2erd/schema_structure'
2
2
  require 'yml2erd/schema_structure/validator'
3
- require 'yaml'
4
3
 
5
4
  module Yml2erd
6
5
  class Parser
7
6
  class << self
8
7
  # returns an object of Yml2erd::SchemaStructure
9
- def parse(path)
10
- yml = YAML.load_file(path)
8
+ def parse(yml)
11
9
  ss = Yml2erd::SchemaStructure.new(yml)
12
10
  Yml2erd::SchemaStructure::Validator.new(ss).validate
13
11
  ss
@@ -1,3 +1,3 @@
1
1
  module Yml2erd
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
data/yml2erd.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["asmsuechan"]
10
10
  spec.email = ["suenagaryoutaabc@gmail.com"]
11
11
 
12
- spec.summary = %q{This gem allows us to generate erd easily.}
13
- spec.description = %q{Convert simple yml to erd}
12
+ spec.summary = %q{This gem allows us to generate an erd easily.}
13
+ spec.description = %q{Convert erd from a simple yml}
14
14
  spec.homepage = "https://github.com/asmsuechan/yml2erd"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yml2erd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - asmsuechan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-25 00:00:00.000000000 Z
11
+ date: 2016-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-graphviz
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: Convert simple yml to erd
139
+ description: Convert erd from a simple yml
140
140
  email:
141
141
  - suenagaryoutaabc@gmail.com
142
142
  executables:
@@ -189,5 +189,5 @@ rubyforge_project:
189
189
  rubygems_version: 2.5.1
190
190
  signing_key:
191
191
  specification_version: 4
192
- summary: This gem allows us to generate erd easily.
192
+ summary: This gem allows us to generate an erd easily.
193
193
  test_files: []