Commit 8d30cdb

mo <mo.khan@gmail.com>
2019-01-06 01:45:12
extract schemas and messages modules
1 parent 8e4cac8
lib/scim/kit/v2/templates/resource_type.json.jbuilder
@@ -4,7 +4,7 @@ json.key_format! camelize: :lower
 json.meta do
   render meta, json: json
 end
-json.schemas [Scim::Kit::V2::Schema::RESOURCE_TYPE]
+json.schemas [Scim::Kit::V2::Schemas::RESOURCE_TYPE]
 json.id id
 json.name name
 json.description description
lib/scim/kit/v2/templates/service_provider_configuration.json.jbuilder
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 json.key_format! camelize: :lower
-json.schemas [Scim::Kit::V2::Schema::SERVICE_PROVIDER_CONFIGURATION]
+json.schemas [Scim::Kit::V2::Schemas::SERVICE_PROVIDER_CONFIGURATION]
 json.documentation_uri documentation_uri
 json.patch do
   render patch, json: json
lib/scim/kit/v2/messages.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Scim
+  module Kit
+    module V2
+      module Messages
+        CORE = 'urn:ietf:params:scim:api:messages:2.0'
+        LIST_RESPONSE = "#{CORE}:ListResponse"
+        SEARCH_REQUEST = "#{CORE}:SearchRequest"
+        ERROR = "#{CORE}:Error"
+      end
+    end
+  end
+end
lib/scim/kit/v2/schema.rb
@@ -7,13 +7,6 @@ module Scim
       class Schema
         include Templatable
 
-        CORE = 'urn:ietf:params:scim:schemas:core:2.0'
-        ERROR = 'urn:ietf:params:scim:api:messages:2.0:Error'
-        GROUP = "#{CORE}:Group"
-        RESOURCE_TYPE = "#{CORE}:ResourceType"
-        SERVICE_PROVIDER_CONFIGURATION = "#{CORE}:ServiceProviderConfig"
-        USER = "#{CORE}:User"
-
         attr_reader :id, :name, :location, :attributes
         attr_accessor :description
 
lib/scim/kit/v2/schemas.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Scim
+  module Kit
+    module V2
+      module Schemas
+        CORE = 'urn:ietf:params:scim:schemas:core:2.0'
+        GROUP = "#{CORE}:Group"
+        RESOURCE_TYPE = "#{CORE}:ResourceType"
+        SERVICE_PROVIDER_CONFIGURATION = "#{CORE}:ServiceProviderConfig"
+        USER = "#{CORE}:User"
+      end
+    end
+  end
+end
lib/scim/kit.rb
@@ -10,11 +10,13 @@ require 'scim/kit/version'
 
 require 'scim/kit/v2/attribute_type'
 require 'scim/kit/v2/authentication_scheme'
+require 'scim/kit/v2/messages'
 require 'scim/kit/v2/meta'
 require 'scim/kit/v2/mutability'
 require 'scim/kit/v2/resource_type'
 require 'scim/kit/v2/returned'
 require 'scim/kit/v2/schema'
+require 'scim/kit/v2/schemas'
 require 'scim/kit/v2/service_provider_configuration'
 require 'scim/kit/v2/supportable'
 require 'scim/kit/v2/uniqueness'
spec/scim/kit/v2/resource_type_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Scim::Kit::V2::ResourceType do
       x.description = 'Group'
       x.endpoint = 'https://www.example.org/scim/v2/groups'
       x.name = 'Group'
-      x.schema = Scim::Kit::V2::Schema::GROUP
+      x.schema = Scim::Kit::V2::Schemas::GROUP
     end
   end
 
@@ -15,7 +15,7 @@ RSpec.describe Scim::Kit::V2::ResourceType do
 
   specify { expect(subject.to_h[:meta][:location]).to eql(location) }
   specify { expect(subject.to_h[:meta][:resourceType]).to eql('ResourceType') }
-  specify { expect(subject.to_h[:schemas]).to match_array([Scim::Kit::V2::Schema::RESOURCE_TYPE]) }
+  specify { expect(subject.to_h[:schemas]).to match_array([Scim::Kit::V2::Schemas::RESOURCE_TYPE]) }
   specify { expect(subject.to_h[:id]).to eql('Group') }
   specify { expect(subject.to_h[:description]).to eql(subject.description) }
   specify { expect(subject.to_h[:endpoint]).to eql(subject.endpoint) }
README.md
@@ -25,9 +25,9 @@ Or install it yourself as:
 ```ruby
 def user_schema
   Scim::Kit::V2::Schema.build(
-    id: Scim::Kit::V2::Schema::USER,
+    id: Scim::Kit::V2::Schemas::USER,
     name: "User",
-    location: scim_v2_schema_url(id: Scim::Kit::V2::Schema::USER)
+    location: scim_v2_schema_url(id: Scim::Kit::V2::Schemas::USER)
   ) do |schema|
     schema.description = "User Account"
     schema.add_attribute(name: 'userName') do |x|