rsyntaxtree 0.6.7 → 0.6.91

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: e4622d2cdbf1276c10f5e5826a6809f3481994df
4
- data.tar.gz: 7a733195f3bf02495f36c6cd2037fd1f6bb64913
3
+ metadata.gz: 4da741645d3844ce99a54efe3df6e8554eeb2b21
4
+ data.tar.gz: 727dcfd111c5ec58240ee5caf4f417c4b195072f
5
5
  SHA512:
6
- metadata.gz: 1758c9c59751b9ce6102d791cbd66ee2264e8e3e7d4b252e810a02f53af80246c769a357fae44a5187ca66832213324994fc4082af55599e620b3be4ee5cc9f3
7
- data.tar.gz: 0a259f2811dc9aeea8fe860169673e9a23f7af1bb1b84508d4465ad76530a021cb54192cc7158c96ad9547da894d8592ab953b06e0a44cbceb7fe37af93509e7
6
+ metadata.gz: b862ff816bd3a129b40b4708aa19d587cd1f8e7f92b9a1a480609b3b5cd99bec120cdb46bd84a1a7e442eed25b297c379c235d73fa6765b24ef1072ea61414fc
7
+ data.tar.gz: a3e621ffc45cb6a17e0d0318c7a43039856964ca771f2c717a42001d8823eea0def499cee932a8d946b6917fbbf988466004e2747110f6c13f3e1f9be5f405b6
data/.gitignore CHANGED
@@ -10,4 +10,5 @@ Gemfile.lock
10
10
  log/
11
11
  logs/
12
12
 
13
-
13
+ bin/rsync_code
14
+ bin/linktree.rb
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in rsyntaxtree.gemspec
4
- gemspec
3
+ gem 'sinatra'
4
+ gem 'haml'
5
+ gem 'rmagick'
6
+ gem 'trollop'
7
+ group :development do
8
+ gem 'thin'
9
+ end
data/lib/rsyntaxtree.rb CHANGED
@@ -43,6 +43,20 @@ require 'version'
43
43
 
44
44
  FONT_DIR = File.expand_path(File.dirname(__FILE__) + "/../fonts")
45
45
 
46
+ ##################################################
47
+ if !development?
48
+ # load and store Google Analytics code, if any, to a variable
49
+ ga_path = File.dirname(__FILE__) + "/../google_analytics_tracking_code"
50
+ if File.exists?(ga_path)
51
+ gfile = File.open(ga_path, "r:UTF-8:UTF-8")
52
+ $GOOGLE_CODE = gfile.read
53
+ gfile.close
54
+ else
55
+ $GOOGLE_CODE = ""
56
+ end
57
+ end
58
+ ##################################################
59
+
46
60
  class RSGenerator
47
61
  include Helpers
48
62
  def initialize(params = {})
@@ -51,7 +65,12 @@ class RSGenerator
51
65
  case key
52
66
  when "data"
53
67
  data = URI.unescape(value)
54
- data = data.gsub('-AMP-', '&').gsub('-PRIME-', "'").gsub('-SCOLON-', ';')
68
+ data = data.gsub('-AMP-', '&')
69
+ .gsub('-PERCENT-', "%")
70
+ .gsub('-PRIME-', "'")
71
+ .gsub('-SCOLON-', ';')
72
+ .gsub('-OABRACKET-', '<')
73
+ .gsub('-CABRACKET-', '>')
55
74
  new_params[key] = data
56
75
  when "symmetrize", "color", "autosub"
57
76
  new_params[key] = value == "on"? true : false
@@ -72,6 +91,8 @@ class RSGenerator
72
91
  new_params["font"] = FONT_DIR + "/ArialUnicode.ttf"
73
92
  elsif value == "tnr"
74
93
  new_params["font"] = FONT_DIR + "/TimesNewRoman.ttf"
94
+ elsif value == "noto"
95
+ new_params["font"] = FONT_DIR + "/NotoSansCJK.ttc"
75
96
  end
76
97
  else
77
98
  new_params[key] = value
@@ -122,7 +143,7 @@ class RSGenerator
122
143
 
123
144
  def draw_svg
124
145
  @params["format"] = "svg"
125
- sp = StringParser.new(@params["data"].gsub('&', '&amp;'))
146
+ sp = StringParser.new(@params["data"].gsub('&', '&amp;').gsub('%', '&#37;'))
126
147
  sp.parse
127
148
  sp.auto_subscript if @params["autosub"]
128
149
  elist = sp.get_elementlist
@@ -28,7 +28,7 @@
28
28
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
29
 
30
30
  # require 'rubygems'
31
- require 'RMagick'
31
+ require 'rmagick'
32
32
  include Magick
33
33
 
34
34
  def img_get_txt_metrics(text, font, font_size, multiline)
@@ -49,7 +49,7 @@ class StringParser
49
49
  attr_accessor :data, :elist, :pos, :id, :level, :tncnt
50
50
  def initialize(str)
51
51
  # Clean up the data a little to make processing easier
52
- string = str.gsub(/\t/, "")
52
+ string = str.gsub(/\t/, "") rescue ""
53
53
  string.gsub!(/\s+/, " ")
54
54
  string.gsub!(/\] \[/, "][")
55
55
  string.gsub!(/ \[/, "[")
@@ -30,7 +30,7 @@
30
30
  require 'imgutils'
31
31
  require 'elementlist'
32
32
  # require 'rubygems'
33
- require 'RMagick'
33
+ require 'rmagick'
34
34
  include Magick
35
35
 
36
36
  E_WIDTH = 60 # Element width
@@ -1,4 +1,4 @@
1
1
  module RSyntaxTree
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.91"
3
3
  end
4
4
 
@@ -33,7 +33,12 @@ $(function(){
33
33
  }
34
34
 
35
35
  function escape_chrs(data){
36
- data = data.replace(/\&/g, "-AMP-").replace(/\'/g, "-PRIME-").replace(/\;/g, "-SCOLON");
36
+ data = data.replace(/\&/g, "-AMP-")
37
+ .replace(/\%/g, '-PERCENT-')
38
+ .replace(/\'/g, "-PRIME-")
39
+ .replace(/\;/g, "-SCOLON-")
40
+ .replace(/\</g, "-OABRACKET-")
41
+ .replace(/\>/g, "-CABRACKET-");
37
42
  data = $('<div/>').text(data).html();
38
43
  return data;
39
44
  }
@@ -129,4 +134,4 @@ $(function(){
129
134
  });
130
135
 
131
136
 
132
- });
137
+ });
data/views/footer.haml CHANGED
@@ -1,3 +1,3 @@
1
1
  .footer
2
2
  %p
3
- &copy; Yoichiro Hasebe 2013
3
+ &copy; Yoichiro Hasebe 2016
data/views/index.haml CHANGED
@@ -11,7 +11,7 @@
11
11
  #alert{:style => "height:20px;"}
12
12
  .span12
13
13
  %textarea.span12{:id => "data", :cols => 100, :style => "font-size: 11pt; height: 4em;line-height: 140%;"}
14
- [S [NP RSyntaxTree^][VP [V generates][NP multilingual syntax trees]]]
14
+ [S [NP RSyntaxTree^][VP [V generates][NP \[multilingual\] syntax trees]]]
15
15
  .row
16
16
  .span2
17
17
  %h4 Leaf-style
@@ -23,13 +23,14 @@
23
23
  .span2
24
24
  %h4 Font-style
25
25
  %select{:name => "fontstyle", :style => "width:110px;"}
26
- %option{:value => "cjk"}CJK
27
26
  %option{:value => "sans-serif"}San-Serif
28
27
  %option{:value => "serif"}Serif
29
28
  %option{:value => "jp-gothic"}JP-Gothic
30
29
  %option{:value => "jp-mincho"}JP-Mincho
30
+ %option{:value => "cjk"}CJK
31
31
  %option{:value => "aru"}ARU
32
32
  %option{:value => "tnr"}TNR
33
+ %option{:value => "noto"}NOTO
33
34
  .span2
34
35
  %h4 Font-size
35
36
  %select{:name => "fontsize", :style => "width:60px;"}
data/views/layout.haml CHANGED
@@ -18,18 +18,20 @@
18
18
 
19
19
  %link{ :href => $SUB_DIRECTORY + "/bootstrap/css/bootstrap-responsive.css", :type => "text/css", :rel => "stylesheet" }
20
20
  %link{ :href => $SUB_DIRECTORY + "/css/rsyntaxtree.css", :type => "text/css", :rel => "stylesheet" }
21
+
21
22
 
22
23
  :plain
24
+ #{ $GOOGLE_CODE }
23
25
  <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
24
26
  <!--[if lt IE 9]>
25
27
  <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
26
28
  <![endif]-->
27
29
 
28
- / Le fav and touch icons
29
- %link{ rel: "apple-touch-icon", href: "/bootstrap/images/apple-touch-icon.png"}
30
- %link{ rel: "shortcut icon", href: "/bootstrap/images/favicon.ico"}
31
- %link{ rel: "apple-touch-icon", sizes: "72x72", href: "/bootstrap/images/apple-touch-icon-72x72.png"}
32
- %link{ rel: "apple-touch-icon", sizes: "114x114", href: "/bootstrap/images/apple-touch-icon-114x114.png"}
30
+ -# / Le fav and touch icons
31
+ -# %link{ :rel => "apple-touch-icon", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon.png"}
32
+ -# %link{ :rel => "shortcut icon", :href => $SUB_DIRECTORY + "/bootstrap/images/favicon.ico"}
33
+ -# %link{ :rel => "apple-touch-icon", :sizes => "72x72", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon-72x72.png"}
34
+ -# %link{ :rel => "apple-touch-icon", :sizes => "114x114", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon-114x114.png"}
33
35
 
34
36
  %body
35
37
  %div#top{:data => {:subdir => $SUB_DIRECTORY}}
data/views/navbar.haml CHANGED
@@ -5,4 +5,4 @@
5
5
  %span.icon-bar
6
6
  %span.icon-bar
7
7
  %span.icon-bar
8
- %a.brand{:href => 'https://github.com/yohasebe/rsyntaxtree'}RSyntaxTree 0.6.5
8
+ %a.brand{:href => 'https://github.com/yohasebe/rsyntaxtree'}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-08 00:00:00.000000000 Z
11
+ date: 2017-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -70,7 +70,6 @@ description: Yet another syntax tree generator made with Ruby and RMagick
70
70
  email:
71
71
  - yohasebe@gmail.com
72
72
  executables:
73
- - linktree.rb
74
73
  - rsyntaxtree
75
74
  extensions: []
76
75
  extra_rdoc_files: []
@@ -80,7 +79,6 @@ files:
80
79
  - README.md
81
80
  - Rakefile
82
81
  - app.rb
83
- - bin/linktree.rb
84
82
  - bin/rsyntaxtree
85
83
  - config.ru
86
84
  - fonts/DroidSans.ttf
@@ -133,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
131
  version: '0'
134
132
  requirements: []
135
133
  rubyforge_project: rsyntaxtree
136
- rubygems_version: 2.4.5
134
+ rubygems_version: 2.6.8
137
135
  signing_key:
138
136
  specification_version: 4
139
137
  summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
data/bin/linktree.rb DELETED
@@ -1,20 +0,0 @@
1
- require 'linkparser'
2
- require 'rsyntaxtree'
3
-
4
- dict = LinkParser::Dictionary.new
5
- sent = dict.parse( "I wonder if Tom knows Jill sneezed her handkerchief off the table" )
6
- sent.subject # => "people"
7
- sent.verb # => "use"
8
- sent.object # => "Ruby"
9
- bracketed = sent.constituent_tree_string(2)
10
- bracketed = bracketed.chomp.gsub(/ [A-Z]+\]/){"]"}
11
- bracketed = bracketed.gsub(/VP (.+?) \[NP/) do |text|
12
- "VP [V #{$1}] [NP"
13
- end
14
-
15
- p bracketed
16
- opts = {}
17
- opts["data"] = bracketed
18
- rsg = RSGenerator.new(opts)
19
- outfile = File.new(File.expand_path("~/Desktop/test.png"), "wb")
20
- outfile.write rsg.draw_png