expressir 0.2.15 → 0.2.16

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
  SHA256:
3
- metadata.gz: 01b9d48b15ce85744e4c19cbe55752d22744388f738367cd486f2afa2ac10835
4
- data.tar.gz: 44fbef691d15a6c0feee280e86aabda10401f6b5d344fc3596cbc7315e816c76
3
+ metadata.gz: 47487a0a54ea6a8564ad87e6ac763fd7afd9110fb3cb4580462ca13c77c78aa5
4
+ data.tar.gz: cfea2dad62fc18754207e704204d79867a3090bee07a9fb89b7c033a2630845e
5
5
  SHA512:
6
- metadata.gz: 8049d49a9c11790c0fb45a3d37e5d8574b18aaf7d3de92b9dd870668bf6131005ff2ce1630d391962dbd6c936ea80d9d6cf95cdca0f6926358640b1ca46e9312
7
- data.tar.gz: d90065bbfda420df3dce91ad2b016e14a145d751f70914823f0d5db8b86ff212c0c4ebce20f77d2a6fa85a343d91e172c3094a66a851db6af64d95af9495aa84
6
+ metadata.gz: e0afc309ae992b8fdb501a77db6073aa9a569af0822e25d295ea2b15bd579088d5c7c15877364a58db0bee9ce4feae95b785cf47816df12f66dd72b792ddb685
7
+ data.tar.gz: 05e78f10274be40d47bad5d5bfac785c4d5aecd027d06fec1421c5ba1623c8f69aa5dcdfc53c13c39cd766b45302dfcc87c521ec74d2847f941db65d9f094646
@@ -1,8 +1,6 @@
1
- require "expressir/express_exp/formatter"
2
-
3
1
  module Expressir
4
2
  module ExpressExp
5
- class HyperlinkFormatter < Formatter
3
+ module HyperlinkFormatter
6
4
  def format_expressions_simple_reference(node)
7
5
  return node.id if node.parent.is_a? Model::Expressions::AttributeReference
8
6
 
@@ -1,8 +1,6 @@
1
- require "expressir/express_exp/formatter"
2
-
3
1
  module Expressir
4
2
  module ExpressExp
5
- class SchemaHeadFormatter < Formatter
3
+ module SchemaHeadFormatter
6
4
  def format_schema(node)
7
5
  [
8
6
  "SCHEMA #{node.id}#{node.version ? " #{format(node.version)}" : ""};",
@@ -92,35 +92,11 @@ module Expressir
92
92
  @tokens[start_index..stop_index]
93
93
  end
94
94
 
95
- def get_head_tokens(ctx)
96
- start_index, stop_index = if ctx.is_a? ::ExpressParser::SchemaDeclContext
97
- start_index = ctx.start.token_index
98
- stop_index = if ctx.schema_body.interface_specification.length > 0
99
- ctx.schema_body.interface_specification.last.stop.token_index
100
- elsif ctx.schema_version_id
101
- ctx.schema_version_id.stop.token_index + 1
102
- else
103
- ctx.schema_id.stop.token_index + 1
104
- end
105
-
106
- [start_index, stop_index]
107
- end
108
-
109
- if start_index and stop_index
110
- @tokens[start_index..stop_index]
111
- end
112
- end
113
-
114
95
  def attach_source(ctx, node)
115
96
  if node.class.method_defined? :source
116
97
  tokens = get_tokens(ctx)
117
98
  node.source = get_tokens_source(tokens)
118
99
  end
119
-
120
- if node.class.method_defined? :head_source
121
- tokens = get_head_tokens(ctx)
122
- node.head_source = get_tokens_source(tokens)
123
- end
124
100
  end
125
101
 
126
102
  def find_remark_target(node, path)
@@ -5,8 +5,6 @@ module Expressir
5
5
 
6
6
  include Identifier
7
7
 
8
- attr_accessor :head_source
9
-
10
8
  attr_accessor :version
11
9
  attr_accessor :interfaces
12
10
  attr_accessor :constants
@@ -23,7 +21,6 @@ module Expressir
23
21
  @id = options[:id]
24
22
  @remarks = options.fetch(:remarks, [])
25
23
  @source = options[:source]
26
- @head_source = options[:head_source]
27
24
 
28
25
  @version = options[:version]
29
26
  @interfaces = options.fetch(:interfaces, [])
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "0.2.15".freeze
2
+ VERSION = "0.2.16".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "spec_helper"
2
2
  require "expressir/express_exp/parser"
3
+ require "expressir/express_exp/formatter"
3
4
  require "expressir/express_exp/hyperlink_formatter"
4
5
 
5
6
  RSpec.describe Expressir::ExpressExp::HyperlinkFormatter do
@@ -7,7 +8,10 @@ RSpec.describe Expressir::ExpressExp::HyperlinkFormatter do
7
8
  it "formats hyperlink" do
8
9
  repo = Expressir::ExpressExp::Parser.from_file(input_file)
9
10
 
10
- result = Expressir::ExpressExp::HyperlinkFormatter.format(repo)
11
+ class CustomFormatter < Expressir::ExpressExp::Formatter
12
+ include Expressir::ExpressExp::HyperlinkFormatter
13
+ end
14
+ result = CustomFormatter.format(repo)
11
15
  expected_result = File.read(output_file)
12
16
 
13
17
  expect(result).to eq(expected_result)
@@ -1,5 +1,6 @@
1
1
  require "spec_helper"
2
2
  require "expressir/express_exp/parser"
3
+ require "expressir/express_exp/formatter"
3
4
  require "expressir/express_exp/schema_head_formatter"
4
5
 
5
6
  RSpec.describe Expressir::ExpressExp::SchemaHeadFormatter do
@@ -7,7 +8,10 @@ RSpec.describe Expressir::ExpressExp::SchemaHeadFormatter do
7
8
  it "formats schema head" do
8
9
  repo = Expressir::ExpressExp::Parser.from_file(sample_file)
9
10
 
10
- result = Expressir::ExpressExp::SchemaHeadFormatter.format(repo)
11
+ class CustomFormatter < Expressir::ExpressExp::Formatter
12
+ include Expressir::ExpressExp::SchemaHeadFormatter
13
+ end
14
+ result = CustomFormatter.format(repo)
11
15
 
12
16
  expect(result).to eq(<<~EXP.strip
13
17
  SCHEMA syntax_schema 'version';
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -695,7 +695,6 @@ files:
695
695
  - spec/expressir/express_exp/formatter/remark_spec.rb
696
696
  - spec/expressir/express_exp/formatter/syntax_spec.rb
697
697
  - spec/expressir/express_exp/hyperlink_formatter_spec.rb
698
- - spec/expressir/express_exp/parser/head_source_spec.rb
699
698
  - spec/expressir/express_exp/parser/multiple_spec.rb
700
699
  - spec/expressir/express_exp/parser/remark_spec.rb
701
700
  - spec/expressir/express_exp/parser/source_spec.rb
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
- require "expressir/express_exp/parser"
3
-
4
- RSpec.describe Expressir::ExpressExp::Parser do
5
- describe ".head_source" do
6
- it "contains original head source" do
7
- input = File.read(sample_file)
8
- repo = Expressir::ExpressExp::Parser.from_file(sample_file)
9
-
10
- repo.schemas[0].tap do |x|
11
- start_index = x.source.index("SCHEMA")
12
- stop_index = x.source.index(";") + ";".length - 1
13
- expected_result = x.source[start_index..stop_index]
14
- expect(x.head_source).to eq(expected_result)
15
- end
16
-
17
- repo.schemas[1].tap do |x|
18
- start_index = x.source.index("SCHEMA")
19
- stop_index = x.source.index(";") + ";".length - 1
20
- expected_result = x.source[start_index..stop_index]
21
- expect(x.head_source).to eq(expected_result)
22
- end
23
-
24
- repo.schemas[2].tap do |x|
25
- start_index = x.source.index("SCHEMA")
26
- stop_index = x.source.index("REFERENCE FROM contract_schema;") + "REFERENCE FROM contract_schema;".length - 1
27
- expected_result = x.source[start_index..stop_index]
28
- expect(x.head_source).to eq(expected_result)
29
- end
30
- end
31
- end
32
-
33
- def sample_file
34
- @sample_file ||= Expressir.root_path.join(
35
- "original", "examples", "syntax", "source.exp"
36
- )
37
- end
38
- end