Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
waymondo committed Jan 2, 2022
0 parents commit 8f57893
Show file tree
Hide file tree
Showing 21 changed files with 519 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Ruby

on:
push:
branches:
- master

pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
ruby:
- 3.0.3

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
AllCops:
TargetRubyVersion: 2.7

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes

Layout/LineLength:
Max: 120
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec

gem "debug", "~> 1.4"
gem "minitest", "~> 5.0"
gem "rake", "~> 13.0"
gem "rubocop", "~> 1.21"
86 changes: 86 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
PATH
remote: .
specs:
strapi (0.0.1)
activesupport (>= 5.0)
faraday (>= 1.0)
oj (>= 3.0)

GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
concurrent-ruby (1.1.9)
debug (1.4.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
io-console (0.5.11)
irb (1.4.1)
reline (>= 0.3.0)
minitest (5.15.0)
multipart-post (2.1.1)
oj (3.13.10)
parallel (1.21.0)
parser (3.0.3.2)
ast (~> 2.4.1)
rainbow (3.0.0)
rake (13.0.6)
regexp_parser (2.2.0)
reline (0.3.1)
io-console (~> 0.5)
rexml (3.2.5)
rubocop (1.24.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)

PLATFORMS
arm64-darwin-21

DEPENDENCIES
debug (~> 1.4)
minitest (~> 5.0)
rake (~> 13.0)
rubocop (~> 1.21)
strapi!

BUNDLED WITH
2.2.32
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022 justin talbott

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Strapi

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/strapi`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'strapi'
```

And then execute:

$ bundle install

Or install it yourself as:

$ gem install strapi

## Usage

TODO: Write usage instructions here

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/waymondo/strapi.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
16 changes: 16 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end

require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[test rubocop]
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "strapi"

# 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.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
11 changes: 11 additions & 0 deletions lib/strapi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "active_support"
require "faraday"
require "oj"

require_relative "strapi/connection"
require_relative "strapi/error"
require_relative "strapi/media"
require_relative "strapi/model"
require_relative "strapi/request"
require_relative "strapi/response"
require_relative "strapi/version"
10 changes: 10 additions & 0 deletions lib/strapi/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Strapi
class Connection
def self.instance
@instance ||= Faraday::Connection.new(
ENV["STRAPI_HOST_URL"],
headers: { "Authorization" => "bearer #{ENV["STRAPI_API_TOKEN"]}" }
)
end
end
end
13 changes: 13 additions & 0 deletions lib/strapi/error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Strapi
class Error < StandardError
attr_reader :status, :name, :message, :details

def initialize(hash = {})
super
@status = hash["status"]
@name = hash["name"]
@message = hash["message"]
@details = hash["details"]
end
end
end
11 changes: 11 additions & 0 deletions lib/strapi/media.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Strapi
class Media
# include Base

# def url
# return if (media_url = _attributes['url']).blank?

# media_url.starts_with?(/http/) ? media_url : [ENV['STRAPI_HOST_URL'], media_url].join('')
# end
end
end
Loading

0 comments on commit 8f57893

Please sign in to comment.