Projects
openEuler:Mainline
rubygem-globalid
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:rubygem-globalid.spec
Changed
@@ -1,13 +1,15 @@ %global gem_name globalid %{?_with_bootstrap: %global bootstrap 1} Name: rubygem-%{gem_name} -Version: 0.4.2 -Release: 3 +Version: 1.0.0 +Release: 2 Summary: Refer to any model with a URI: gid://app/class/id License: MIT URL: https://github.com/rails/%{gem_name} Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem Source1: https://github.com/rails/%{gem_name}/archive/v%{version}.tar.gz +Patch0: CVE-2023-22799.patch + BuildRequires: ruby(release) rubygems-devel ruby >= 1.9.3 %if ! 0%{?bootstrap} BuildRequires: rubygem(activesupport) >= 4.1 rubygem(activemodel) >= 4.1 @@ -26,6 +28,7 @@ %prep %setup -q -n %{gem_name}-%{version} -b 1 +%patch0 -p1 %build gem build ../%{gem_name}-%{version}.gemspec @@ -39,7 +42,7 @@ %check pushd .%{gem_instdir} -ln -s %{_builddir}/globalid-0.4.2/test test +ln -s %{_builddir}/globalid-%{version}/test test sed -i "/bundler\/setup/ s/^/#/" ./test/helper.rb sed -i "/defaults to nil when secret_token is not present' do/a \\ skip 'Not compatible with Rails 5.2'" test/cases/railtie_test.rb @@ -59,6 +62,12 @@ %doc %{gem_instdir}/README.md %changelog +* Tue Feb 07 2023 liyuxiang<liyuxiang@ncti-gba.cn> - 1.0.0-2 +- fix CVE-2023-22799 + +* Tue Jan 17 2023 wangkai <wangkai385@h-partners.com> - 1.0.0-1 +- Upgrade to version 1.0.0 + * Thu Aug 12 2021 liyanan <liyanan32@huawei.com> - 0.4.2-3 - fix spec file name
View file
_service:tar_scm:CVE-2023-22799.patch
Added
@@ -0,0 +1,50 @@ +From 3bc4349422e60f2235876a59dd415e98b072eb2b Mon Sep 17 00:00:00 2001 +From: Aaron Patterson <tenderlove@ruby-lang.org> +Date: Tue, 17 Jan 2023 13:32:28 -0800 +Subject: PATCH Fix ReDoS vulnerability in name parsing + +Thanks to @ooooooo_q for the patch! + +CVE-2023-22799 +--- + lib/global_id/uri/gid.rb | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/lib/global_id/uri/gid.rb b/lib/global_id/uri/gid.rb +index f5d52dc..3fadf4f 100644 +--- a/lib/global_id/uri/gid.rb ++++ b/lib/global_id/uri/gid.rb +@@ -127,9 +127,6 @@ def set_params(params) + private + COMPONENT = :scheme, :app, :model_name, :model_id, :params .freeze + +- # Extracts model_name and model_id from the URI path. +- PATH_REGEXP = %r(\A/(^/+)/?(^/+)?\z) +- + def check_host(host) + validate_component(host) + super +@@ -149,11 +146,11 @@ def check_scheme(scheme) + end + + def set_model_components(path, validate = false) +- _, model_name, model_id = path.match(PATH_REGEXP).to_a +- model_id = CGI.unescape(model_id) if model_id +- ++ _, model_name, model_id = path.split('/', 3) + validate_component(model_name) && validate_model_id(model_id, model_name) if validate + ++ model_id = CGI.unescape(model_id) if model_id ++ + @model_name = model_name + @model_id = model_id + end +@@ -166,7 +163,7 @@ def validate_component(component) + end + + def validate_model_id(model_id, model_name) +- return model_id unless model_id.blank? ++ return model_id unless model_id.blank? || model_id.include?('/') + + raise MissingModelIdError, "Unable to create a Global ID for " \ + "#{model_name} without a model id."
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/rubygem-globalid.git</param> - <param name="revision">e276a93b3d48d3f43be8ce33decf075a7a2c6af7</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:globalid-0.4.2.gem/checksums.yaml.gz -> _service:tar_scm:globalid-1.0.0.gem/checksums.yaml.gz
Changed
@@ -1,7 +1,7 @@ --- SHA256: - metadata.gz: 1c51189af124bc8712e1242070c33fa3bfd26c900003699a2b21328e8d197e55 - data.tar.gz: b00783d7b5fd8b7def68e925d6f70e3ddfb70ad82c3603061c0d29e736dfa9f4 + metadata.gz: 4f36292e3297f3b86657a1f78ddbc66b49ca68c180ed19a982da42b6b8c217d3 + data.tar.gz: 7283f395e6ee9f52b6eca60ef6bb30bff5f18aebfc6967a4d01b2562b5c05535 SHA512: - metadata.gz: 5f5b1a859baae95d9efb693f8d9a0cfb008c82cedfbc3cc994b51cdf46d7191725317e31f8eee824ade1c04a9924d661ca1b9c04e7032ab9250aa20bf8e73614 - data.tar.gz: c0ac25a21157363a3274e4e58ba99146fa2ce90e0860bbe7c21356a9af9d8013c0404bef2d6f4c793ca20aae287c26fa9625e4c74170574a1f4b048dd961fe0e + metadata.gz: f49b754df08e92cfca61de31d9df0a79ffdeaec3866da4210bfb293fe76043402294d9fede88f0d11f74e2d16beb962cde3cfc475806db8c99d7d17b5d7b43e1 + data.tar.gz: 96870a2787b2267b91413096d2096f364d67ed1d059d4244110500310f592516c3c3dab815f147d739d7fde7bb4a8e22d538130dc6fef21e23b22c02e032c4c9
View file
_service:tar_scm:globalid-0.4.2.gem/data/README.md -> _service:tar_scm:globalid-1.0.0.gem/data/README.md
Changed
@@ -133,6 +133,34 @@ # => #<Person:0x007fae94bf6298 @id="1"> ``` +### Locating many Global IDs + +When needing to locate many Global IDs use `GlobalID::Locator.locate_many` or `GlobalID::Locator.locate_many_signed` for Signed Global IDs to allow loading +Global IDs more efficiently. + +For instance, the default locator passes every `model_id` per `model_name` thus +using `model_name.where(id: model_ids)` versus `GlobalID::Locator.locate`'s `model_name.find(id)`. + +In the case of looking up Global IDs from a database, it's only necessary to query +once per `model_name` as shown here: + +```ruby +gids = users.concat(people).sort_by(&:id).map(&:to_global_id) +# => #<GlobalID:0x00007ffd6a8411a0 @uri=#<URI::GID gid://app/User/1>>, +#<GlobalID:0x00007ffd675d32b8 @uri=#<URI::GID gid://app/Student/1>>, +#<GlobalID:0x00007ffd6a840b10 @uri=#<URI::GID gid://app/User/2>>, +#<GlobalID:0x00007ffd675d2c28 @uri=#<URI::GID gid://app/Student/2>>, +#<GlobalID:0x00007ffd6a840480 @uri=#<URI::GID gid://app/User/3>>, +#<GlobalID:0x00007ffd675d2598 @uri=#<URI::GID gid://app/Student/3>> + +GlobalID::Locator.locate_many gids +# SELECT "users".* FROM "users" WHERE "users"."id" IN ($1, $2, $3) "id", 1, "id", 2, "id", 3 +# SELECT "students".* FROM "students" WHERE "students"."id" IN ($1, $2, $3) "id", 1, "id", 2, "id", 3 +# => #<User id: 1>, #<Student id: 1>, #<User id: 2>, #<Student id: 2>, #<User id: 3>, #<Student id: 3> +``` + +Note the order is maintained in the returned results. + ### Custom App Locator A custom locator can be set for an app by calling `GlobalID::Locator.use` and providing an app locator to use for that app.
View file
_service:tar_scm:globalid-1.0.0.gem/data/lib/global_id/fixture_set.rb
Added
@@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class GlobalID + module FixtureSet + def signed_global_id(fixture_set_name, label, column_type: :integer, **options) + identifier = identify(label, column_type) + model_name = default_fixture_model_name(fixture_set_name) + uri = URI::GID.build(GlobalID.app, model_name, identifier, {}) + + SignedGlobalID.new(uri, **options) + end + end +end
View file
_service:tar_scm:globalid-0.4.2.gem/data/lib/global_id/identification.rb -> _service:tar_scm:globalid-1.0.0.gem/data/lib/global_id/identification.rb
Changed
@@ -1,9 +1,5 @@ -require 'active_support/concern' - class GlobalID module Identification - extend ActiveSupport::Concern - def to_global_id(options = {}) GlobalID.create(self, options) end
View file
_service:tar_scm:globalid-0.4.2.gem/data/lib/global_id/railtie.rb -> _service:tar_scm:globalid-1.0.0.gem/data/lib/global_id/railtie.rb
Changed
@@ -5,6 +5,7 @@ require 'global_id' require 'active_support' require 'active_support/core_ext/string/inflections' +require 'active_support/core_ext/integer/time' class GlobalID # = GlobalID Railtie @@ -18,11 +19,11 @@ default_app_name = app.railtie_name.remove('_application').dasherize GlobalID.app = app.config.global_id.app ||= default_app_name - SignedGlobalID.expires_in = app.config.global_id.expires_in ||= default_expires_in + SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in) config.after_initialize do GlobalID.app = app.config.global_id.app ||= default_app_name - SignedGlobalID.expires_in = app.config.global_id.expires_in ||= default_expires_in + SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in) app.config.global_id.verifier ||= begin GlobalID::Verifier.new(app.key_generator.generate_key('signed_global_ids')) @@ -36,6 +37,11 @@ require 'global_id/identification' send :include, GlobalID::Identification end + + ActiveSupport.on_load(:active_record_fixture_set) do + require 'global_id/fixture_set' + send :extend, GlobalID::FixtureSet + end end end end
View file
_service:tar_scm:globalid-0.4.2.gem/data/lib/global_id/uri/gid.rb -> _service:tar_scm:globalid-1.0.0.gem/data/lib/global_id/uri/gid.rb
Changed
@@ -173,5 +173,9 @@ end end - @@schemes'GID' = GID + if respond_to?(:register_scheme) + register_scheme('GID', GID) + else + @@schemes'GID' = GID + end end
View file
_service:tar_scm:globalid-0.4.2.gem/metadata.gz -> _service:tar_scm:globalid-1.0.0.gem/metadata.gz
Changed
@@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: globalid version: !ruby/object:Gem::Version - version: 0.4.2 + version: 1.0.0 platform: ruby authors: - David Heinemeier Hansson autorequire: bindir: bin cert_chain: -date: 2019-01-11 00:00:00.000000000 Z +date: 2021-11-25 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: activesupport @@ -16,14 +16,14 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: 4.2.0 + version: '5.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version - version: 4.2.0 + version: '5.0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement @@ -47,6 +47,7 @@ - MIT-LICENSE - README.md - lib/global_id.rb +- lib/global_id/fixture_set.rb - lib/global_id/global_id.rb - lib/global_id/identification.rb - lib/global_id/locator.rb @@ -67,14 +68,14 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: 1.9.3 + version: 2.5.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: -rubygems_version: 3.0.2 +rubygems_version: 3.2.22 signing_key: specification_version: 4 summary: 'Refer to any model with a URI: gid://app/class/id'
View file
_service:tar_scm:v0.4.2.tar.gz/.travis.yml
Deleted
@@ -1,47 +0,0 @@ ---- -language: ruby -sudo: false -before_install: - - gem install bundler - - "rm -f ${BUNDLE_GEMFILE}.lock" -before_script: - - bundle update -cache: bundler -rvm: -- 2.2.10 -- 2.3.8 -- 2.4.5 -- 2.5.3 -- ruby-head -- rbx-2 -- jruby -gemfile: -- gemfiles/rails_4.2.gemfile -- gemfiles/rails_5.0.gemfile -- gemfiles/rails_5.1.gemfile -- gemfiles/rails_5.2.gemfile -matrix: - include: - - rvm: 1.9.3 - gemfile: gemfiles/rails_4.2.gemfile - - rvm: 2.0.0 - gemfile: gemfiles/rails_4.2.gemfile - - rvm: 2.1.10 - gemfile: gemfiles/rails_4.2.gemfile - allow_failures: - - rvm: rbx-2 - - rvm: jruby - - rvm: ruby-head - fast_finish: true -notifications: - email: false - irc: - on_success: change - on_failure: always - channels: - - "irc.freenode.org#rails-contrib" - campfire: - on_success: change - on_failure: always - rooms: - - secure: "A6lU9PnAYUzvayOnJjKXA+lav6uQ4O8+bhFZs/wiEw3I/B/vUyNjxUlDu3qRhZHDKs3LX1zH82BC/TEP6CgVtP7hE0WfgFqaCouLzBxgzlyzQMdlObRdoO1PlNTglfph8Q7gQEY3Fo4dZmE9DfgOzY6Lkopnj7Esg2YnoZ1lrXI="
View file
_service:tar_scm:v0.4.2.tar.gz/gemfiles/rails_4.2.gemfile
Deleted
@@ -1,7 +0,0 @@ -source "https://rubygems.org" - -gem "activemodel", :github => "rails/rails", :branch => "4-2-stable" -gem "railties", :github => "rails/rails", :branch => "4-2-stable" -gem "minitest", "~> 5.10.0" - -gemspec path: "../"
View file
_service:tar_scm:v1.0.0.tar.gz/.devcontainer
Added
+(directory)
View file
_service:tar_scm:v1.0.0.tar.gz/.devcontainer/Dockerfile
Added
@@ -0,0 +1,17 @@ +# Choice Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster +ARG VARIANT=2-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT} + +# Choice Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if "${NODE_VERSION}" != "none" ; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# Optional Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends <your-package-list-here> + +# Optional Uncomment this line to install additional gems. +# RUN gem install <your-gem-names-here> + +# Optional Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 \ No newline at end of file
View file
_service:tar_scm:v1.0.0.tar.gz/.devcontainer/base.Dockerfile
Added
@@ -0,0 +1,43 @@ +# Choice Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster +ARG VARIANT=2-bullseye +FROM ruby:${VARIANT} + +# Copy library scripts to execute +COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/ + +# Option Install zsh +ARG INSTALL_ZSH="true" +# Option Upgrade OS packages to their latest versions +ARG UPGRADE_PACKAGES="true" +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131 + && apt-get purge -y imagemagick imagemagick-6-common \ + # Install common packages, non-root user, rvm, core build tools + && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \ + && bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# Choice Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +ENV NVM_DIR=/usr/local/share/nvm +ENV NVM_SYMLINK_CURRENT=true \ + PATH=${NVM_DIR}/current/bin:${PATH} +RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + + # Remove library scripts for final image +RUN rm -rf /tmp/library-scripts + +# Optional Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends <your-package-list-here> + +# Optional Uncomment this line to install additional gems. +# RUN gem install <your-gem-names-here> + +# Optional Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 \ No newline at end of file
View file
_service:tar_scm:v1.0.0.tar.gz/.devcontainer/devcontainer.json
Added
@@ -0,0 +1,37 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/ruby +{ + "name": "Ruby", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local on arm64/Apple Silicon. + "VARIANT": "3-bullseye", + // Options + "NODE_VERSION": "lts/*" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": {}, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": + "rebornix.Ruby" + , + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": , + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "ruby --version", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "github-cli": "latest" + } + +} \ No newline at end of file
View file
_service:tar_scm:v1.0.0.tar.gz/.github
Added
+(directory)
View file
_service:tar_scm:v1.0.0.tar.gz/.github/workflows
Added
+(directory)
View file
_service:tar_scm:v1.0.0.tar.gz/.github/workflows/ci.yml
Added
@@ -0,0 +1,40 @@ +name: CI +on: push, pull_request +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: 2.5, 2.6, 2.7 + rails: '5.0', '5.1', '5.2', '6.0', '6.1' + include: + - ruby: '3.0' + rails: '6.0' + - ruby: '3.0' + rails: '6.1' + - ruby: head + rails: '6.0' + - ruby: head + rails: '6.1' + - ruby: truffleruby + rails: '6.0' + - ruby: truffleruby + rails: '6.1' + + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests + run: bundle exec rake test + continue-on-error: ${{ matrix.ruby == 'head' || matrix.ruby == 'truffleruby' }} + timeout-minutes: 3
View file
_service:tar_scm:v0.4.2.tar.gz/Gemfile.lock -> _service:tar_scm:v1.0.0.tar.gz/Gemfile.lock
Changed
@@ -1,65 +1,68 @@ PATH remote: . specs: - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (1.0.0) + activesupport (>= 5.0) GEM remote: https://rubygems.org/ specs: - actionpack (5.2.2) - actionview (= 5.2.2) - activesupport (= 5.2.2) - rack (~> 2.0) + actionpack (6.1.4.1) + actionview (= 6.1.4.1) + activesupport (= 6.1.4.1) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.2) - activesupport (= 5.2.2) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actionview (6.1.4.1) + activesupport (= 6.1.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activemodel (5.2.2) - activesupport (= 5.2.2) - activesupport (5.2.2) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activemodel (6.1.4.1) + activesupport (= 6.1.4.1) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - builder (3.2.3) - concurrent-ruby (1.1.4) - crass (1.0.4) - erubi (1.8.0) - i18n (1.5.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + builder (3.2.4) + concurrent-ruby (1.1.9) + crass (1.0.6) + erubi (1.10.0) + i18n (1.8.11) concurrent-ruby (~> 1.0) - loofah (2.2.3) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - method_source (0.9.2) - mini_portile2 (2.4.0) - minitest (5.11.3) - nokogiri (1.10.0) - mini_portile2 (~> 2.4.0) - rack (2.0.6) + method_source (1.0.0) + mini_portile2 (2.6.1) + minitest (5.14.4) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) + racc (1.6.0) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (5.2.2) - actionpack (= 5.2.2) - activesupport (= 5.2.2) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) + railties (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rake (12.3.2) - thor (0.20.3) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) + rake (>= 0.13) + thor (~> 1.0) + rake (13.0.6) + thor (1.1.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.5.1) PLATFORMS ruby @@ -71,4 +74,4 @@ rake BUNDLED WITH - 1.17.3 + 2.2.22
View file
_service:tar_scm:v0.4.2.tar.gz/README.md -> _service:tar_scm:v1.0.0.tar.gz/README.md
Changed
@@ -133,6 +133,34 @@ # => #<Person:0x007fae94bf6298 @id="1"> ``` +### Locating many Global IDs + +When needing to locate many Global IDs use `GlobalID::Locator.locate_many` or `GlobalID::Locator.locate_many_signed` for Signed Global IDs to allow loading +Global IDs more efficiently. + +For instance, the default locator passes every `model_id` per `model_name` thus +using `model_name.where(id: model_ids)` versus `GlobalID::Locator.locate`'s `model_name.find(id)`. + +In the case of looking up Global IDs from a database, it's only necessary to query +once per `model_name` as shown here: + +```ruby +gids = users.concat(people).sort_by(&:id).map(&:to_global_id) +# => #<GlobalID:0x00007ffd6a8411a0 @uri=#<URI::GID gid://app/User/1>>, +#<GlobalID:0x00007ffd675d32b8 @uri=#<URI::GID gid://app/Student/1>>, +#<GlobalID:0x00007ffd6a840b10 @uri=#<URI::GID gid://app/User/2>>, +#<GlobalID:0x00007ffd675d2c28 @uri=#<URI::GID gid://app/Student/2>>, +#<GlobalID:0x00007ffd6a840480 @uri=#<URI::GID gid://app/User/3>>, +#<GlobalID:0x00007ffd675d2598 @uri=#<URI::GID gid://app/Student/3>> + +GlobalID::Locator.locate_many gids +# SELECT "users".* FROM "users" WHERE "users"."id" IN ($1, $2, $3) "id", 1, "id", 2, "id", 3 +# SELECT "students".* FROM "students" WHERE "students"."id" IN ($1, $2, $3) "id", 1, "id", 2, "id", 3 +# => #<User id: 1>, #<Student id: 1>, #<User id: 2>, #<Student id: 2>, #<User id: 3>, #<Student id: 3> +``` + +Note the order is maintained in the returned results. + ### Custom App Locator A custom locator can be set for an app by calling `GlobalID::Locator.use` and providing an app locator to use for that app.
View file
_service:tar_scm:v0.4.2.tar.gz/gemfiles/rails_5.2.gemfile -> _service:tar_scm:v1.0.0.tar.gz/gemfiles/rails_5.2.gemfile
Changed
@@ -1,6 +1,6 @@ source "https://rubygems.org" gem "activemodel", "~> 5.2.0" -gem "railties", "~> 5.2.0" +gem "railties", git: "https://github.com/rails/rails", branch: "5-2-stable" gemspec path: "../"
View file
_service:tar_scm:v1.0.0.tar.gz/gemfiles/rails_6.0.gemfile
Added
@@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "activemodel", "~> 6.0" +gem "railties", "~> 6.0" + +gemspec path: "../"
View file
_service:tar_scm:v1.0.0.tar.gz/gemfiles/rails_6.1.gemfile
Added
@@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "activemodel", "~> 6.1" +gem "railties", "~> 6.1" + +gemspec path: "../"
View file
_service:tar_scm:v0.4.2.tar.gz/globalid.gemspec -> _service:tar_scm:v1.0.0.tar.gz/globalid.gemspec
Changed
@@ -1,11 +1,11 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'globalid' - s.version = '0.4.2' + s.version = '1.0.0' s.summary = 'Refer to any model with a URI: gid://app/class/id' s.description = 'URIs for your models makes it easy to pass references around.' - s.required_ruby_version = '>= 1.9.3' + s.required_ruby_version = '>= 2.5.0' s.license = 'MIT' @@ -16,7 +16,7 @@ s.files = Dir'MIT-LICENSE', 'README.md', 'lib/**/*' s.require_path = 'lib' - s.add_runtime_dependency 'activesupport', '>= 4.2.0' + s.add_runtime_dependency 'activesupport', '>= 5.0' s.add_development_dependency 'rake' end
View file
_service:tar_scm:v1.0.0.tar.gz/lib/global_id/fixture_set.rb
Added
@@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class GlobalID + module FixtureSet + def signed_global_id(fixture_set_name, label, column_type: :integer, **options) + identifier = identify(label, column_type) + model_name = default_fixture_model_name(fixture_set_name) + uri = URI::GID.build(GlobalID.app, model_name, identifier, {}) + + SignedGlobalID.new(uri, **options) + end + end +end
View file
_service:tar_scm:v0.4.2.tar.gz/lib/global_id/identification.rb -> _service:tar_scm:v1.0.0.tar.gz/lib/global_id/identification.rb
Changed
@@ -1,9 +1,5 @@ -require 'active_support/concern' - class GlobalID module Identification - extend ActiveSupport::Concern - def to_global_id(options = {}) GlobalID.create(self, options) end
View file
_service:tar_scm:v0.4.2.tar.gz/lib/global_id/railtie.rb -> _service:tar_scm:v1.0.0.tar.gz/lib/global_id/railtie.rb
Changed
@@ -5,6 +5,7 @@ require 'global_id' require 'active_support' require 'active_support/core_ext/string/inflections' +require 'active_support/core_ext/integer/time' class GlobalID # = GlobalID Railtie @@ -18,11 +19,11 @@ default_app_name = app.railtie_name.remove('_application').dasherize GlobalID.app = app.config.global_id.app ||= default_app_name - SignedGlobalID.expires_in = app.config.global_id.expires_in ||= default_expires_in + SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in) config.after_initialize do GlobalID.app = app.config.global_id.app ||= default_app_name - SignedGlobalID.expires_in = app.config.global_id.expires_in ||= default_expires_in + SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in) app.config.global_id.verifier ||= begin GlobalID::Verifier.new(app.key_generator.generate_key('signed_global_ids')) @@ -36,6 +37,11 @@ require 'global_id/identification' send :include, GlobalID::Identification end + + ActiveSupport.on_load(:active_record_fixture_set) do + require 'global_id/fixture_set' + send :extend, GlobalID::FixtureSet + end end end end
View file
_service:tar_scm:v0.4.2.tar.gz/lib/global_id/uri/gid.rb -> _service:tar_scm:v1.0.0.tar.gz/lib/global_id/uri/gid.rb
Changed
@@ -173,5 +173,9 @@ end end - @@schemes'GID' = GID + if respond_to?(:register_scheme) + register_scheme('GID', GID) + else + @@schemes'GID' = GID + end end
View file
_service:tar_scm:v0.4.2.tar.gz/test/cases/railtie_test.rb -> _service:tar_scm:v1.0.0.tar.gz/test/cases/railtie_test.rb
Changed
@@ -15,6 +15,7 @@ @app = BlogApp::Application.new @app.config.eager_load = false @app.config.logger = Logger.new(nil) + @app.config.secret_key_base = ('x' * 30) end test 'GlobalID.app for Blog::Application defaults to blog' do @@ -28,6 +29,12 @@ assert_equal 'foo', GlobalID.app end + test 'SignedGlobalID.expires_in can be explicitly set to nil with config.global_id.expires_in' do + @app.config.global_id.expires_in = nil + @app.initialize! + assert_nil SignedGlobalID.expires_in + end + test 'config.global_id can be used to set configurations after the railtie has been loaded' do @app.config.eager_load = true @app.config.before_eager_load do @@ -40,8 +47,18 @@ assert_equal 1.year, SignedGlobalID.expires_in end + test 'config.global_id can be used to explicitly set SignedGlobalID.expires_in to nil after the railtie has been loaded' do + @app.config.eager_load = true + @app.config.before_eager_load do + @app.config.global_id.expires_in = nil + end + + @app.initialize! + assert_nil SignedGlobalID.expires_in + end + + test 'SignedGlobalID.verifier defaults to Blog::Application.message_verifier(:signed_global_ids) when secret_key_base is present' do - @app.config.secret_key_base = ('x' * 30) @app.initialize! message = {id: 42} signed_message = SignedGlobalID.verifier.generate(message) @@ -52,6 +69,7 @@ original_env, Rails.env = Rails.env, 'production' begin + @app.config.secret_key_base = nil @app.initialize! assert_nil SignedGlobalID.verifier ensure
View file
_service:tar_scm:v0.4.2.tar.gz/test/helper.rb -> _service:tar_scm:v1.0.0.tar.gz/test/helper.rb
Changed
@@ -1,4 +1,5 @@ require 'bundler/setup' +require 'forwardable' require 'active_support' require 'active_support/testing/autorun'
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2