ro-crate 0.4.6 → 0.4.11
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/Gemfile.lock +8 -8
- data/README.md +37 -0
- data/lib/ro_crate.rb +1 -0
- data/lib/ro_crate/model/contextual_entity.rb +2 -14
- data/lib/ro_crate/model/crate.rb +14 -0
- data/lib/ro_crate/model/data_entity.rb +3 -3
- data/lib/ro_crate/model/directory.rb +1 -3
- data/lib/ro_crate/model/entity.rb +24 -2
- data/lib/ro_crate/model/file.rb +1 -3
- data/lib/ro_crate/model/metadata.rb +9 -1
- data/lib/ro_crate/model/organization.rb +1 -1
- data/lib/ro_crate/model/preview.rb +3 -15
- data/lib/ro_crate/model/preview_generator.rb +40 -0
- data/lib/ro_crate/reader.rb +122 -26
- data/ro_crate.gemspec +2 -2
- data/test/crate_test.rb +12 -0
- data/test/entity_test.rb +21 -0
- data/test/fixtures/nested_directory.zip +0 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/LICENSE +176 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/README.md +6 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/ro-crate-metadata.json +133 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/sort-and-change-case.ga +118 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/input.bed +3 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/output_exp.bed +3 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/sort-and-change-case-test.yml +8 -0
- data/test/fixtures/sparse_directory_crate/ro-crate-preview.html +60 -59
- data/test/reader_test.rb +56 -0
- data/test/writer_test.rb +22 -2
- metadata +13 -4
| @@ -1,66 +1,67 @@ | |
| 1 1 | 
             
            <!DOCTYPE html>
         | 
| 2 2 | 
             
            <html>
         | 
| 3 3 | 
             
            <head>
         | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
            }</script>
         | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 4 | 
            +
                <title>New RO-Crate</title>
         | 
| 5 | 
            +
                <script type="application/ld+json">{
         | 
| 6 | 
            +
                    "@context": "https://w3id.org/ro/crate/1.0/context",
         | 
| 7 | 
            +
                    "@graph": [
         | 
| 8 | 
            +
                        {
         | 
| 9 | 
            +
                            "@id": "ro-crate-metadata.jsonld",
         | 
| 10 | 
            +
                            "@type": "CreativeWork",
         | 
| 11 | 
            +
                            "about": {
         | 
| 12 | 
            +
                                "@id": "./"
         | 
| 13 | 
            +
                            }
         | 
| 14 | 
            +
                        },
         | 
| 15 | 
            +
                        {
         | 
| 16 | 
            +
                            "@id": "ro-crate-preview.html",
         | 
| 17 | 
            +
                            "@type": "CreativeWork",
         | 
| 18 | 
            +
                            "about": {
         | 
| 19 | 
            +
                                "@id": "./"
         | 
| 20 | 
            +
                            }
         | 
| 21 | 
            +
                        },
         | 
| 22 | 
            +
                        {
         | 
| 23 | 
            +
                            "@id": "./",
         | 
| 24 | 
            +
                            "@type": "Dataset",
         | 
| 25 | 
            +
                            "hasPart": [
         | 
| 26 | 
            +
                                {
         | 
| 27 | 
            +
                                    "@id": "listed_file.txt"
         | 
| 28 | 
            +
                                }
         | 
| 29 | 
            +
                            ]
         | 
| 30 | 
            +
                        },
         | 
| 31 | 
            +
                        {
         | 
| 32 | 
            +
                            "@id": "listed_file.txt",
         | 
| 33 | 
            +
                            "@type": "File"
         | 
| 34 | 
            +
                        }
         | 
| 35 | 
            +
                    ]
         | 
| 36 | 
            +
                }</script>
         | 
| 37 | 
            +
                <meta name="generator" content="https://github.com/fbacall/ro-crate-ruby">
         | 
| 38 | 
            +
                <meta name="keywords" content="RO-Crate">
         | 
| 39 39 | 
             
            </head>
         | 
| 40 40 | 
             
            <body>
         | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
              <p>
         | 
| 44 | 
            -
                
         | 
| 45 | 
            -
              </p>
         | 
| 46 | 
            -
              <dl>
         | 
| 47 | 
            -
                
         | 
| 48 | 
            -
                
         | 
| 49 | 
            -
                
         | 
| 50 | 
            -
                
         | 
| 51 | 
            -
              </dl>
         | 
| 41 | 
            +
            <h1>New RO-Crate</h1>
         | 
| 42 | 
            +
            Some stuff has been added here blablabla
         | 
| 52 43 |  | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 44 | 
            +
            <p>
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            </p>
         | 
| 47 | 
            +
            <dl>
         | 
| 48 | 
            +
             | 
| 49 | 
            +
             | 
| 50 | 
            +
             | 
| 51 | 
            +
             | 
| 52 | 
            +
            </dl>
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            <h2>Contents</h2>
         | 
| 55 | 
            +
            <ul>
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                <li id="__data_entity_listed_file.txt">
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    <strong>listed_file.txt</strong>
         | 
| 60 | 
            +
             | 
| 61 | 
            +
             | 
| 62 | 
            +
             | 
| 63 | 
            +
                </li>
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            </ul>
         | 
| 65 66 | 
             
            </body>
         | 
| 66 | 
            -
            </html>
         | 
| 67 | 
            +
            </html>
         | 
    
        data/test/reader_test.rb
    CHANGED
    
    | @@ -195,4 +195,60 @@ class ReaderTest < Test::Unit::TestCase | |
| 195 195 | 
             
                assert crate.entries['fish/data/binary.jpg']
         | 
| 196 196 | 
             
                assert_equal ['./', 'listed_file.txt', 'ro-crate-metadata.jsonld', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
         | 
| 197 197 | 
             
              end
         | 
| 198 | 
            +
             | 
| 199 | 
            +
              test 'reading a zip from various object types' do
         | 
| 200 | 
            +
                string_io = StringIO.new
         | 
| 201 | 
            +
                string_io.write(::File.read(fixture_file('sparse_directory_crate.zip').path))
         | 
| 202 | 
            +
                string_io.rewind
         | 
| 203 | 
            +
                assert string_io.is_a?(StringIO)
         | 
| 204 | 
            +
                assert_equal 11, ROCrate::Reader.read_zip(string_io).entries.count
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                path = Pathname.new(fixture_file('sparse_directory_crate.zip').path)
         | 
| 207 | 
            +
                assert path.is_a?(Pathname)
         | 
| 208 | 
            +
                assert_equal 11, ROCrate::Reader.read_zip(path).entries.count
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                file = ::File.open(fixture_file('sparse_directory_crate.zip').path)
         | 
| 211 | 
            +
                assert file.is_a?(::File)
         | 
| 212 | 
            +
                assert_equal 11, ROCrate::Reader.read_zip(file).entries.count
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                string = fixture_file('sparse_directory_crate.zip').path
         | 
| 215 | 
            +
                assert string.is_a?(String)
         | 
| 216 | 
            +
                assert_equal 11, ROCrate::Reader.read_zip(string).entries.count
         | 
| 217 | 
            +
              end
         | 
| 218 | 
            +
             | 
| 219 | 
            +
              test 'reading from zip where the crate root is nested somewhere within' do
         | 
| 220 | 
            +
                crate = ROCrate::Reader.read_zip(fixture_file('nested_directory.zip'))
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                assert crate.entries['fish/info.txt']
         | 
| 223 | 
            +
                assert_equal '1234', crate.entries['fish/info.txt'].source.read.chomp
         | 
| 224 | 
            +
                assert crate.entries['fish/root.txt']
         | 
| 225 | 
            +
                assert crate.entries['fish/data/info.txt']
         | 
| 226 | 
            +
                assert crate.entries['fish/data/nested.txt']
         | 
| 227 | 
            +
                assert crate.entries['fish/data/binary.jpg']
         | 
| 228 | 
            +
                assert_equal ['./', 'fish/', 'ro-crate-metadata.json', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
         | 
| 229 | 
            +
              end
         | 
| 230 | 
            +
             | 
| 231 | 
            +
              test 'reading preserves any additions to @context' do
         | 
| 232 | 
            +
                crate = ROCrate::Reader.read_directory(fixture_file('ro-crate-galaxy-sortchangecase').path)
         | 
| 233 | 
            +
             | 
| 234 | 
            +
                context = crate.metadata.context
         | 
| 235 | 
            +
                assert_equal [
         | 
| 236 | 
            +
                                 'https://w3id.org/ro/crate/1.1/context',
         | 
| 237 | 
            +
                                 {
         | 
| 238 | 
            +
                                     'TestSuite' => 'https://w3id.org/ro/terms/test#TestSuite',
         | 
| 239 | 
            +
                                     'TestInstance' => 'https://w3id.org/ro/terms/test#TestInstance',
         | 
| 240 | 
            +
                                     'TestService' => 'https://w3id.org/ro/terms/test#TestService',
         | 
| 241 | 
            +
                                     'TestDefinition' => 'https://w3id.org/ro/terms/test#TestDefinition',
         | 
| 242 | 
            +
                                     'PlanemoEngine' => 'https://w3id.org/ro/terms/test#PlanemoEngine',
         | 
| 243 | 
            +
                                     'JenkinsService' => 'https://w3id.org/ro/terms/test#JenkinsService',
         | 
| 244 | 
            +
                                     'TravisService' => 'https://w3id.org/ro/terms/test#TravisService',
         | 
| 245 | 
            +
                                     'GithubService' => 'https://w3id.org/ro/terms/test#GithubService',
         | 
| 246 | 
            +
                                     'instance' => 'https://w3id.org/ro/terms/test#instance',
         | 
| 247 | 
            +
                                     'runsOn' => 'https://w3id.org/ro/terms/test#runsOn',
         | 
| 248 | 
            +
                                     'resource' => 'https://w3id.org/ro/terms/test#resource',
         | 
| 249 | 
            +
                                     'definition' => 'https://w3id.org/ro/terms/test#definition',
         | 
| 250 | 
            +
                                     'engineVersion' => 'https://w3id.org/ro/terms/test#engineVersion'
         | 
| 251 | 
            +
                                 }
         | 
| 252 | 
            +
                             ], context
         | 
| 253 | 
            +
              end
         | 
| 198 254 | 
             
            end
         | 
    
        data/test/writer_test.rb
    CHANGED
    
    | @@ -124,12 +124,32 @@ class WriterTest < Test::Unit::TestCase | |
| 124 124 | 
             
                  actual_files =  Dir.chdir(dir) { Dir.glob('**/*') }
         | 
| 125 125 | 
             
                  assert_equal expected_files, actual_files
         | 
| 126 126 | 
             
                  expected_files.each do |file|
         | 
| 127 | 
            -
                    next if file == 'ro-crate-metadata.jsonld' # Expected context gets updated.
         | 
| 128 | 
            -
                    next if file == 'ro-crate-preview.html' # RO-Crate preview format changed
         | 
| 129 127 | 
             
                    abs_file_path = ::File.join(fixture, file)
         | 
| 130 128 | 
             
                    next if ::File.directory?(abs_file_path)
         | 
| 131 129 | 
             
                    assert_equal ::File.read(abs_file_path), ::File.read(::File.join(dir, file)), "#{file} didn't match"
         | 
| 132 130 | 
             
                  end
         | 
| 133 131 | 
             
                end
         | 
| 134 132 | 
             
              end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
              test 'reading/writing multiple times does not change the crate' do
         | 
| 135 | 
            +
                input_dir = fixture_file('sparse_directory_crate').path
         | 
| 136 | 
            +
                Dir.mktmpdir do |dir|
         | 
| 137 | 
            +
                  3.times do |i|
         | 
| 138 | 
            +
                    output_dir = ::File.join(dir, "new_directory_#{i}")
         | 
| 139 | 
            +
                    crate = ROCrate::Reader.read(input_dir)
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    ROCrate::Writer.new(crate).write(output_dir)
         | 
| 142 | 
            +
                    expected_files = Dir.chdir(input_dir) { Dir.glob('**/*') }
         | 
| 143 | 
            +
                    actual_files =  Dir.chdir(output_dir) { Dir.glob('**/*') }
         | 
| 144 | 
            +
                    assert_equal expected_files, actual_files
         | 
| 145 | 
            +
                    expected_files.each do |file|
         | 
| 146 | 
            +
                      abs_file_path = ::File.join(input_dir, file)
         | 
| 147 | 
            +
                      next if ::File.directory?(abs_file_path)
         | 
| 148 | 
            +
                      assert_equal ::File.read(abs_file_path), ::File.read(::File.join(output_dir, file)), "#{file} didn't match"
         | 
| 149 | 
            +
                    end
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    input_dir = output_dir
         | 
| 152 | 
            +
                  end
         | 
| 153 | 
            +
                end
         | 
| 154 | 
            +
              end
         | 
| 135 155 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ro-crate
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4. | 
| 4 | 
            +
              version: 0.4.11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Finn Bacall
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-04-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: addressable
         | 
| @@ -72,14 +72,14 @@ dependencies: | |
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: 0. | 
| 75 | 
            +
                    version: 0.21.2
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: 0. | 
| 82 | 
            +
                    version: 0.21.2
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: yard
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -137,6 +137,7 @@ files: | |
| 137 137 | 
             
            - lib/ro_crate/model/organization.rb
         | 
| 138 138 | 
             
            - lib/ro_crate/model/person.rb
         | 
| 139 139 | 
             
            - lib/ro_crate/model/preview.rb
         | 
| 140 | 
            +
            - lib/ro_crate/model/preview_generator.rb
         | 
| 140 141 | 
             
            - lib/ro_crate/model/remote_entry.rb
         | 
| 141 142 | 
             
            - lib/ro_crate/reader.rb
         | 
| 142 143 | 
             
            - lib/ro_crate/ro-crate-preview.html.erb
         | 
| @@ -165,6 +166,14 @@ files: | |
| 165 166 | 
             
            - test/fixtures/directory_crate/ro-crate-preview.html
         | 
| 166 167 | 
             
            - test/fixtures/file with spaces.txt
         | 
| 167 168 | 
             
            - test/fixtures/info.txt
         | 
| 169 | 
            +
            - test/fixtures/nested_directory.zip
         | 
| 170 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/LICENSE
         | 
| 171 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/README.md
         | 
| 172 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/ro-crate-metadata.json
         | 
| 173 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/sort-and-change-case.ga
         | 
| 174 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/input.bed
         | 
| 175 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/output_exp.bed
         | 
| 176 | 
            +
            - test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/sort-and-change-case-test.yml
         | 
| 168 177 | 
             
            - test/fixtures/spaces/file with spaces.txt
         | 
| 169 178 | 
             
            - test/fixtures/spaces/ro-crate-metadata.jsonld
         | 
| 170 179 | 
             
            - test/fixtures/sparse_directory_crate.zip
         |