Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
janlindblom committed May 1, 2021
2 parents 5da7cc6 + 639c176 commit a7b0609
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 68 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language = "ruby"
run = "bundle exec rake"
18 changes: 17 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
require: rubocop-rake

AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5
NewCops: enable

Style/StringLiterals:
Enabled: true
Expand All @@ -9,5 +12,18 @@ Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes

Layout/EndOfLine:
Enabled: false

Naming/AccessorMethodName:
Enabled: false

Lint/ScriptPermission:
Enabled: false

Layout/LineLength:
Max: 120

Lint/SuppressedException:
Exclude:
- Rakefile
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][Keep a Changelog] and this project adheres to [Semantic Versioning][Semantic Versioning].

## [Unreleased]

---

## [Released]

---

<!-- Links -->
[Keep a Changelog]: https://keepachangelog.com/
[Semantic Versioning]: https://semver.org/

<!-- Versions -->
[Unreleased]: https://github.com/janlindblom/ruby-replitdb/compare/v1.0.0...HEAD
[Released]: https://github.com/janlindblom/ruby-replitdb/releases
[0.0.2]: https://github.com/janlindblom/ruby-replitdb/compare/v0.0.1..v0.0.2
[0.0.1]: https://github.com/janlindblom/ruby-replitdb/releases/v0.0.1
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ source "https://rubygems.org"

# Specify your gem's dependencies in ruby-replitdb.gemspec
gemspec

gem "rake", "~> 13.0"

gem "rubocop", "~> 1.7"
70 changes: 70 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
PATH
remote: .
specs:
replitdb (0.0.1)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
coderay (1.1.3)
diff-lcs (1.4.4)
method_source (1.0.0)
parallel (1.20.1)
parser (3.0.1.0)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rainbow (3.0.0)
rake (13.0.3)
regexp_parser (2.1.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rubocop (1.13.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
rubocop-rake (0.5.1)
rubocop
rubocop-rspec (2.3.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
ruby-progressbar (1.11.0)
unicode-display_width (2.0.0)
yard (0.9.26)

PLATFORMS
x64-mingw32

DEPENDENCIES
pry (~> 0.14)
rake (~> 13.0)
replitdb!
rspec (~> 3.10)
rubocop (~> 1.7)
rubocop-rake (~> 0.5)
rubocop-rspec (~> 2.3)
yard (~> 0.9)

BUNDLED WITH
2.2.5
54 changes: 45 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ReplitDb
# Replit Database client

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby/replitdb`. To experiment with that code, run `bin/console` for an interactive prompt.
Replit Database client is a simple way to use Replit Database in your Ruby repls.

TODO: Delete this and the text above, and describe your gem
Based on the [Node.js Replit Database client](https://github.com/replit/database-node).

## Installation

Expand All @@ -12,17 +12,53 @@ Add this line to your application's Gemfile:
gem 'replitdb'
```

And then execute:
## Usage

Require it in your code:

$ bundle install
```ruby
require 'replit'
client = Replit::Database::Client.new
client.set "key", "value"
key = client.get "key"
puts key
```

Or install it yourself as:
### Library documentation

$ gem install replitdb
#### Constructor

## Usage
```ruby
Replit::Database::Client.new(custom_url)
```

Constructor takes a custom database URL as an optional argument.

#### Functions

```ruby
get(key, {raw: false})
```

Gets the value of a key from the database, specifying passing the optional `raw: true` option returns the raw value stored, otherwise it will be deserialized as JSON into a Ruby object.

```ruby
set(key, value)
```

Sets the value of a key in the database.

```ruby
delete(key)
```

Deletes `key` from database.

```ruby
list(prefix="")
```

TODO: Write usage instructions here
List all of the keys, or if prefix is defined all of the keys starting with `prefix`.

## Development

Expand Down
19 changes: 16 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rubocop/rake_task"

RuboCop::RakeTask.new
begin
require "rubocop/rake_task"
require "yard"
require "rspec/core/rake_task"

task default: :rubocop
RSpec::Core::RakeTask.new(:spec)

RuboCop::RakeTask.new

YARD::Rake::YardocTask.new do |t|
t.files = ["lib/**/*.rb", "spec/**/*.rb"]
t.stats_options = ["--list-undoc"]
end

task default: :rubocop
rescue LoadError
end
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "ruby/replitdb"
require "replit/database"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
12 changes: 12 additions & 0 deletions lib/replit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require_relative "replit/database"

#
# The Replit module.
#
# @author Jan Lindblom <[email protected]>
# @version 0.1.0
#
module Replit
end
23 changes: 23 additions & 0 deletions lib/replit/database.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require_relative "database/client"

module Replit
#
# Replit Database module.
#
# @author Jan Lindblom <[email protected]>
# @version 0.1.0
#
module Database
#
# Thrown if there is a syntax error.
#
class SyntaxError < StandardError; end

#
# Thrown if there is a configuration error.
#
class ConfigurationError < StandardError; end
end
end
Loading

0 comments on commit a7b0609

Please sign in to comment.