Skip to content

Commit

Permalink
Merge pull request #99 from getyoti/release-1.6.4
Browse files Browse the repository at this point in the history
Release 1.6.4
  • Loading branch information
davidgrayston authored Jun 1, 2020
2 parents 306dd0a + 5c65a0e commit 2082bef
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 70 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ jobs:
include:
- &test
stage: Test
rvm: 2.4
rvm: 2.7
before_install:
- gem install bundler
install:
- bundle install
script:
- bundle exec rake
- <<: *test
rvm: 2.6
- <<: *test
rvm: 2.5
- <<: *test
rvm: 2.6
rvm: 2.4
install:
- BUNDLE_FORCE_RUBY_PLATFORM=1 bundle install
- &coverage
stage: coverage
name: Coveralls
rvm: 2.4
rvm: 2.7
before_install:
- gem install bundler
install:
Expand Down
29 changes: 0 additions & 29 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,6 @@ bundle exec guard

Although this gem supports Ruby 2.0.0, in order to use the latest development dependencies you have to use at least Ruby 2.2.2.

If you wish to compile `.proto` definitions to Ruby, you will need to install [Google's Protocol Buffers](http://code.google.com/p/protobuf).

### OSX

```shell
brew install protobuf
```

### Ubuntu

```shell
sudo apt-get install -y protobuf
```

This gem relies heavily on the [Ruby Protobuf][] gem. For more information on how Google Protobuf works, please see the [Wiki pages][].

Compiling the common and attribute `.proto` definitions can be done with the following commands:

```shell
cd lib/yoti/protobuf/v1
protoc -I definitions/attribute-public-api/attrpubapi_v1 --ruby_out ./attribute_public_api definitions/attribute-public-api/attrpubapi_v1/*.proto
protoc -I definitions/common-public-api/compubapi_v1/ --ruby_out ./common_public_api definitions/common-public-api/compubapi_v1/*.proto
```

These commands will overwrite the current protobuf Ruby modules, which have been modified. If the protobuf files have to be updated, a good idea would be to change them manually, or generate the files in a new location, and compare the content.

[Ruby Protobuf]: https://github.com/ruby-protobuf/protobuf/
[Wiki Pages]: https://github.com/ruby-protobuf/protobuf/wiki

## Requirements

### Code coverage
Expand Down
11 changes: 8 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ require 'yaml'
# Tests #
################################

RSpec::Core::RakeTask.new
task test: :spec
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = ['spec/yoti']
end

RSpec::Core::RakeTask.new(:test_generators) do |t|
t.pattern = ['spec/generators']
end

################################
# Coveralls #
Expand Down Expand Up @@ -46,4 +51,4 @@ end
# Defaults #
################################

task default: %i[spec rubocop]
task default: %i[spec test_generators rubocop]
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# frozen_string_literal: true

require 'time'

module Yoti
module DynamicSharingService
class ThirdPartyAttributeDefinition
#
# @param [String] name
#
def initialize(name)
@name = name
end

def as_json(*_args)
{ name: @name }
end

def to_json(*_args)
{ name: @name }.to_json
as_json.to_json
end
end

Expand All @@ -18,51 +27,93 @@ def initialize
@definitions = []
end

#
# @param [DateTime,Time] expiry_date
#
# @return [self]
#
def with_expiry_date(expiry_date)
@expiry_date = expiry_date
self
end

#
# @param [String] *names
#
# @return [self]
#
def with_definitions(*names)
@definitions += names.map do |name|
ThirdPartyAttributeDefinition.new(name)
end
self
end

#
# @return [ThirdPartyAttributeExtension]
#
def build
extension = ThirdPartyAttributeExtension.new
extension.instance_variable_get(:@content)[:expiry_date] = @expiry_date
extension.instance_variable_get(:@content)[:definitions] = @definitions
extension
content = ThirdPartyAttributeExtensionContent.new(@expiry_date, @definitions)
ThirdPartyAttributeExtension.new(content)
end
end

class ThirdPartyAttributeExtension
EXTENSION_TYPE = 'THIRD_PARTY_ATTRIBUTE'

# @return [ThirdPartyAttributeExtensionContent]
attr_reader :content

# @return [String]
attr_reader :type

def initialize
@content = {}
#
# @param [ThirdPartyAttributeExtensionContent] content
#
def initialize(content = nil)
@content = content
@type = EXTENSION_TYPE
end

def as_json(*_args)
{
type: @type,
content: @content
}
json = {}
json[:type] = @type
json[:content] = @content.as_json unless @content.nil?
json
end

def to_json(*_args)
as_json.to_json
end

#
# @return [ThirdPartyAttributeExtensionBuilder]
#
def self.builder
ThirdPartyAttributeExtensionBuilder.new
end
end

class ThirdPartyAttributeExtensionContent
#
# @param [DateTime,Time] expiry_date
# @param [Array<ThirdPartyAttributeDefinition>] definitions
#
def initialize(expiry_date, definitions)
@expiry_date = expiry_date
@definitions = definitions
end

def as_json(*_args)
json = {}
json[:expiry_date] = @expiry_date.to_time.utc.strftime('%FT%T.%3NZ') unless @expiry_date.nil?
json[:definitions] = @definitions.map(&:as_json)
json
end

def to_json(*_args)
as_json.to_json
end
end
end
end
26 changes: 13 additions & 13 deletions lib/yoti/dynamic_share_service/policy/dynamic_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ def with_wanted_attribute_by_name(name, constraints: nil)
end

def with_family_name(options = {})
with_wanted_attribute_by_name Attribute::FAMILY_NAME, options
with_wanted_attribute_by_name Attribute::FAMILY_NAME, **options
end

def with_given_names(options = {})
with_wanted_attribute_by_name Attribute::GIVEN_NAMES, options
with_wanted_attribute_by_name Attribute::GIVEN_NAMES, **options
end

def with_full_name(options = {})
with_wanted_attribute_by_name Attribute::FULL_NAME, options
with_wanted_attribute_by_name Attribute::FULL_NAME, **options
end

def with_date_of_birth(options = {})
with_wanted_attribute_by_name Attribute::DATE_OF_BIRTH, options
with_wanted_attribute_by_name Attribute::DATE_OF_BIRTH, **options
end

#
Expand All @@ -138,42 +138,42 @@ def with_age_derived_attribute(derivation, constraints: nil)
# @param [Integer] derivation
#
def with_age_over(age, options = {})
with_age_derived_attribute(Attribute::AGE_OVER + age.to_s, options)
with_age_derived_attribute(Attribute::AGE_OVER + age.to_s, **options)
end

#
# @param [Integer] derivation
#
def with_age_under(age, options = {})
with_age_derived_attribute(Attribute::AGE_UNDER + age.to_s, options)
with_age_derived_attribute(Attribute::AGE_UNDER + age.to_s, **options)
end

def with_gender(options = {})
with_wanted_attribute_by_name Attribute::GENDER, options
with_wanted_attribute_by_name Attribute::GENDER, **options
end

def with_postal_address(options = {})
with_wanted_attribute_by_name(Attribute::POSTAL_ADDRESS, options)
with_wanted_attribute_by_name(Attribute::POSTAL_ADDRESS, **options)
end

def with_structured_postal_address(options = {})
with_wanted_attribute_by_name(Attribute::STRUCTURED_POSTAL_ADDRESS, options)
with_wanted_attribute_by_name(Attribute::STRUCTURED_POSTAL_ADDRESS, **options)
end

def with_nationality(options = {})
with_wanted_attribute_by_name(Attribute::NATIONALITY, options)
with_wanted_attribute_by_name(Attribute::NATIONALITY, **options)
end

def with_phone_number(options = {})
with_wanted_attribute_by_name(Attribute::PHONE_NUMBER, options)
with_wanted_attribute_by_name(Attribute::PHONE_NUMBER, **options)
end

def with_selfie(options = {})
with_wanted_attribute_by_name(Attribute::SELFIE, options)
with_wanted_attribute_by_name(Attribute::SELFIE, **options)
end

def with_email(options = {})
with_wanted_attribute_by_name(Attribute::EMAIL_ADDRESS, options)
with_wanted_attribute_by_name(Attribute::EMAIL_ADDRESS, **options)
end

def with_document_details
Expand Down
2 changes: 2 additions & 0 deletions lib/yoti/dynamic_share_service/share_url.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'securerandom'

module Yoti
module DynamicSharingService
class Share
Expand Down
2 changes: 2 additions & 0 deletions lib/yoti/http/request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'securerandom'

module Yoti
# Manage the API's HTTPS requests
class Request
Expand Down
2 changes: 1 addition & 1 deletion lib/yoti/protobuf/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def convert_multi_value(value)
proto_multi_value = Yoti::Protobuf::Attrpubapi::MultiValue.decode(value)
items = []
proto_multi_value.values.each do |item|
items.append value_based_on_content_type(item.data, item.content_type)
items << value_based_on_content_type(item.data, item.content_type)
end
MultiValue.new(items)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/yoti/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Yoti
# @return [String] the gem's current version
VERSION = '1.6.3'.freeze
VERSION = '1.6.4'.freeze
end
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey = yoti-web-sdk:ruby
sonar.projectName = ruby-sdk
sonar.projectVersion = 1.6.3
sonar.projectVersion = 1.6.4
sonar.language=ruby
sonar.exclusions = **/protobuf/**.rb, coverage/**, spec/sample-data/**
sonar.links.scm = https://github.com/getyoti/yoti-ruby-sdk
Expand Down
1 change: 0 additions & 1 deletion spec/generators/yoti/install/install_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'spec_helper'
require 'generator_spec'
require 'generators/yoti/install/install_generator.rb'

Expand Down
Loading

0 comments on commit 2082bef

Please sign in to comment.