gris 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 384f461e4fb5637d285e821164485bd0208e190e
4
- data.tar.gz: 9378c46ca28ee796eb63f5d99efa00278d597f3a
3
+ metadata.gz: 4ef5f60c714ffb37c1cee757a9f948a7be8cc565
4
+ data.tar.gz: aa30d373204592b972d76be94ecd3d5bb6026c96
5
5
  SHA512:
6
- metadata.gz: 9c03f1888efe805675bc8d75a919e28ef246db23ad3d68896e81fcb6dcb5b766eeb24aa1e4d4a91da9a5322ccca1a4ff595b287ee8a4b1503f6098752f83e41b
7
- data.tar.gz: 615f3ed39a0067a40db7e447083ecc917f111e2cbd404d1b8b42de51a4c494f096671ec0e9e221c77bf7d8b1bca7d66ca75eeda7dafab1722a0c2337817a8c69
6
+ metadata.gz: ed7f285cd67b0465818cd73d56777c824ffa8715d9461f337e17ce7df8d5d6c52207874e1aa740c6b3692ce5ad6cf0a6d0d4af692383d5697ca90c7d99d1918e
7
+ data.tar.gz: b5637b878507394ec58524598ca861be1fb92d991ab30ffb482a4f25c18a0b4037cd6be329fa9a274a92343c686b12beb913b3b9f920dd4690701539f463222e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gris (0.1.3)
4
+ gris (0.1.4)
5
5
  activesupport (~> 4.2, >= 4.2.0)
6
6
  dotenv (~> 1.0.2, >= 1.0.2)
7
7
  git (~> 1.2, >= 1.2.8)
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Gris is a framework for building Rack-based hypermedia APIs using Grape, Roar and ActiveRecord.
4
4
 
5
+ [![Build Status](https://semaphoreci.com/api/v1/projects/37371083-45b6-4c6f-a887-b631ca0fbe5c/381675/badge.png)](https://semaphoreci.com/dylanfareed/gris)
6
+
5
7
  It is derived from/inspired by the stellar and more sophisticated [Napa framework by Bellycard Inc.](https://github.com/bellycard/napa).
6
8
 
7
9
  Gris aims to provide generators and middleware common to API microservices. For the moment, however, it is in development and primarily exploratory. Note that the ground may shift.
data/Rakefile CHANGED
@@ -1,11 +1,14 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'rake/testtask'
4
3
  require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
5
6
 
6
- Rake::TestTask.new(:spec) do |test|
7
- test.libs << 'lib' << 'spec'
8
- test.pattern = 'spec/**/*_spec.rb'
7
+ RSpec::Core::RakeTask.new
8
+
9
+ desc 'Run RuboCop'
10
+ RuboCop::RakeTask.new(:rubocop) do |task|
11
+ task.fail_on_error = true
9
12
  end
10
13
 
11
- task default: :spec
14
+ task default: [:rubocop, :spec]
data/gris.gemspec CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.0'
23
23
  s.add_runtime_dependency 'rake', '~> 10.4', '>= 10.4.2'
24
24
  s.add_runtime_dependency 'git', '~> 1.2', '>= 1.2.8'
25
+ s.add_runtime_dependency 'dotenv', '~> 1.0.2', '>= 1.0.2'
25
26
 
26
27
  s.add_dependency 'logging'
27
- s.add_dependency 'dotenv', '~> 1.0.2', '>= 1.0.2'
28
28
  s.add_dependency 'grape', '~> 0.11.0', '>= 0.11.0'
29
29
  s.add_dependency 'grape-roar', '~> 0.3.0', '>= 0.3.0'
30
30
 
@@ -9,4 +9,4 @@ DATABASE_PASSWORD=''
9
9
  DATABASE_HOST=localhost
10
10
  DATABASE_NAME=<%= app_name.underscore %>_test
11
11
  BASE_URL=http://127.0.0.1:9393
12
- PERMITTED_TOKENS=["replace-me"]
12
+ PERMITTED_TOKENS=replace-me
@@ -8,4 +8,4 @@ DATABASE_PASSWORD=''
8
8
  DATABASE_HOST=localhost
9
9
  DATABASE_NAME=<%= app_name.underscore %>_development
10
10
  BASE_URL=http://127.0.0.1:9292
11
- PERMITTED_TOKENS=["replace-me"]
11
+ PERMITTED_TOKENS=replace-me
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'gris/setup'
3
- require 'dotenv'
4
3
  Gris.load_environment
5
4
 
6
5
  require File.expand_path('../config/application.rb', __FILE__)
@@ -4,7 +4,7 @@ end
4
4
 
5
5
  shared_context 'with token authorization' do
6
6
  before(:each) do
7
- permitted_token = ENV['PERMITTED_TOKENS'].dup.gsub!(/[\[\]]/, '').split(/\s*,\s*/).first if ENV['PERMITTED_TOKENS']
7
+ permitted_token = ENV['PERMITTED_TOKENS'].split(',').first if ENV['PERMITTED_TOKENS']
8
8
  header 'Http-Authorization', permitted_token
9
9
  end
10
10
  end
@@ -15,7 +15,7 @@ module Gris
15
15
  end
16
16
 
17
17
  def permitted_tokens
18
- ENV['PERMITTED_TOKENS']
18
+ ENV['PERMITTED_TOKENS'].split(',')
19
19
  end
20
20
  end
21
21
  end
data/lib/gris/setup.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'active_support'
2
+ require 'dotenv'
2
3
 
3
4
  module Gris
4
5
  class << self
5
6
  def load_environment
6
- Dotenv.load(Gris.env.test? ? '.env.test' : '.env')
7
+ Dotenv.load
7
8
  end
8
9
 
9
10
  def env
data/lib/gris/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Gris
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
 
4
4
  class Version
5
5
  class << self
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Gris::AuthenticationHelpers do
4
4
  context 'without permitted token' do
5
5
  before(:each) do
6
- stub_const 'ENV', 'PERMITTED_TOKENS' => %w(my-token another-token)
6
+ stub_const 'ENV', 'PERMITTED_TOKENS' => 'my-token,another-token'
7
7
  @helper = SpecApiAuthHelper.new
8
8
  end
9
9
 
@@ -23,6 +23,14 @@ describe Gris::AuthenticationHelpers do
23
23
  expect(@helper.token_authentication!).to be_nil
24
24
  end
25
25
  end
26
+ context 'with blank params token' do
27
+ it 'returns a 401 Forbidden error' do
28
+ allow(@helper).to receive(:params).and_return(token: '')
29
+ allow(@helper).to receive_message_chain(:request, :headers).and_return('Http-Authorization' => nil)
30
+ @helper.token_authentication!
31
+ expect(@helper.message).to eq(message: 'Forbidden', status: 401)
32
+ end
33
+ end
26
34
  context 'with included request header token' do
27
35
  it 'returns nil' do
28
36
  allow(@helper).to receive(:params).and_return(token: nil)
@@ -30,6 +38,14 @@ describe Gris::AuthenticationHelpers do
30
38
  expect(@helper.token_authentication!).to be_nil
31
39
  end
32
40
  end
41
+ context 'with blank header token' do
42
+ it 'returns a 401 Forbidden error' do
43
+ allow(@helper).to receive(:params).and_return(token: nil)
44
+ allow(@helper).to receive_message_chain(:request, :headers).and_return('Http-Authorization' => '')
45
+ @helper.token_authentication!
46
+ expect(@helper.message).to eq(message: 'Forbidden', status: 401)
47
+ end
48
+ end
33
49
  end
34
50
  end
35
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Fareed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -91,39 +91,39 @@ dependencies:
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.2.8
93
93
  - !ruby/object:Gem::Dependency
94
- name: logging
94
+ name: dotenv
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: 1.0.2
97
100
  - - ">="
98
101
  - !ruby/object:Gem::Version
99
- version: '0'
102
+ version: 1.0.2
100
103
  type: :runtime
101
104
  prerelease: false
102
105
  version_requirements: !ruby/object:Gem::Requirement
103
106
  requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.2
104
110
  - - ">="
105
111
  - !ruby/object:Gem::Version
106
- version: '0'
112
+ version: 1.0.2
107
113
  - !ruby/object:Gem::Dependency
108
- name: dotenv
114
+ name: logging
109
115
  requirement: !ruby/object:Gem::Requirement
110
116
  requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: 1.0.2
114
117
  - - ">="
115
118
  - !ruby/object:Gem::Version
116
- version: 1.0.2
119
+ version: '0'
117
120
  type: :runtime
118
121
  prerelease: false
119
122
  version_requirements: !ruby/object:Gem::Requirement
120
123
  requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 1.0.2
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
- version: 1.0.2
126
+ version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: grape
129
129
  requirement: !ruby/object:Gem::Requirement
@@ -303,7 +303,6 @@ files:
303
303
  - ".rubocop_todo.yml"
304
304
  - ".ruby-gemset"
305
305
  - ".ruby-version"
306
- - ".travis.yml"
307
306
  - Gemfile
308
307
  - Gemfile.lock
309
308
  - Guardfile
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.1.5
5
-
6
- before_install: gem install bundler
7
-
8
- bundler_args: --no-deployment
9
-
10
- script:
11
- - "bundle exec rspec"
12
- - "bundle exec rubocop"