Skip to content

Commit

Permalink
mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk committed Aug 2, 2024
1 parent daf3fe3 commit ccd4d28
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require:
- rubocop-minitest
- rubocop-rake

AllCops:
NewCops: enable
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ group :development do
gem 'rake'
gem 'rubocop'
gem 'rubocop-minitest'
gem 'rubocop-rake'
end
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
simple_monads (0.1.1)
simple_monads (0.1.2)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -44,6 +44,8 @@ GEM
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
strscan (3.1.0)
unicode-display_width (2.5.0)
Expand All @@ -59,6 +61,7 @@ DEPENDENCIES
rake
rubocop
rubocop-minitest
rubocop-rake
simple_monads!

BUNDLED WITH
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/**/*_test.rb']
end

desc 'build and push gem versions'
task :build_and_push do
puts "build simple_monads #{SimpleMonads::VERSION}"
system 'gem build simple_monads.gemspec'
Expand Down
11 changes: 11 additions & 0 deletions lib/simple_monads.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# frozen_string_literal: true

require_relative 'simple_monads/failure_object'
require_relative 'simple_monads/success_object'

# Main module
module SimpleMonads
def Success(object) # rubocop:disable Naming/MethodName
SuccessObject.new(object)
end

def Failure(object) # rubocop:disable Naming/MethodName
FailureObject.new(object)
end
end
24 changes: 24 additions & 0 deletions lib/simple_monads/failure_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module SimpleMonads
# failure object
class FailureObject
attr_reader :object

def initialize(object)
@object = object
end

def failure?
true
end

def success?
false
end

def inspect
"Failure(#{object})"
end
end
end
24 changes: 24 additions & 0 deletions lib/simple_monads/success_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module SimpleMonads
# success object
class SuccessObject
attr_reader :object

def initialize(object)
@object = object
end

def failure?
false
end

def success?
true
end

def inspect
"Success(#{object})"
end
end
end
2 changes: 1 addition & 1 deletion lib/simple_monads/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SimpleMonads
VERSION = '0.1.1'
VERSION = '0.1.2'
end

0 comments on commit ccd4d28

Please sign in to comment.