Hello community, here is the log from the commit of package rubygem-globalid for openSUSE:Factory checked in at 2016-08-25 09:55:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-globalid (Old) and /work/SRC/openSUSE:Factory/.rubygem-globalid.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-globalid" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-globalid/rubygem-globalid.changes 2015-08-05 19:14:43.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-globalid.new/rubygem-globalid.changes 2016-08-25 09:55:43.000000000 +0200 @@ -1,0 +2,6 @@ +Wed Jul 27 04:29:42 UTC 2016 - co...@suse.com + +- updated to version 0.3.7 + no changelog found + +------------------------------------------------------------------- Old: ---- globalid-0.3.6.gem New: ---- globalid-0.3.7.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-globalid.spec ++++++ --- /var/tmp/diff_new_pack.PiuXSO/_old 2016-08-25 09:55:44.000000000 +0200 +++ /var/tmp/diff_new_pack.PiuXSO/_new 2016-08-25 09:55:44.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-globalid # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-globalid -Version: 0.3.6 +Version: 0.3.7 Release: 0 %define mod_name globalid %define mod_full_name %{mod_name}-%{version} @@ -53,7 +53,7 @@ %install %gem_install \ - --doc-files="MIT-LICENSE" \ + --doc-files="MIT-LICENSE README.md" \ -f %gem_packages ++++++ globalid-0.3.6.gem -> globalid-0.3.7.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MIT-LICENSE new/MIT-LICENSE --- old/MIT-LICENSE 2015-08-04 23:30:09.000000000 +0200 +++ new/MIT-LICENSE 2016-07-26 22:35:46.000000000 +0200 @@ -1,4 +1,4 @@ -Copyright (c) 2014 David Heinemeier Hansson +Copyright (c) 2014-2016 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/README.md 2016-07-26 22:35:46.000000000 +0200 @@ -0,0 +1,130 @@ +# Global ID - Reference models by URI + +A Global ID is an app wide URI that uniquely identifies a model instance: + + gid://YourApp/Some::Model/id + +This is helpful when you need a single identifier to reference different +classes of objects. + +One example is job scheduling. We need to reference a model object rather than +serialize the object itself. We can pass a Global ID that can be used to locate +the model when it's time to perform the job. The job scheduler doesn't need to know +the details of model naming and IDs, just that it has a global identifier that +references a model. + +Another example is a drop-down list of options, consisting of both Users and Groups. +Normally we'd need to come up with our own ad hoc scheme to reference them. With Global +IDs, we have a universal identifier that works for objects of both classes. + + +## Usage + +Mix `GlobalID::Identification` into any model with a `#find(id)` class method. +Support is automatically included in Active Record. + +```ruby +>> person_gid = Person.find(1).to_global_id +=> #<GlobalID ... + +>> person_gid.uri +=> #<URI ... + +>> person_gid.to_s +=> "gid://app/Person/1" + +>> GlobalID::Locator.locate person_gid +=> #<Person:0x007fae94bf6298 @id="1"> +``` + +### Signed Global IDs + +For added security GlobalIDs can also be signed to ensure that the data hasn't been tampered with. + +```ruby +>> person_sgid = Person.find(1).to_signed_global_id +=> #<SignedGlobalID:0x007fea1944b410 + +>> person_sgid = Person.find(1).to_sgid +=> #<SignedGlobalID:0x007fea1944b410 + +>> person_sgid.to_s +=> "BAhJIh5naWQ6Ly9pZGluYWlkaS9Vc2VyLzM5NTk5BjoGRVQ=--81d7358dd5ee2ca33189bb404592df5e8d11420e" + +>> GlobalID::Locator.locate_signed person_sgid +=> #<Person:0x007fae94bf6298 @id="1"> + +``` +You can even bump the security up some more by explaining what purpose a Signed Global ID is for. +In this way evildoers can't reuse a sign-up form's SGID on the login page. For example. + +```ruby +>> signup_person_sgid = Person.find(1).to_sgid(for: 'signup_form') +=> #<SignedGlobalID:0x007fea1984b520 + +>> GlobalID::Locator.locate_signed(signup_person_sgid.to_s, for: 'signup_form') +=> #<Person:0x007fae94bf6298 @id="1"> +``` + +You can also have SGIDs that expire some time in the future. This is useful if there's a resource, +people shouldn't have indefinite access to, like a share link. + +```ruby +>> expiring_sgid = Document.find(5).to_sgid(expires_in: 2.hours, for: 'sharing') +=> #<SignedGlobalID:0x008fde45df8937 + +# Within 2 hours... +>> GlobalID::Locator.locate_signed(expiring_sgid.to_s, for: 'sharing') +=> #<Document:0x007fae94bf6298 @id="5"> + +# More than 2 hours later... +>> GlobalID::Locator.locate_signed(expiring_sgid.to_s, for: 'sharing') +=> nil + +>> explicit_expiring_sgid = SecretAgentMessage.find(5).to_sgid(expires_at: Time.now.advance(hours: 1)) +=> #<SignedGlobalID:0x008fde45df8937 + +# 1 hour later... +>> GlobalID::Locator.locate_signed explicit_expiring_sgid.to_s +=> nil +``` + +### 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. +A custom app locator is useful when different apps collaborate and reference each others' Global IDs. +When finding a Global ID's model, the locator to use is based on the app name provided in the Global ID url. + +A custom locator can either be a block or a class. + +Using a block: + +```ruby +GlobalID::Locator.use :foo do |gid| + FooRemote.const_get(gid.model_name).find(gid.model_id) +end +``` + +Using a class: + +```ruby +GlobalID::Locator.use :bar, BarLocator.new +class BarLocator + def locate(gid) + @search_client.search name: gid.model_name, id: gid.model_id + end +end +``` + +After defining locators as above, URIs like "gid://foo/Person/1" and "gid://bar/Person/1" will now use the foo block locator and `BarLocator` respectively. +Other apps will still keep using the default locator. + +## Contributing to GlobalID + +GlobalID is work of many contributors. You're encouraged to submit pull requests, propose +features and discuss issues. + +See [CONTRIBUTING](CONTRIBUTING.md). + +## License +GlobalID is released under the [MIT License](http://www.opensource.org/licenses/MIT). Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/global_id/locator.rb new/lib/global_id/locator.rb --- old/lib/global_id/locator.rb 2015-08-04 23:30:09.000000000 +0200 +++ new/lib/global_id/locator.rb 2016-07-26 22:35:46.000000000 +0200 @@ -106,9 +106,7 @@ private def locator_for(gid) - @locators.fetch(normalize_app(gid.app)) do - gid.model_class.respond_to?(:unscoped) ? UNSCOPED_LOCATOR : DEFAULT_LOCATOR - end + @locators.fetch(normalize_app(gid.app)) { DEFAULT_LOCATOR } end def find_allowed?(model_class, only = nil) @@ -127,7 +125,7 @@ private @locators = {} - class DefaultLocator + class BaseLocator def locate(gid) gid.model_class.find gid.model_id end @@ -151,19 +149,26 @@ end end end - DEFAULT_LOCATOR = DefaultLocator.new - class UnscopedLocator < DefaultLocator + class UnscopedLocator < BaseLocator def locate(gid) - gid.model_class.unscoped { super } + unscoped(gid.model_class) { super } end private def find_records(model_class, ids, options) - model_class.unscoped { super } + unscoped(model_class) { super } + end + + def unscoped(model_class) + if model_class.respond_to?(:unscoped) + model_class.unscoped { yield } + else + yield + end end end - UNSCOPED_LOCATOR = UnscopedLocator.new + DEFAULT_LOCATOR = UnscopedLocator.new class BlockLocator def initialize(block) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/global_id/signed_global_id.rb new/lib/global_id/signed_global_id.rb --- old/lib/global_id/signed_global_id.rb 2015-08-04 23:30:09.000000000 +0200 +++ new/lib/global_id/signed_global_id.rb 2016-07-26 22:35:46.000000000 +0200 @@ -9,11 +9,7 @@ attr_accessor :verifier def parse(sgid, options = {}) - if sgid.is_a? self - sgid - else - super verify(sgid, options), options - end + super verify(sgid.to_s, options), options end # Grab the verifier from options and fall back to SignedGlobalID.verifier. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-08-04 23:30:09.000000000 +0200 +++ new/metadata 2016-07-26 22:35:46.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: globalid version: !ruby/object:Gem::Version - version: 0.3.6 + version: 0.3.7 platform: ruby authors: - David Heinemeier Hansson autorequire: bindir: bin cert_chain: [] -date: 2015-08-04 00:00:00.000000000 Z +date: 2016-07-26 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: activesupport @@ -45,6 +45,7 @@ extra_rdoc_files: [] files: - MIT-LICENSE +- README.md - lib/global_id.rb - lib/global_id/global_id.rb - lib/global_id/identification.rb @@ -73,9 +74,8 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.7 +rubygems_version: 2.4.5.1 signing_key: specification_version: 4 summary: 'Refer to any model with a URI: gid://app/class/id' test_files: [] -has_rdoc: