Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Move to dry-rb and remove Virtus #98

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: move to dry
  • Loading branch information
forest committed Jan 18, 2017
commit 77283ab3c2bed257337503d1f31cb3d29f68f417
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.yardoc
.idea
.vscode
.rubocop.yml
bin
.DS_Store
Gemfile.lock
Expand Down
4 changes: 2 additions & 2 deletions lib/tracker_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
else
require 'core_ext/object/blank'
end
require 'equalizer'

require 'multi_json'
require 'representable/json'
Expand Down Expand Up @@ -59,7 +58,8 @@ module Endpoints
module Resources
module Shared
autoload :Base, 'tracker_api/resources/shared/base'
autoload :Collection, 'tracker_api/resources/shared/collection'
autoload :Types, 'tracker_api/resources/shared/types'
autoload :BaseDry, 'tracker_api/resources/shared/base_dry'
end
autoload :Activity, 'tracker_api/resources/activity'
autoload :Account, 'tracker_api/resources/account'
Expand Down
32 changes: 16 additions & 16 deletions lib/tracker_api/resources/me.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
require_relative './shared/types'

module TrackerApi
module Resources
class Me
include Shared::Base

attribute :name, String
attribute :initials, String
attribute :username, String
attribute :time_zone, TimeZone
attribute :api_token, String
attribute :has_google_identity, Boolean
attribute :project_ids, [Integer]
attribute :projects, [MembershipSummary]
attribute :workspace_ids, [Integer]
attribute :workspaces, [Workspace]
attribute :email, String
attribute :receives_in_app_notifications, Boolean
attribute :kind, String
class Me < Shared::BaseDry
attribute :name, Shared::Types::Coercible::String
attribute :initials, Shared::Types::Coercible::String
attribute :username, Shared::Types::Coercible::String
# attribute :time_zone, Shared::Types::Coercible::TimeZone
attribute :api_token, Shared::Types::Coercible::String
attribute :has_google_identity, Shared::Types::Strict::Bool
attribute :project_ids, Shared::Types::Strict::Array.member(Shared::Types::Coercible::Int)
attribute :projects, Shared::Types::Strict::Array.member(MembershipSummary)
attribute :workspace_ids, Shared::Types::Strict::Array.member(Shared::Types::Coercible::Int)
attribute :workspaces, Shared::Types::Strict::Array.member(Workspace)
attribute :email, Shared::Types::Coercible::String
attribute :receives_in_app_notifications, Shared::Types::Strict::Bool
attribute :kind, Shared::Types::Coercible::String
end
end
end
17 changes: 17 additions & 0 deletions lib/tracker_api/resources/shared/base_dry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'dry-struct'
require_relative 'types'

module TrackerApi

module Resources
module Shared
class BaseDry < Dry::Struct
constructor_type :schema

include Dry::Equalizer(:id)

attribute :id, Types::Coercible::Int
end
end
end
end
13 changes: 13 additions & 0 deletions lib/tracker_api/resources/shared/types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'dry-types'

module TrackerApi
module Resources
module Shared
module Types
include Dry::Types.module

# Statuses = Types::Strict::String.enum('draft', 'published', 'archived')
end
end
end
end
4 changes: 3 additions & 1 deletion tracker_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Gem::Specification.new do |spec|

spec.add_dependency 'addressable'
spec.add_dependency 'virtus'
spec.add_dependency 'dry-struct'
spec.add_dependency 'dry-equalizer'
spec.add_dependency 'faraday', '~> 0.9.0'
spec.add_dependency 'faraday_middleware'
spec.add_dependency 'excon'
spec.add_dependency 'equalizer'
# spec.add_dependency 'equalizer'
spec.add_dependency 'representable'
spec.add_dependency 'multi_json'
end