rsyntaxtree 1.0.8 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,11 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'rmagick'
4
- gem 'optimist'
5
- gem 'parslet'
6
- gem 'rsvg2'
3
+ # source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ruby-spacy.gemspec
6
+ gemspec
7
+
8
+ gem "optimist"
9
+ gem "parslet"
10
+ gem "rmagick"
11
+ gem "rsvg2"
data/README.md CHANGED
@@ -72,7 +72,8 @@ For the command-line interface, type `$rsyntaxtree -h` after installation. Here'
72
72
  RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
73
73
 
74
74
  Usage:
75
- rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
75
+ 1) rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
76
+ 2) rsyntaxtree [options] "/path/to/text/file"
76
77
  where [options] are:
77
78
  -o, --outdir=<s> Output directory (default: ./)
78
79
  -f, --format=<s> Output format: png, gif, jpg, pdf, or svg (default: png)
@@ -87,7 +88,7 @@ where [options] are:
87
88
  -r, --transparent=<s> Make background transparent: on or off (default: off)
88
89
  -p, --polyline=<s> draw polyline connectors: on or off (default: off)
89
90
  -e, --version Print version and exit
90
- -h, --help Show this message```
91
+ -h, --help Show this message
91
92
  ```
92
93
 
93
94
  See the [documentation](https://yohasebe.github.io/rsyntaxtree/documentation) for more detailed info about the syntax.
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
4
6
  task default: "test"
5
7
 
6
8
  Rake::TestTask.new do |task|
7
- task.pattern = "test/*_test.rb"
9
+ task.pattern = "test/*_test.rb"
8
10
  end
data/bin/rsyntaxtree CHANGED
@@ -1,66 +1,58 @@
1
1
  #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH << File.join( File.dirname(__FILE__), '../lib')
5
-
6
- require 'rsyntaxtree'
4
+ require_relative '../lib/rsyntaxtree'
5
+ require_relative '../lib/rsyntaxtree/utils'
7
6
  require 'optimist'
8
- require 'utils'
9
7
 
10
- opts = Optimist::options do
11
- version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2021 Yoichiro Hasebe"
12
- banner <<-EOS
13
- RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
8
+ opts = Optimist.options do
9
+ version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2023 Yoichiro Hasebe"
10
+ banner <<~BANNER
11
+ RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
14
12
 
15
- Usage:
16
- rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
17
- where [options] are:
18
- EOS
13
+ Usage:
14
+ 1) rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
15
+ 2) rsyntaxtree [options] "/path/to/text/file"
16
+ where [options] are:
17
+ BANNER
19
18
 
20
- opt :outdir, "Output directory",
21
- :default => "./"
22
- opt :format, "Output format: png, gif, jpg, pdf, or svg",
23
- :default => "png"
24
- opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing",
25
- :default => "auto"
26
- opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, cjk",
27
- :default => "sans"
28
- opt :font, "Path to a ttf font used to generate tree (optional)", :type => String
29
- opt :fontsize, "Size: 8-26",
30
- :default => 16
31
- opt :margin, "Margin: 0-10",
32
- :default => 1
33
- opt :vheight, "Connector Height: 0.5-5.0",
34
- :default => 2.0
35
- opt :color, "Color text and bars: on or off",
36
- :default => "on"
37
- opt :symmetrize, "Generate radically symmetrical, balanced tree: on or off",
38
- :default => "off"
39
- opt :transparent, "Make background transparent: on or off",
40
- :default => "off"
41
- opt :polyline, "draw polyline connectors: on or off",
42
- :default => "off"
19
+ opt :outdir, "Output directory", default: "./"
20
+ opt :format, "Output format: png, gif, jpg, pdf, or svg", default: "png"
21
+ opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing", default: "auto"
22
+ opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, cjk", default: "sans"
23
+ opt :font, "Path to a ttf font used to generate tree (optional)", type: String
24
+ opt :fontsize, "Size: 8-26", default: 16
25
+ opt :margin, "Margin: 0-10", default: 1
26
+ opt :vheight, "Connector Height: 0.5-5.0", default: 2.0
27
+ opt :color, "Color text and bars: on or off", default: "on"
28
+ opt :symmetrize, "Generate radically symmetrical, balanced tree: on or off", default: "off"
29
+ opt :transparent, "Make background transparent: on or off", default: "off"
30
+ opt :polyline, "draw polyline connectors: on or off", default: "off"
43
31
  end
44
32
 
45
- Optimist::die :outdir, "must be an exsting directory path" unless FileTest::directory?(opts[:outdir])
46
- Optimist::die :format, "must be png, jpg, gif, or svg" unless /\A(png|jpg|gif|pdf|svg)\z/ =~ opts[:format]
47
- Optimist::die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
48
- Optimist::die :fontstyle, "must be sans, serif, cjk" unless /\A(sans|serif|cjk)\z/ =~ opts[:fontstyle]
49
- Optimist::die :font, "must be path to an existing ttf font" if opts[:font] && !File::exists?(opts[:font])
50
- Optimist::die :fontsize, "must be in the range of 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
51
- Optimist::die :color, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:color]
52
- Optimist::die :symmetrize, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:symmetrize]
53
- Optimist::die :margin, "must be in the range of 0-10" if opts[:margin] < 0 || opts[:margin] > 10
54
- Optimist::die :vheight, "must be in the range of 0.5-5.0" if opts[:vheight] < 0.5 || opts[:vheight] > 5.0
55
- Optimist::die :transparent, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:transparent]
56
- Optimist::die :polyline, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:polyline]
33
+ Optimist.die :outdir, "must be an exsting directory path" unless FileTest.directory?(opts[:outdir])
34
+ Optimist.die :format, "must be png, jpg, gif, or svg" unless /\A(png|jpg|gif|pdf|svg)\z/ =~ opts[:format]
35
+ Optimist.die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
36
+ Optimist.die :fontstyle, "must be sans, serif, cjk" unless /\A(sans|serif|cjk)\z/ =~ opts[:fontstyle]
37
+ Optimist.die :font, "must be path to an existing ttf font" if opts[:font] && !File.exist?(opts[:font])
38
+ Optimist.die :fontsize, "must be in the range of 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
39
+ Optimist.die :color, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:color]
40
+ Optimist.die :symmetrize, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:symmetrize]
41
+ Optimist.die :margin, "must be in the range of 0-10" if opts[:margin].negative? || opts[:margin] > 10
42
+ Optimist.die :vheight, "must be in the range of 0.5-5.0" if opts[:vheight] < 0.5 || opts[:vheight] > 5.0
43
+ Optimist.die :transparent, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:transparent]
44
+ Optimist.die :polyline, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:polyline]
57
45
 
58
46
  string_opts = {}
59
47
  opts.each do |key, value|
60
48
  string_opts[key.to_sym] = value unless key == :font && !value
61
49
  end
62
50
 
63
- data = ARGV[0]
51
+ data = if File.exist?(File.expand_path(ARGV[0]))
52
+ File.read ARGV[0]
53
+ else
54
+ ARGV[0]
55
+ end
64
56
 
65
57
  begin
66
58
  RSyntaxTree::RSGenerator.check_data(data)
@@ -89,7 +81,7 @@ begin
89
81
  rescue RSTError => e
90
82
  puts e
91
83
  exit
92
- rescue => e
84
+ rescue StandardError => e
93
85
  p e
94
86
  puts "Error: something unexpected occurred"
95
87
  exit
data/docs/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
  # Hello! This is where you manage which Jekyll version is used to run.
3
5
  # When you want to use a different version, change it below, save the
@@ -27,5 +29,5 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do
27
29
  end
28
30
 
29
31
  # Performance-booster for watching directories on Windows
30
- gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
32
+ gem "wdm", "~> 0.1.1", platforms: [:mingw, :x64_mingw, :mswin]
31
33
  gem "webrick"
@@ -35,7 +35,7 @@
35
35
  {{ content }}
36
36
 
37
37
  <footer class="site-footer" style='border-top-width: 0; text-align: center;'>
38
- <div> <span class="site-footer-credits">© Yoichiro HASEBE 2009-2022</span></div>
38
+ <div> <span class="site-footer-credits">© Yoichiro HASEBE 2009-2023</span></div>
39
39
  {% include social_media_links.html %}
40
40
  </footer>
41
41
  </main>