marlin 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c61439809c2833828005c4a06f2555a37d11b32b7f1ff774c0d84c8ded38ddd1
4
+ data.tar.gz: 23250078aebabfd03124f67e1c94f777383234d6af1a57820588013ce11bb6e5
5
+ SHA512:
6
+ metadata.gz: 72a48e4edfbb831036e6ee02df39bbe21c9ebb874ba323bb1c904a4fb32b346cdc8df546d5e44029863ddc184df55c3c88123ec01f7352e0c710ddd63da2604f
7
+ data.tar.gz: b55de0b89fa19e1c737e11e08eed974e54cd8795894a8b3421d8bf1ceccd8f30a20285d5f09273d4eee954d326f8ff2af1805fc5d58de5a51bcee59d410cff07
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ marlin (0.0.1)
5
+ foreman (~> 0.85.0)
6
+ sinatra (~> 2.0.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ foreman (0.85.0)
12
+ thor (~> 0.19.1)
13
+ mustermann (1.0.3)
14
+ rack (2.0.6)
15
+ rack-protection (2.0.5)
16
+ rack
17
+ sinatra (2.0.5)
18
+ mustermann (~> 1.0)
19
+ rack (~> 2.0)
20
+ rack-protection (= 2.0.5)
21
+ tilt (~> 2.0)
22
+ thor (0.19.4)
23
+ tilt (2.0.9)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ marlin!
30
+
31
+ BUNDLED WITH
32
+ 1.17.2
data/Procfile ADDED
@@ -0,0 +1 @@
1
+ web: bundle exec rackup config.ru -p 3000
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # falcon
2
+ Highly available key-value storage
data/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require File.expand_path("lib/marlin/app", File.dirname(__FILE__))
2
+
3
+ run Marlin::App
@@ -0,0 +1,16 @@
1
+ module Marlin
2
+ module Actions
3
+ class Base
4
+ def initialize(key, persister = Marlin::Persisters::Memory.new)
5
+ @key = key
6
+ @persister = persister
7
+ end
8
+
9
+ protected
10
+
11
+ def call
12
+ raise NotImplementedError
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ module Marlin
2
+ module Actions
3
+ class DeleteKey < Base
4
+ def call
5
+ @persister.delete(@key)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Marlin
2
+ module Actions
3
+ class ReadKey < Base
4
+ def call
5
+ @persister.read(@key)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Marlin
2
+ module Actions
3
+ class ReplicateKey < Base
4
+ def call
5
+ # TODO
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Marlin
2
+ module Actions
3
+ class SaveKey < Base
4
+ def call(value)
5
+ @persister.write(@key, value)
6
+ end
7
+ end
8
+ end
9
+ end
data/lib/marlin/app.rb ADDED
@@ -0,0 +1,31 @@
1
+ require "sinatra/base"
2
+
3
+ module Marlin
4
+ class App < Sinatra::Base
5
+ set :root, File.dirname(__FILE__)
6
+
7
+ KEYS_ROUTE = "/keys/:key"
8
+
9
+ get "/" do
10
+ "Marlin Gem Homepage"
11
+ end
12
+
13
+ get "/ping" do
14
+ "OK"
15
+ end
16
+
17
+ put KEYS_ROUTE do
18
+ Marlin::Actions::SaveKey.new(params[:key]).call(params[:value])
19
+ end
20
+
21
+ get KEYS_ROUTE do
22
+ Marlin::Actions::ReadKey.new(params[:key]).call
23
+ end
24
+
25
+ delete KEYS_ROUTE do
26
+ Marlin::Actions::DeleteKey.new(params[:key]).call
27
+ end
28
+
29
+ require File.join(root, "/config/initializers/autoloader.rb")
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ AUTOLOAD_DIRS = %w(
2
+ actions/*.rb
3
+ persisters/*.rb
4
+ )
5
+
6
+ AUTOLOAD_DIRS.each do |autoload_dir|
7
+ Dir[File.join(Marlin::App.root, autoload_dir)].each do |file|
8
+ next if file.include?("initializers/autoloader")
9
+ require file
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Marlin
2
+ module Persisters
3
+ class Base
4
+ protected
5
+
6
+ def read(key)
7
+ raise NotImplementedError
8
+ end
9
+
10
+ def write(key, value)
11
+ raise NotImplementedError
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module Marlin
2
+ module Persisters
3
+ class Memory < Base
4
+ @@storage = {}
5
+
6
+ def read(key)
7
+ @@storage[key]
8
+ end
9
+
10
+ def write(key, value)
11
+ @@storage[key] = value
12
+ end
13
+
14
+ def delete(key)
15
+ @@storage.delete(key)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Marlin
2
+ module Persisters
3
+ class Redis < Base
4
+ def read(key)
5
+ raise NotImplementedError
6
+ end
7
+
8
+ def write(key, value)
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def delete(key)
13
+ raise NotImplementedError
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Marlin
2
+ VERSION = "0.0.1".freeze
3
+ end
data/lib/marlin.rb ADDED
@@ -0,0 +1,2 @@
1
+ module Marlin
2
+ end
data/marlin.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "marlin/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'marlin'
9
+ s.version = Marlin::VERSION
10
+ s.authors = ['Ilya Kovalenko']
11
+ s.email = ['to@ilyakovalenko.com']
12
+ s.homepage = 'https://github.com/ilyacoding/marlin'
13
+ s.summary = 'Marlin'
14
+ s.description = 'Marlin'
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ s.add_dependency 'sinatra', '~> 2.0.5'
20
+ s.add_dependency 'foreman', '~> 0.85.0'
21
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marlin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ilya Kovalenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: foreman
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.85.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.85.0
41
+ description: Marlin
42
+ email:
43
+ - to@ilyakovalenko.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - Procfile
52
+ - README.md
53
+ - config.ru
54
+ - lib/marlin.rb
55
+ - lib/marlin/actions/base.rb
56
+ - lib/marlin/actions/delete_key.rb
57
+ - lib/marlin/actions/read_key.rb
58
+ - lib/marlin/actions/replicate_key.rb
59
+ - lib/marlin/actions/save_key.rb
60
+ - lib/marlin/app.rb
61
+ - lib/marlin/config/initializers/autoloader.rb
62
+ - lib/marlin/persisters/base.rb
63
+ - lib/marlin/persisters/memory.rb
64
+ - lib/marlin/persisters/redis.rb
65
+ - lib/marlin/version.rb
66
+ - marlin.gemspec
67
+ homepage: https://github.com/ilyacoding/marlin
68
+ licenses: []
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.0.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Marlin
89
+ test_files: []