expressir 1.4.1-x86_64-darwin → 1.4.3-x86_64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.adoc +33 -3
 - data/lib/expressir/cli.rb +17 -22
 - data/lib/expressir/express/2.7/express_parser.bundle +0 -0
 - data/lib/expressir/model/model_element.rb +32 -15
 - data/lib/expressir/version.rb +1 -1
 - data/spec/expressir/model/model_element_spec.rb +25 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5ef5f654a41b3f0dbc952132e9cef32295770b25b3d0bbc755ccbc778769fde4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 71479dd7526bb2a49b911669554a4f2e37a0d3293cc355cc4d3659631e932991
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3e6de2b730fd4cc5f3c22ffcb6e3b4058f8460bdf875335dfc442d460f6efe22bfbdb01f5fba5bc43cd5dca744af4241b7a2c2edf2c16cbc5c68ee81ec58b08b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: aec5d3270a3b28a2b44dc36fe7a4e08d11677fb5412527a794326a1094f4a09b7544502b71f466c6e6635621aac2d378c286d2e4549517473b4e57b6c5c14aa3
         
     | 
    
        data/README.adoc
    CHANGED
    
    | 
         @@ -125,6 +125,36 @@ $ gem install expressir 
     | 
|
| 
       125 
125 
     | 
    
         
             
            ----
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
127 
     | 
    
         | 
| 
      
 128 
     | 
    
         
            +
            == Usage
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
            === Filtering out schemas
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            Use the `select_proc` argument of `to_hash`.
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            Example:
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
            [source,ruby]
         
     | 
| 
      
 137 
     | 
    
         
            +
            ----
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            schema_yaml = YAML.load_file('documents/iso-10303-41/schemas.yaml')
         
     | 
| 
      
 140 
     | 
    
         
            +
            schema_paths = schema_yaml['schemas'].map {|x,y| y['path'].gsub("../../", "")}
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
            repo = Expressir::Express::Parser.from_files(schema_paths)
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
            filtered_schemas = ["action_schema", "date_time_schema"]
         
     | 
| 
      
 145 
     | 
    
         
            +
            select_proc = Proc.new do |value|
         
     | 
| 
      
 146 
     | 
    
         
            +
              if value.is_a?(Expressir::Model::Declarations::Schema)
         
     | 
| 
      
 147 
     | 
    
         
            +
                filtered_schemas.include?(value.id)
         
     | 
| 
      
 148 
     | 
    
         
            +
              else
         
     | 
| 
      
 149 
     | 
    
         
            +
                true
         
     | 
| 
      
 150 
     | 
    
         
            +
              end
         
     | 
| 
      
 151 
     | 
    
         
            +
            end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
            repo_hash = repo.to_hash(select_proc: select_proc)
         
     | 
| 
      
 154 
     | 
    
         
            +
            schemas = repo_hash['schemas']
         
     | 
| 
      
 155 
     | 
    
         
            +
            schemas.map {|s| s["id"] }
         
     | 
| 
      
 156 
     | 
    
         
            +
            ----
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
       128 
158 
     | 
    
         
             
            == Contributing
         
     | 
| 
       129 
159 
     | 
    
         | 
| 
       130 
160 
     | 
    
         
             
            First, thank you for contributing! We love pull requests from everyone. By
         
     | 
| 
         @@ -148,7 +178,8 @@ Here are a few technical guidelines to follow: 
     | 
|
| 
       148 
178 
     | 
    
         | 
| 
       149 
179 
     | 
    
         
             
            Expressir is distributed under the BSD 2-clause license.
         
     | 
| 
       150 
180 
     | 
    
         | 
| 
       151 
     | 
    
         
            -
            Expressir  
     | 
| 
      
 181 
     | 
    
         
            +
            Expressir originally contained some code from the NIST Reeper project but
         
     | 
| 
      
 182 
     | 
    
         
            +
            has been completely rewritten.
         
     | 
| 
       152 
183 
     | 
    
         | 
| 
       153 
184 
     | 
    
         
             
            The https://www.nist.gov/services-resources/software/reeper[NIST Reeper license]
         
     | 
| 
       154 
185 
     | 
    
         
             
            is reproduced below:
         
     | 
| 
         @@ -169,5 +200,4 @@ ____ 
     | 
|
| 
       169 
200 
     | 
    
         | 
| 
       170 
201 
     | 
    
         
             
            == Credits
         
     | 
| 
       171 
202 
     | 
    
         | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
            the NIST Reeper software on https://sourceforge.net/p/reeper/[Sourceforge].
         
     | 
| 
      
 203 
     | 
    
         
            +
            Copyright Ribose Inc.
         
     | 
    
        data/lib/expressir/cli.rb
    CHANGED
    
    | 
         @@ -18,14 +18,22 @@ module Expressir 
     | 
|
| 
       18 
18 
     | 
    
         
             
                      acc << schema.id unless schema.version&.value
         
     | 
| 
       19 
19 
     | 
    
         
             
                      acc
         
     | 
| 
       20 
20 
     | 
    
         
             
                    end
         
     | 
| 
       21 
     | 
    
         
            -
                  rescue StandardError 
     | 
| 
       22 
     | 
    
         
            -
                    # pp e
         
     | 
| 
      
 21 
     | 
    
         
            +
                  rescue StandardError
         
     | 
| 
       23 
22 
     | 
    
         
             
                    nil
         
     | 
| 
       24 
23 
     | 
    
         
             
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def _print_validation_errors(type, array)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    return if array.empty?
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    puts "#{'*' * 20} RESULTS: #{type.to_s.upcase.gsub('_', ' ')} #{'*' * 20}"
         
     | 
| 
      
 29 
     | 
    
         
            +
                    array.each do |msg|
         
     | 
| 
      
 30 
     | 
    
         
            +
                      puts msg
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
       25 
33 
     | 
    
         
             
                end
         
     | 
| 
       26 
34 
     | 
    
         | 
| 
       27 
35 
     | 
    
         
             
                desc "validate *PATH", "validate EXPRESS schema located at PATH"
         
     | 
| 
       28 
     | 
    
         
            -
                def validate(*paths)
         
     | 
| 
      
 36 
     | 
    
         
            +
                def validate(*paths) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
         
     | 
| 
       29 
37 
     | 
    
         
             
                  no_version = []
         
     | 
| 
       30 
38 
     | 
    
         
             
                  no_valid = []
         
     | 
| 
       31 
39 
     | 
    
         | 
| 
         @@ -39,30 +47,17 @@ module Expressir 
     | 
|
| 
       39 
47 
     | 
    
         
             
                      next
         
     | 
| 
       40 
48 
     | 
    
         
             
                    end
         
     | 
| 
       41 
49 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
                     
     | 
| 
       43 
     | 
    
         
            -
                       
     | 
| 
       44 
     | 
    
         
            -
                        no_version << "Missing version string: schema `#{schema_id}` | #{x}"
         
     | 
| 
       45 
     | 
    
         
            -
                      end
         
     | 
| 
      
 50 
     | 
    
         
            +
                    ret.each do |schema_id|
         
     | 
| 
      
 51 
     | 
    
         
            +
                      no_version << "Missing version string: schema `#{schema_id}` | #{x}"
         
     | 
| 
       46 
52 
     | 
    
         
             
                    end
         
     | 
| 
       47 
53 
     | 
    
         
             
                  end
         
     | 
| 
       48 
54 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                   
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                    no_valid.each do |msg|
         
     | 
| 
       52 
     | 
    
         
            -
                      puts msg
         
     | 
| 
       53 
     | 
    
         
            -
                    end
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
                  _print_validation_errors(:failed_to_parse, no_valid)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  _print_validation_errors(:missing_version_string, no_version)
         
     | 
| 
       55 
57 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
       57 
     | 
    
         
            -
                    puts "#{"*" * 20} RESULTS: MISSING VERSION STRING #{"*" * 20}"
         
     | 
| 
       58 
     | 
    
         
            -
                    no_version.each do |msg|
         
     | 
| 
       59 
     | 
    
         
            -
                      puts msg
         
     | 
| 
       60 
     | 
    
         
            -
                    end
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                  exit 1 unless [no_valid, no_version].all?(&:empty?)
         
     | 
| 
       62 
59 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                   
     | 
| 
       64 
     | 
    
         
            -
                    exit 1
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                  puts "Validation passed for all EXPRESS schemas."
         
     | 
| 
       66 
61 
     | 
    
         
             
                end
         
     | 
| 
       67 
62 
     | 
    
         | 
| 
       68 
63 
     | 
    
         
             
                desc "version", "Expressir Version"
         
     | 
| 
         Binary file 
     | 
| 
         @@ -94,8 +94,13 @@ module Expressir 
     | 
|
| 
       94 
94 
     | 
    
         
             
                  # @param [String] root_path
         
     | 
| 
       95 
95 
     | 
    
         
             
                  # @param [Express::Formatter] formatter
         
     | 
| 
       96 
96 
     | 
    
         
             
                  # @param [Boolean] include_empty
         
     | 
| 
      
 97 
     | 
    
         
            +
                  # @param [Proc] select_proc
         
     | 
| 
       97 
98 
     | 
    
         
             
                  # @return [Hash]
         
     | 
| 
       98 
     | 
    
         
            -
                  def to_hash(root_path: nil, formatter: nil, include_empty: nil)
         
     | 
| 
      
 99 
     | 
    
         
            +
                  def to_hash(root_path: nil, formatter: nil, include_empty: nil, select_proc: nil)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    # Filter out entries
         
     | 
| 
      
 101 
     | 
    
         
            +
                    has_filter = !select_proc.nil? && select_proc.is_a?(Proc)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    return nil if has_filter && !select_proc.call(self)
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
       99 
104 
     | 
    
         
             
                    hash = {}
         
     | 
| 
       100 
105 
     | 
    
         
             
                    hash[CLASS_KEY] = self.class.name
         
     | 
| 
       101 
106 
     | 
    
         | 
| 
         @@ -106,20 +111,32 @@ module Expressir 
     | 
|
| 
       106 
111 
     | 
    
         
             
                      # skip empty values
         
     | 
| 
       107 
112 
     | 
    
         
             
                      next unless !empty or include_empty
         
     | 
| 
       108 
113 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
                       
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 114 
     | 
    
         
            +
                      value_hash = case value
         
     | 
| 
      
 115 
     | 
    
         
            +
                                   when Array
         
     | 
| 
      
 116 
     | 
    
         
            +
                                     value.map do |v|
         
     | 
| 
      
 117 
     | 
    
         
            +
                                       if v.is_a? ModelElement
         
     | 
| 
      
 118 
     | 
    
         
            +
                                         v.to_hash(
         
     | 
| 
      
 119 
     | 
    
         
            +
                                           root_path: root_path,
         
     | 
| 
      
 120 
     | 
    
         
            +
                                           formatter: formatter,
         
     | 
| 
      
 121 
     | 
    
         
            +
                                           include_empty: include_empty,
         
     | 
| 
      
 122 
     | 
    
         
            +
                                           select_proc: select_proc
         
     | 
| 
      
 123 
     | 
    
         
            +
                                         )
         
     | 
| 
      
 124 
     | 
    
         
            +
                                       else
         
     | 
| 
      
 125 
     | 
    
         
            +
                                         v
         
     | 
| 
      
 126 
     | 
    
         
            +
                                       end
         
     | 
| 
      
 127 
     | 
    
         
            +
                                     end.compact
         
     | 
| 
      
 128 
     | 
    
         
            +
                                   when ModelElement
         
     | 
| 
      
 129 
     | 
    
         
            +
                                     value.to_hash(
         
     | 
| 
      
 130 
     | 
    
         
            +
                                       root_path: root_path,
         
     | 
| 
      
 131 
     | 
    
         
            +
                                       formatter: formatter,
         
     | 
| 
      
 132 
     | 
    
         
            +
                                       include_empty: include_empty,
         
     | 
| 
      
 133 
     | 
    
         
            +
                                       select_proc: select_proc
         
     | 
| 
      
 134 
     | 
    
         
            +
                                     )
         
     | 
| 
      
 135 
     | 
    
         
            +
                                   else
         
     | 
| 
      
 136 
     | 
    
         
            +
                                     value
         
     | 
| 
      
 137 
     | 
    
         
            +
                                   end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                      hash[variable.to_s] = value_hash unless value_hash.nil?
         
     | 
| 
       123 
140 
     | 
    
         
             
                    end
         
     | 
| 
       124 
141 
     | 
    
         | 
| 
       125 
142 
     | 
    
         
             
                    if self.is_a? Declarations::Schema and file
         
     | 
    
        data/lib/expressir/version.rb
    CHANGED
    
    
| 
         @@ -23,6 +23,31 @@ RSpec.describe Expressir::Model::ModelElement do 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  GC.verify_compaction_references
         
     | 
| 
       24 
24 
     | 
    
         
             
                  GC.verify_internal_consistency
         
     | 
| 
       25 
25 
     | 
    
         
             
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                it "exports objects filtered by select_proc (multiple.exp)" do |example|
         
     | 
| 
      
 28 
     | 
    
         
            +
                  print "\n[#{example.description}] "
         
     | 
| 
      
 29 
     | 
    
         
            +
                  exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  repo = Expressir::Express::Parser.from_file(exp_file)
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  filtered_schemas = ["multiple_schema2", "multiple_schema3"]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  select_proc = Proc.new do |value|
         
     | 
| 
      
 35 
     | 
    
         
            +
                    if value.is_a?(Expressir::Model::Declarations::Schema)
         
     | 
| 
      
 36 
     | 
    
         
            +
                      filtered_schemas.include?(value.id)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    else
         
     | 
| 
      
 38 
     | 
    
         
            +
                      true
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  result = repo.to_hash(select_proc: select_proc)
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  expect(result["schemas"].map { |s| s["id"] }.sort).to eq(filtered_schemas)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  # Validate Object Space
         
     | 
| 
      
 47 
     | 
    
         
            +
                  GC.start
         
     | 
| 
      
 48 
     | 
    
         
            +
                  GC.verify_compaction_references
         
     | 
| 
      
 49 
     | 
    
         
            +
                  GC.verify_internal_consistency
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
       26 
51 
     | 
    
         
             
              end
         
     | 
| 
       27 
52 
     | 
    
         | 
| 
       28 
53 
     | 
    
         
             
              describe ".from_hash" do
         
     | 
    
        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: 1.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86_64-darwin
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ribose Inc.
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-05-13 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: thor
         
     |