From 89474face62004ab70430ef718556fe50720e038 Mon Sep 17 00:00:00 2001 From: mdorf Date: Thu, 7 Sep 2023 16:55:04 -0700 Subject: [PATCH 1/3] fixed Gemfile after merging from master --- Gemfile | 4 ++-- Gemfile.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index ba7af023..84eff580 100644 --- a/Gemfile +++ b/Gemfile @@ -33,5 +33,5 @@ group :development do end # NCBO gems (can be from a local dev path or from rubygems/git) -gem 'goo', github: 'ncbo/goo', branch: 'develop' -gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop' +gem 'goo', github: 'ncbo/goo', branch: 'master' +gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master' diff --git a/Gemfile.lock b/Gemfile.lock index 46d8f227..6ee3d830 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/ncbo/goo.git - revision: 911d71aefe433314d11398445e3856fca503b9c1 - branch: develop + revision: cd477a1c71d8c2b2c26c3ea92c9457643a9cc70a + branch: master specs: goo (0.0.2) addressable (~> 2.8) @@ -15,8 +15,8 @@ GIT GIT remote: https://github.com/ncbo/sparql-client.git - revision: 55e7dbf858eb571c767bc67868f9af61663859cb - branch: develop + revision: d418d56a6c9ff5692f925b45739a2a1c66bca851 + branch: master specs: sparql-client (1.0.1) json_pure (>= 1.4) From a7ad210e846a390f203457be2459719214d142fe Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 11 Sep 2023 21:01:05 -0700 Subject: [PATCH 2/3] Gemfile.lock update --- Gemfile.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6ee3d830..64bbab41 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/ncbo/goo.git - revision: cd477a1c71d8c2b2c26c3ea92c9457643a9cc70a + revision: daea7822af9e5ca1961d6873a758735133a1b2db branch: master specs: goo (0.0.2) @@ -139,7 +139,7 @@ GEM rsolr (2.5.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rubocop (1.56.2) + rubocop (1.56.3) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -181,6 +181,7 @@ GEM macaddr (~> 1.0) PLATFORMS + aarch64-linux arm64-darwin-22 x86_64-darwin-18 x86_64-darwin-21 From c9e05b212dcf82860693cb43de052b379f0a08f1 Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Sat, 28 Oct 2023 10:00:28 +0200 Subject: [PATCH 3/3] make the slice acronym validator not accepting underscores --- Gemfile | 4 +-- Gemfile.lock | 40 +++++++++++----------- lib/ontologies_linked_data/models/slice.rb | 25 ++++++++++---- test/models/test_slice.rb | 23 ++++++++++++- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/Gemfile b/Gemfile index 84eff580..ba7af023 100644 --- a/Gemfile +++ b/Gemfile @@ -33,5 +33,5 @@ group :development do end # NCBO gems (can be from a local dev path or from rubygems/git) -gem 'goo', github: 'ncbo/goo', branch: 'master' -gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master' +gem 'goo', github: 'ncbo/goo', branch: 'develop' +gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop' diff --git a/Gemfile.lock b/Gemfile.lock index 64bbab41..067e5720 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/ncbo/goo.git - revision: daea7822af9e5ca1961d6873a758735133a1b2db - branch: master + revision: 83425ba6c05d051d86c6f5775540727ce4238443 + branch: develop specs: goo (0.0.2) addressable (~> 2.8) @@ -15,8 +15,8 @@ GIT GIT remote: https://github.com/ncbo/sparql-client.git - revision: d418d56a6c9ff5692f925b45739a2a1c66bca851 - branch: master + revision: 55e7dbf858eb571c767bc67868f9af61663859cb + branch: develop specs: sparql-client (1.0.1) json_pure (>= 1.4) @@ -53,11 +53,12 @@ GEM launchy (~> 2.1) mail (~> 2.7) eventmachine (1.2.7) - faraday (2.7.10) + faraday (2.7.11) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.3) hashie (5.0.0) htmlentities (4.3.4) http-accept (1.7.0) @@ -82,7 +83,7 @@ GEM method_source (1.0.0) mime-types (3.5.1) mime-types-data (~> 3.2015) - mime-types-data (3.2023.0808) + mime-types-data (3.2023.1003) mini_mime (1.1.5) minitest (4.7.5) minitest-reporters (0.14.24) @@ -92,21 +93,21 @@ GEM powerbar multi_json (1.15.0) net-http-persistent (2.9.4) - net-imap (0.3.7) + net-imap (0.4.2) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol netrc (0.11.0) oj (3.16.1) omni_logger (0.1.4) logger parallel (1.23.0) - parser (3.2.2.3) + parser (3.2.2.4) ast (~> 2.4.1) racc pony (1.13.1) @@ -125,11 +126,11 @@ GEM rake (10.5.0) rdf (1.0.8) addressable (>= 2.2) - redis (5.0.7) - redis-client (>= 0.9.0) - redis-client (0.17.0) + redis (5.0.8) + redis-client (>= 0.17.0) + redis-client (0.18.0) connection_pool - regexp_parser (2.8.1) + regexp_parser (2.8.2) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) @@ -139,19 +140,18 @@ GEM rsolr (2.5.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rubocop (1.56.3) - base64 (~> 0.1.1) + rubocop (1.57.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -176,7 +176,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) uuid (2.3.9) macaddr (~> 1.0) @@ -216,4 +216,4 @@ DEPENDENCIES thin BUNDLED WITH - 2.3.15 + 2.4.12 diff --git a/lib/ontologies_linked_data/models/slice.rb b/lib/ontologies_linked_data/models/slice.rb index 65748f2e..c8e8f3c6 100644 --- a/lib/ontologies_linked_data/models/slice.rb +++ b/lib/ontologies_linked_data/models/slice.rb @@ -13,12 +13,25 @@ class Slice < LinkedData::Models::Base def self.validate_acronym(inst, attr) inst.bring(attr) if inst.bring?(attr) - value = inst.send(attr) - acronym_regex = /\A[-_a-z]+\Z/ - if (acronym_regex.match value).nil? - return [:acronym_value_validator,"The acronym value #{value} is invalid"] + acronym = inst.send(attr) + + return [] if acronym.nil? + + errors = [] + + if acronym.match(/\A[^a-z^A-Z]{1}/) + errors << [:start_with_letter, "`acronym` must start with a letter"] + end + + if acronym.match(/[^-0-9a-zA-Z]/) + errors << [:special_characters, "`acronym` must only contain the folowing characters: -, letters, and numbers"] + end + + if acronym.match(/.{17,}/) + errors << [:length, "`acronym` must be sixteen characters or less"] end - return [:acronym_value_validator, nil] + + return errors.flatten end def self.synchronize_groups_to_slices @@ -31,7 +44,7 @@ def self.synchronize_groups_to_slices slice.save if slice.valid? else slice = self.new({ - acronym: g.acronym.downcase.gsub(" ", "_"), + acronym: g.acronym.downcase.gsub(" ", "-"), name: g.name, description: g.description, ontologies: g.ontologies diff --git a/test/models/test_slice.rb b/test/models/test_slice.rb index 699fb0f2..8cc243b1 100644 --- a/test/models/test_slice.rb +++ b/test/models/test_slice.rb @@ -54,7 +54,7 @@ def test_slice_lifecycle s = LinkedData::Models::Slice.new({ :name => "Test Slice", :description => "This is a test slice", - :acronym => "test_slice", + :acronym => "test-slice", :ontologies => @@onts[3..-1] }) @@ -70,6 +70,27 @@ def test_synchronization assert slices.map {|s| s.acronym}.include?(@@group_acronym) end + def test_slice_acronym_validity + s = LinkedData::Models::Slice.new({ + :name => "Test Slice", + :description => "This is a test slice", + :acronym => "test_slice", + :ontologies => @@onts[3..-1] + }) + + refute s.valid? + + s = LinkedData::Models::Slice.new({ + :name => "Test Slice", + :description => "This is a test slice", + :acronym => "test-slice", + :ontologies => @@onts[3..-1] + }) + + assert s.valid? + + end + private def self._create_group