Skip to content

Commit

Permalink
update hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
amine2233 committed Mar 31, 2019
1 parent 2b5f204 commit def8cc8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'cocoapods', '~> 1.6.0.beta.1'
gem 'cocoapods', '~> 1.7.0.beta.3'
gem 'xcodeproj', '~> 1.8.0'
gem 'xcpretty'
gem 'slather'
52 changes: 27 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,75 @@ GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.0)
activesupport (4.2.10)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
atomos (0.1.3)
claide (1.0.2)
clamp (0.6.5)
cocoapods (1.6.0.beta.1)
clamp (1.3.0)
cocoapods (1.7.0.beta.3)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.6.0.beta.1)
cocoapods-deintegrate (>= 1.0.2, < 2.0)
cocoapods-downloader (>= 1.2.1, < 2.0)
cocoapods-core (= 1.7.0.beta.3)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.3.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
fourflusher (>= 2.2.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.2)
xcodeproj (>= 1.6.0, < 2.0)
cocoapods-core (1.6.0.beta.1)
ruby-macho (~> 1.4)
xcodeproj (>= 1.8.2, < 2.0)
cocoapods-core (1.7.0.beta.3)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.1)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.3.1)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.5)
escape (0.0.4)
fourflusher (2.0.1)
fourflusher (2.2.0)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
rouge (2.0.7)
ruby-macho (1.3.1)
slather (2.4.0)
ruby-macho (1.4.0)
slather (2.4.7)
CFPropertyList (>= 2.2, < 4)
activesupport (>= 4.0.2, < 5)
clamp (~> 0.6)
nokogiri (~> 1.6)
xcodeproj (>= 0.20, < 2.0.0)
clamp (~> 1.3)
nokogiri (~> 1.8)
xcodeproj (~> 1.7)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcodeproj (1.6.0)
xcodeproj (1.8.2)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -82,8 +83,9 @@ PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.6.0.beta.1)
cocoapods (~> 1.7.0.beta.3)
slather
xcodeproj (~> 1.8.0)
xcpretty

BUNDLED WITH
Expand Down
35 changes: 18 additions & 17 deletions Sources/StateMachine/StateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import Dispatch
/// State
open class State: Hashable {

/// hash Value
public var hashValue: Int {
return self.name.hashValue
}

/// Name of state
public let name: String

Expand All @@ -28,6 +23,11 @@ open class State: Hashable {
public init(_ name: String) {
self.name = name
}

/// hash Value
public func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}

/// State Equatable
Expand All @@ -49,11 +49,6 @@ extension State: Equatable {
/// The Transition class
open class Transition: Hashable {

/// hash Value
public var hashValue: Int {
return self.name.hashValue
}

/// Name of Transition
public let name: String
/// The begin state
Expand All @@ -74,6 +69,11 @@ open class Transition: Hashable {
self.from = from
self.to = to
}

/// hash Value
public func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}

/// Transition Equatable
Expand Down Expand Up @@ -107,19 +107,20 @@ public enum LifecycleEvent {

/// LifecycleEvent Hashable
extension LifecycleEvent: Hashable {

public var hashValue: Int {

/// hash Value
public func hash(into hasher: inout Hasher) {
switch self {
case .beforeTransition(let value):
return "bt\(value.hashValue)".hashValue
hasher.combine("bt\(value.hashValue)")
case .leaveState(let value):
return "ls\(value.hashValue)".hashValue
hasher.combine("ls\(value.hashValue)")
case .onState(let value):
return "os\(value.hashValue)".hashValue
hasher.combine("os\(value.hashValue)")
case .onTransition(let value):
return "ot\(value.hashValue)".hashValue
hasher.combine("ot\(value.hashValue)")
case .afterTransition(let value):
return "at\(value.hashValue)".hashValue
hasher.combine("at\(value.hashValue)")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion StateMachine.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "StateMachine"
s.version = "0.1.0"
s.version = "0.1.1"
s.summary = "Sort description of 'StateMachine' framework"
s.homepage = "https://github.com/amine2233/StateMachine"
s.license = { type: 'MIT', file: 'LICENSE' }
Expand Down

0 comments on commit def8cc8

Please sign in to comment.