oedipus_lex 2.3.0 → 2.3.1

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: e4d847d43454e2e7497b7737efea33c3ac3639d2
4
- data.tar.gz: 94c532557bd692ed547f901b40667befe44fe39a
3
+ metadata.gz: c56dcc885b6ee098fa6e988db8ffd9a423134640
4
+ data.tar.gz: 03ee3915b080e450e7ff564842b5c7298dde0672
5
5
  SHA512:
6
- metadata.gz: 7d8ed1a67c28ca5ffafcf7d48abac036d6d3ccb88254bfd11e953d646f35b08a27e3c246f40317e13127961c6ca77f98a71b0eaa9aded873ae5d4f207176efe2
7
- data.tar.gz: 473a2296045308dec98b4a9355d4f1dd89168f2fae68cdea7f70efa6c4249f630fccf4b3be02d96478f343e995cdd61f96ce766f523ccaa9d7f59123b93ab4e9
6
+ metadata.gz: a2843b5841203dbc901caded1175e7cdb392e392429f0cdb8723054cd5bb04de9e4351a83e56ba75a5fa43a0144ee50e70a430d4cbbd04d7598370788ae76c64
7
+ data.tar.gz: 369ae18943123aca8e0b5d331932747d98c5eb7dee8ff100fab4bfba3e81078e776871237c52fc74055f6b4ccb45e8989b32af31a8dae009abbbae3e10d06eb4
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === 2.3.1 / 2014-06-09
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * If there is an encoding comment on the first line, put it above generated headers.
6
+
1
7
  === 2.3.0 / 2014-05-16
2
8
 
3
9
  * 4 minor enhancements:
data/lib/oedipus_lex.rb CHANGED
@@ -4,7 +4,7 @@ require "erb"
4
4
  require "oedipus_lex.rex"
5
5
 
6
6
  class OedipusLex
7
- VERSION = "2.3.0"
7
+ VERSION = "2.3.1"
8
8
 
9
9
  attr_accessor :class_name
10
10
  attr_accessor :header
@@ -232,10 +232,14 @@ class OedipusLex
232
232
  all_states = [[nil, *inclusives], # nil+incls # eg [[nil, :a],
233
233
  *exclusives.map { |s| [s] }] # [excls] # [:A], [:B]]
234
234
 
235
+ encoding = header.shift if header.first =~ /encoding:/
236
+ encoding ||= "# encoding: UTF-8"
237
+
235
238
  ERB.new(TEMPLATE, nil, "%").result binding
236
239
  end
237
240
 
238
241
  TEMPLATE = <<-'REX'.gsub(/^ {6}/, '')
242
+ <%= encoding %>
239
243
  #--
240
244
  # This file is automatically generated. Do not modify it.
241
245
  # Generated by: oedipus_lex version <%= VERSION %>.
@@ -1,6 +1,7 @@
1
+ # encoding: UTF-8
1
2
  #--
2
3
  # This file is automatically generated. Do not modify it.
3
- # Generated by: oedipus_lex version 2.2.1.
4
+ # Generated by: oedipus_lex version 2.3.0.
4
5
  # Source: lib/oedipus_lex.rex
5
6
  #++
6
7
 
@@ -592,15 +592,46 @@ class TestOedipusLex < Minitest::Test
592
592
 
593
593
  ruby = generate_lexer src
594
594
 
595
- exp = ["#--\n",
596
- "# This file is automatically generated. Do not modify it.\n",
597
- "# Generated by: oedipus_lex version #{OedipusLex::VERSION}.\n",
598
- "#++\n",
599
- "\n",
600
- "module X\n",
601
- "module Y\n"]
602
-
603
- assert_equal exp, ruby.lines.first(7)
595
+ exp = ["# encoding: UTF-8",
596
+ "#--",
597
+ "# This file is automatically generated. Do not modify it.",
598
+ "# Generated by: oedipus_lex version #{OedipusLex::VERSION}.",
599
+ "#++",
600
+ "",
601
+ "module X",
602
+ "module Y"]
603
+
604
+ assert_equal exp, ruby.lines.map(&:chomp).first(8)
605
+ end
606
+
607
+ def test_header_encoding_is_on_top
608
+ src = <<-'REX'
609
+ # encoding: UTF-8
610
+
611
+ module X
612
+ module Y
613
+ class Calculator
614
+ rule
615
+ /\d+/ { [:number, text.to_i] }
616
+ /\s+/
617
+ /[+-]/ { [:op, text] }
618
+ end
619
+ end
620
+ end
621
+ REX
622
+
623
+ ruby = generate_lexer src
624
+
625
+ exp = ["# encoding: UTF-8",
626
+ "#--",
627
+ "# This file is automatically generated. Do not modify it.",
628
+ "# Generated by: oedipus_lex version #{OedipusLex::VERSION}.",
629
+ "#++",
630
+ "",
631
+ "",
632
+ "module X"]
633
+
634
+ assert_equal exp, ruby.lines.map(&:chomp).first(8)
604
635
  end
605
636
 
606
637
  def test_read_non_existent_file
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oedipus_lex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  Y4evBVezr3SjXz08vPqRO5YRdO3zfeMT8gBjRqZjWJGMZ2lD4XNfrs7eky74CyZw
30
30
  xx3n58i0lQkBE1EpKE0lFu/y
31
31
  -----END CERTIFICATE-----
32
- date: 2014-05-16 00:00:00.000000000 Z
32
+ date: 2014-06-10 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: minitest
metadata.gz.sig CHANGED
Binary file