Skip to content

Commit 9f40603

Browse files
committed
Bootstrap the project.
0 parents  commit 9f40603

14 files changed

+359
-0
lines changed

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.rubocop.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
inherit_gem:
2+
rubocop-rails_config:
3+
- config/rails.yml
4+
5+
Rails:
6+
Enabled: true
7+
8+
Style/StringLiterals:
9+
Enabled: true
10+
EnforcedStyle: single_quotes
11+
12+
Style/FrozenStringLiteralComment:
13+
Enabled: false
14+
15+
Metrics/LineLength:
16+
Max: 80
17+
18+
Layout/IndentationConsistency:
19+
EnforcedStyle: normal
20+
21+
Style/BlockDelimiters:
22+
Enabled: true

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sudo: false
3+
language: ruby
4+
cache: bundler
5+
rvm:
6+
- 2.5.1
7+
before_install: gem install bundler

.yardstick.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
path: ['lib/**/*.rb']
3+
threshold: 100
4+
rules:
5+
ApiTag::Presence:
6+
enabled: false
7+
ApiTag::Inclusion:
8+
enabled: false
9+
ApiTag::ProtectedMethod:
10+
enabled: false
11+
ApiTag::PrivateMethod:
12+
enabled: false
13+
ExampleTag:
14+
enabled: false
15+
ReturnTag:
16+
enabled: true
17+
exclude: []
18+
Summary::Presence:
19+
enabled: true
20+
exclude: []
21+
Summary::Length:
22+
enabled: true
23+
exclude: []
24+
Summary::Delimiter:
25+
enabled: true
26+
exclude: []
27+
Summary::SingleLine:
28+
enabled: true
29+
exclude: []

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in jsonapi.gemspec
4+
gemspec

Gemfile.lock

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
PATH
2+
remote: .
3+
specs:
4+
jsonapi.rb (0.0.1)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
actionpack (5.2.2)
10+
actionview (= 5.2.2)
11+
activesupport (= 5.2.2)
12+
rack (~> 2.0)
13+
rack-test (>= 0.6.3)
14+
rails-dom-testing (~> 2.0)
15+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
16+
actionview (5.2.2)
17+
activesupport (= 5.2.2)
18+
builder (~> 3.1)
19+
erubi (~> 1.4)
20+
rails-dom-testing (~> 2.0)
21+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
22+
activesupport (5.2.2)
23+
concurrent-ruby (~> 1.0, >= 1.0.2)
24+
i18n (>= 0.7, < 2)
25+
minitest (~> 5.1)
26+
tzinfo (~> 1.1)
27+
ast (2.4.0)
28+
builder (3.2.3)
29+
concurrent-ruby (1.1.4)
30+
crass (1.0.4)
31+
diff-lcs (1.3)
32+
erubi (1.8.0)
33+
i18n (1.5.1)
34+
concurrent-ruby (~> 1.0)
35+
jaro_winkler (1.5.2)
36+
loofah (2.2.3)
37+
crass (~> 1.0.2)
38+
nokogiri (>= 1.5.9)
39+
method_source (0.9.2)
40+
mini_portile2 (2.4.0)
41+
minitest (5.11.3)
42+
nokogiri (1.10.0)
43+
mini_portile2 (~> 2.4.0)
44+
parallel (1.12.1)
45+
parser (2.5.3.0)
46+
ast (~> 2.4.0)
47+
powerpack (0.1.2)
48+
rack (2.0.6)
49+
rack-test (1.1.0)
50+
rack (>= 1.0, < 3)
51+
rails-dom-testing (2.0.3)
52+
activesupport (>= 4.2.0)
53+
nokogiri (>= 1.6)
54+
rails-html-sanitizer (1.0.4)
55+
loofah (~> 2.2, >= 2.2.2)
56+
railties (5.2.2)
57+
actionpack (= 5.2.2)
58+
activesupport (= 5.2.2)
59+
method_source
60+
rake (>= 0.8.7)
61+
thor (>= 0.19.0, < 2.0)
62+
rainbow (3.0.0)
63+
rake (12.3.2)
64+
rspec (3.8.0)
65+
rspec-core (~> 3.8.0)
66+
rspec-expectations (~> 3.8.0)
67+
rspec-mocks (~> 3.8.0)
68+
rspec-core (3.8.0)
69+
rspec-support (~> 3.8.0)
70+
rspec-expectations (3.8.2)
71+
diff-lcs (>= 1.2.0, < 2.0)
72+
rspec-support (~> 3.8.0)
73+
rspec-mocks (3.8.0)
74+
diff-lcs (>= 1.2.0, < 2.0)
75+
rspec-support (~> 3.8.0)
76+
rspec-support (3.8.0)
77+
rubocop (0.62.0)
78+
jaro_winkler (~> 1.5.1)
79+
parallel (~> 1.10)
80+
parser (>= 2.5, != 2.5.1.1)
81+
powerpack (~> 0.1)
82+
rainbow (>= 2.2.2, < 4.0)
83+
ruby-progressbar (~> 1.7)
84+
unicode-display_width (~> 1.4.0)
85+
rubocop-rails_config (0.4.0)
86+
railties (>= 3.0)
87+
rubocop (~> 0.58)
88+
ruby-progressbar (1.10.0)
89+
thor (0.20.3)
90+
thread_safe (0.3.6)
91+
tzinfo (1.2.5)
92+
thread_safe (~> 0.1)
93+
unicode-display_width (1.4.1)
94+
yard (0.9.16)
95+
yardstick (0.9.9)
96+
yard (~> 0.8, >= 0.8.7.2)
97+
98+
PLATFORMS
99+
ruby
100+
101+
DEPENDENCIES
102+
bundler
103+
jsonapi.rb!
104+
rspec (~> 3.0)
105+
rubocop-rails_config
106+
yardstick
107+
108+
BUNDLED WITH
109+
1.16.3

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Stas Suscov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# JSONAPI.rb :electric_plug:
2+
3+
So you say you need [JSON:API](https://jsonapi.org/) support in your API...
4+
5+
> - hey how did your hackathon go?
6+
> - not too bad, we got Babel set up
7+
> - yep…
8+
> - yep.
9+
>
10+
>[I Am Devloper](https://twitter.com/iamdevloper/status/787969734918668289)
11+
12+
Here are some _codes_ to help you build your next JSON:API compliable application
13+
easier and faster.
14+
15+
## But why?
16+
17+
It's quite a hassle to setup a Ruby web application to use and follow the
18+
JSON:API specifications.
19+
20+
The idea is simple, JSONAPI.rb offers a bunch of modules/mixins/glue,
21+
add them to your controllers, call some methods, _profit_!
22+
23+
Main goals:
24+
* No _magic_ please
25+
* No DSLs please
26+
* Less code, less maintenance
27+
* Good docs and test coverage
28+
* Keep it up-to-date (or at least tell people this is for _grabs_)
29+
30+
## But how?
31+
32+
Mainly by leveraging [Fast JSON API](https://github.com/Netflix/fast_jsonapi)
33+
and [Ransack](https://github.com/activerecord-hackery/ransack).
34+
35+
Thanks to everyone who worked on these amazing projects!
36+
37+
## Installation
38+
39+
Add this line to your application's Gemfile:
40+
41+
```ruby
42+
gem 'jsonapi.rb'
43+
```
44+
45+
And then execute:
46+
47+
$ bundle
48+
49+
Or install it yourself as:
50+
51+
$ gem install jsonapi.rb
52+
53+
## Usage
54+
55+
TODO: Write usage instructions here
56+
57+
## Development
58+
59+
After checking out the repo, run `bundle` to install dependencies.
60+
61+
Then, run `rake spec` to run the tests.
62+
63+
To install this gem onto your local machine, run `bundle exec rake install`.
64+
65+
To release a new version, update the version number in `version.rb`, and then
66+
run `bundle exec rake release`, which will create a git tag for the version,
67+
push git commits and tags, and push the `.gem` file to
68+
[rubygems.org](https://rubygems.org).
69+
70+
## Contributing
71+
72+
Bug reports and pull requests are welcome on GitHub at
73+
https://github.com/stas/jsonapi.rb
74+
75+
This project is intended to be a safe, welcoming space for collaboration, and
76+
contributors are expected to adhere to the
77+
[Contributor Covenant](http://contributor-covenant.org) code of conduct.
78+
79+
## License
80+
81+
The gem is available as open source under the terms of the
82+
[MIT License](https://opensource.org/licenses/MIT).

Rakefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'bundler/gem_tasks'
2+
require 'rspec/core/rake_task'
3+
require 'rubocop/rake_task'
4+
require 'yaml'
5+
require 'yardstick'
6+
7+
desc('Documentation stats and measurements')
8+
task('qa:docs') do
9+
yaml = YAML.load_file(File.expand_path('../.yardstick.yml', __FILE__))
10+
config = Yardstick::Config.coerce(yaml)
11+
measure = Yardstick.measure(config)
12+
measure.puts
13+
coverage = Yardstick.round_percentage(measure.coverage * 100)
14+
exit(1) if coverage < config.threshold
15+
end
16+
17+
desc('Codestyle check and linter')
18+
RuboCop::RakeTask.new('qa:code') do |task|
19+
task.fail_on_error = true
20+
task.patterns = [
21+
'lib/**/*.rb',
22+
'spec/**/*.rb'
23+
]
24+
end
25+
26+
desc('Run CI QA tasks')
27+
task(qa: ['qa:docs', 'qa:code'])
28+
29+
RSpec::Core::RakeTask.new(spec: :qa)
30+
task(default: :spec)

jsonapi.rb.gemspec

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
lib = File.expand_path("../lib", __FILE__)
2+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3+
4+
require 'jsonapi/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = 'jsonapi.rb'
8+
spec.version = JSONAPI::VERSION
9+
spec.authors = ['Stas Suscov']
10+
spec.email = ['[email protected]']
11+
12+
spec.summary = %q{So you say you need JSON:API support in your API...}
13+
spec.description = %q{This + FastJSONAPI = ♥}
14+
spec.homepage = 'https://github.com/stas/jsonapi.rb'
15+
spec.license = 'MIT'
16+
17+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
19+
end
20+
spec.require_paths = ['lib']
21+
22+
spec.add_development_dependency 'bundler'
23+
spec.add_development_dependency 'rspec', '~> 3.0'
24+
spec.add_development_dependency 'yardstick'
25+
spec.add_development_dependency 'rubocop-rails_config'
26+
end

lib/jsonapi.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'jsonapi/version'
2+
3+
module JSONAPI
4+
# Your code goes here...
5+
end

lib/jsonapi/version.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module JSONAPI
2+
VERSION = '0.0.1'
3+
end

spec/jsonapi_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe JSONAPI do
4+
xit 'does something useful' do
5+
expect(false).to eq(true)
6+
end
7+
end

spec/spec_helper.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'bundler/setup'
2+
require 'jsonapi'
3+
4+
RSpec.configure do |config|
5+
# Disable RSpec exposing methods globally on `Module` and `main`
6+
config.disable_monkey_patching!
7+
8+
config.expect_with :rspec do |c|
9+
c.syntax = :expect
10+
end
11+
end

0 commit comments

Comments
 (0)