gris 0.2.4 → 0.3.0

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: 7903911cba8da7b598dd6b4917a79a47b636b7b5
4
- data.tar.gz: 8d7cb5ded5b95afd3a0862688c5a002feeb32d40
3
+ metadata.gz: d9a3d232cdfdbe4192901e7b09af1be47d757fa6
4
+ data.tar.gz: 9cba6a4558f7c4af0948c9282a81e1e98aa9e621
5
5
  SHA512:
6
- metadata.gz: 3c04c1f98d3e9c1467507e182d317c89a7456a27f2f542d8a0f297ccd30d45bfa5090e5dfa3cfa14796a4693dc526cedc284c21982ec39d12bc6ca39797a9c67
7
- data.tar.gz: ef360e0a06a2b4ece6de403e17640e3fd641a676221512597d67418e1233db6d3608d1b848d28d5a197e76dcfa75fe50b611f8a5145df1fd6af60cd5a13dd2fe
6
+ metadata.gz: 174a24dab870ccb72d89d50bbb12542d5816a173cf408127999c52b0f2853bf364908df77df78bc5ce48b220ef5d03b9c63ad17e5d7ed5f21a19b907ff2f973a
7
+ data.tar.gz: 99c07b949ff431a604bf688da3bc83386d65c4490d08634d3bcba8446d2000f3aaae19f1aedf446305242cc219990213e1ad0868d09f7d240e247b220f95424c
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gris (0.2.4)
4
+ gris (0.3.0)
5
5
  activesupport (~> 4.2, >= 4.2.0)
6
6
  chronic (~> 0.10.0)
7
7
  dalli (~> 2.7)
8
- dotenv (~> 2.0, >= 2.0)
9
8
  git (~> 1.2, >= 1.2.8)
10
9
  grape (~> 0.11.0, >= 0.11.0)
11
10
  grape-roar (~> 0.3.0, >= 0.3.0)
@@ -58,7 +57,6 @@ GEM
58
57
  descendants_tracker (0.0.4)
59
58
  thread_safe (~> 0.3, >= 0.3.1)
60
59
  diff-lcs (1.2.5)
61
- dotenv (2.0.1)
62
60
  equalizer (0.0.11)
63
61
  faraday (0.9.1)
64
62
  multipart-post (>= 1.2, < 3)
@@ -94,7 +92,7 @@ GEM
94
92
  grape-swagger (0.10.1)
95
93
  grape (>= 0.8.0)
96
94
  grape-entity
97
- hashie (3.4.1)
95
+ hashie (3.4.2)
98
96
  hashie-forbidden_attributes (0.1.1)
99
97
  hashie (>= 3.0)
100
98
  hyperclient (0.7.0)
@@ -107,20 +105,20 @@ GEM
107
105
  uri_template (~> 0.5)
108
106
  i18n (0.7.0)
109
107
  ice_nine (0.11.1)
110
- json (1.8.2)
108
+ json (1.8.3)
111
109
  little-plugger (1.1.3)
112
110
  logging (2.0.0)
113
111
  little-plugger (~> 1.1)
114
112
  multi_json (~> 1.10)
115
113
  mini_portile (0.6.2)
116
- minitest (5.6.1)
114
+ minitest (5.7.0)
117
115
  multi_json (1.11.0)
118
116
  multi_xml (0.5.5)
119
117
  multipart-post (2.0.0)
120
118
  net-http-digest_auth (1.4)
121
119
  nokogiri (1.6.6.2)
122
120
  mini_portile (~> 0.6.0)
123
- parser (2.2.2.3)
121
+ parser (2.2.2.5)
124
122
  ast (>= 1.1, < 3.0)
125
123
  powerpack (0.1.1)
126
124
  rack (1.6.1)
@@ -135,7 +133,7 @@ GEM
135
133
  rack-test (>= 0.5)
136
134
  rainbow (2.0.0)
137
135
  rake (10.4.2)
138
- representable (2.2.1)
136
+ representable (2.2.2)
139
137
  multi_json
140
138
  nokogiri
141
139
  uber (~> 0.0.7)
@@ -161,9 +159,9 @@ GEM
161
159
  rainbow (>= 1.99.1, < 3.0)
162
160
  ruby-progressbar (~> 1.4)
163
161
  ruby-progressbar (1.7.5)
164
- ruby_parser (3.6.6)
162
+ ruby_parser (3.7.0)
165
163
  sexp_processor (~> 4.1)
166
- sexp_processor (4.5.1)
164
+ sexp_processor (4.6.0)
167
165
  sqlite3 (1.3.10)
168
166
  thor (0.19.1)
169
167
  thread_safe (0.3.5)
@@ -22,7 +22,6 @@ 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', '~> 2.0', '>= 2.0'
26
25
  s.add_runtime_dependency 'logging', '~> 2.0'
27
26
  s.add_runtime_dependency 'grape', '~> 0.11.0', '>= 0.11.0'
28
27
  s.add_runtime_dependency 'grape-roar', '~> 0.3.0', '>= 0.3.0'
@@ -1,6 +1,5 @@
1
1
  # require external libraries
2
2
  require 'rake'
3
- require 'dotenv'
4
3
  require 'yaml'
5
4
  require 'grape'
6
5
  require 'json'
@@ -2,8 +2,6 @@ require 'thor'
2
2
  require 'gris/generators'
3
3
  require 'gris/version'
4
4
 
5
- Gris.load_environment if defined?(Dotenv)
6
-
7
5
  module Gris
8
6
  class CLI
9
7
  class Generate < Thor
@@ -3,7 +3,6 @@
3
3
  .rspec
4
4
  .env
5
5
  .env.*
6
- !.env.example
7
6
  !log/.keep
8
7
  log/*
9
8
  tmp/*
@@ -3,5 +3,3 @@ require 'bundler/setup'
3
3
  require 'gris/setup'
4
4
 
5
5
  Bundler.require(:default, Gris.env.to_sym)
6
-
7
- Gris.load_environment
@@ -1,20 +1,16 @@
1
- defaults: &defaults
2
- encoding: unicode
1
+ default: &default
3
2
  adapter: postgresql
4
- host: <%%= ENV['DATABASE_HOST'] %>
5
- username: <%%= ENV['DATABASE_USER'] %>
6
- password: <%%= ENV['DATABASE_PASSWORD'] %>
7
- database: <%%= ENV['DATABASE_NAME'] %>
8
- pool: <%= ENV["DB_POOL"] || ENV['MAX_THREADS'] || 5 %>
9
-
10
- production:
11
- <<: *defaults
3
+ encoding: unicode
4
+ host: localhost
5
+ username: <%%= ENV['DB_USER'] %>
6
+ password: <%%= ENV['DB_PASS'] %>
7
+ pool: 5
12
8
 
13
9
  development:
14
- <<: *defaults
10
+ <<: *default
11
+ database: <%= app_name %>_development
15
12
 
16
13
  test:
17
- <<: *defaults
14
+ <<: *default
15
+ database: <%= app_name %>_test
18
16
 
19
- staging:
20
- <<: *defaults
@@ -0,0 +1,15 @@
1
+ default: &:default
2
+ service_name: <%= app_name %>
3
+ permitted_tokens: replace-me
4
+ base_url: <%%= ENV['BASE_URL'] || 'http://localhost:9292' %>
5
+
6
+ development:
7
+ <<: *default
8
+
9
+ test:
10
+ <<: *default
11
+
12
+ production:
13
+ <<: *default
14
+ permitted_tokens: <%%= ENV['PERMITTED_TOKENS'] %>
15
+
@@ -3,11 +3,10 @@ shared_context 'with a running app' do
3
3
  end
4
4
 
5
5
  shared_context 'with token authorization' do
6
+ let(:permitted_token) { Gris.secrets.permitted_tokens }
6
7
  before(:each) do
7
- permitted_token = ENV['PERMITTED_TOKENS'].split(',').first if ENV['PERMITTED_TOKENS']
8
8
  header 'Http-Authorization', permitted_token
9
9
  end
10
- let(:permitted_token) { ENV['PERMITTED_TOKENS'].split(',').first }
11
10
  end
12
11
 
13
12
  shared_context 'with a running app and client' do
@@ -15,7 +15,7 @@ module Gris
15
15
  end
16
16
 
17
17
  def permitted_tokens
18
- ENV['PERMITTED_TOKENS'].split(',')
18
+ Gris.secrets.permitted_tokens.split(',')
19
19
  end
20
20
  end
21
21
  end
@@ -13,11 +13,11 @@ module Gris
13
13
  end
14
14
 
15
15
  def self.name
16
- ENV['SERVICE_NAME'] || 'api-service'
16
+ Gris.secrets.service_name
17
17
  end
18
18
 
19
19
  def self.base_url
20
- ENV['BASE_URL'] || 'http://localhost:9292'
20
+ Gris.secrets.base_url
21
21
  end
22
22
 
23
23
  def self.hostname
@@ -1,13 +1,7 @@
1
1
  require 'active_support'
2
- require 'dotenv'
3
2
 
4
3
  module Gris
5
4
  class << self
6
- def load_environment
7
- env_file = Gris.env.test? ? '.env.test' : '.env'
8
- Dotenv.overload env_file
9
- end
10
-
11
5
  def env
12
6
  @_env ||= ActiveSupport::StringInquirer.new(ENV['RACK_ENV'] || 'development')
13
7
  end
@@ -16,6 +10,22 @@ module Gris
16
10
  @_env = ActiveSupport::StringInquirer.new(environment)
17
11
  end
18
12
 
13
+ # adapted from https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb
14
+ # Returns secrets added to config/secrets.yml.
15
+ def secrets
16
+ @secrets ||= begin
17
+ secrets = ActiveSupport::OrderedOptions.new
18
+ yaml = 'config/secrets.yml'
19
+ if File.exist?(yaml)
20
+ require 'erb'
21
+ all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {}
22
+ env_secrets = all_secrets[Gris.env]
23
+ secrets.merge!(env_secrets.symbolize_keys) if env_secrets
24
+ end
25
+ secrets
26
+ end
27
+ end
28
+
19
29
  def db_connection_details
20
30
  YAML.load(ERB.new(File.read('./config/database.yml')).result)[Gris.env]
21
31
  end
@@ -1,5 +1,5 @@
1
1
  module Gris
2
- VERSION = '0.2.4'
2
+ VERSION = '0.3.0'
3
3
 
4
4
  class Version
5
5
  class << self
@@ -33,24 +33,12 @@ describe Gris::Generators::ScaffoldGenerator do
33
33
  expect(Dir).to exist(app_path)
34
34
  end
35
35
 
36
- it 'creates a .env.example file with with a development database name' do
37
- expect(File).to exist("#{app_path}/.env.example")
38
- env_file = File.read("#{app_path}/.env.example")
39
- expect(env_file).to match(/#{app_name}_development/)
40
- end
41
-
42
36
  it 'creates a Procfile file with puma ' do
43
37
  expect(File).to exist("#{app_path}/Procfile")
44
38
  env_file = File.read("#{app_path}/Procfile")
45
39
  expect(env_file).to match(/web: bundle exec puma/)
46
40
  end
47
41
 
48
- it 'creates a .env.example file with a development database name' do
49
- expect(File).to exist("#{app_path}/.env.example")
50
- env_test_file = File.read("#{app_path}/.env.example")
51
- expect(env_test_file).to match(/#{app_name}_development/)
52
- end
53
-
54
42
  it 'selects postgresql as the default database adapter' do
55
43
  database_config_file = File.read("#{app_path}/config/database.yml")
56
44
  expect(database_config_file).to match(/adapter: postgresql/)
@@ -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' => 'my-token,another-token'
6
+ Gris.secrets.permitted_tokens = 'my-token,another-token'
7
7
  @helper = SpecApiAuthHelper.new
8
8
  end
9
9
 
@@ -33,14 +33,8 @@ describe Gris::Identity do
33
33
  end
34
34
 
35
35
  context '#name' do
36
- it "returns 'api-service' if no ENV['SERVICE_NAME'] is set" do
37
- ENV['SERVICE_NAME'] = nil
38
- expect(Gris::Identity.name).to eq('api-service')
39
- end
40
-
41
- it "returns the ENV['SERVICE_NAME'] when specified" do
42
- ENV['SERVICE_NAME'] = nil
43
- ENV['SERVICE_NAME'] = 'my-service'
36
+ it 'returns the Gris.secrets.service_name when specified' do
37
+ Gris.secrets.service_name = 'my-service'
44
38
  expect(Gris::Identity.name).to eq('my-service')
45
39
  end
46
40
  end
@@ -72,14 +66,8 @@ describe Gris::Identity do
72
66
  end
73
67
 
74
68
  context '#base_url' do
75
- it 'returns http://localhost:9292 by default' do
76
- ENV['BASE_URL'] = nil
77
- expect(Gris::Identity.base_url).to eq('http://localhost:9292')
78
- end
79
-
80
- it "returns the env['BASE_URL'] when specied" do
81
- ENV['BASE_URL'] = nil
82
- ENV['BASE_URL'] = 'my-base-url'
69
+ it 'returns the Gris.secrets.base_url when specied' do
70
+ Gris.secrets.base_url = 'my-base-url'
83
71
  expect(Gris::Identity.base_url).to eq('my-base-url')
84
72
  end
85
73
  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.2.4
4
+ version: 0.3.0
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-05-27 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -90,26 +90,6 @@ dependencies:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.2.8
93
- - !ruby/object:Gem::Dependency
94
- name: dotenv
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '2.0'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '2.0'
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '2.0'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: '2.0'
113
93
  - !ruby/object:Gem::Dependency
114
94
  name: logging
115
95
  requirement: !ruby/object:Gem::Requirement
@@ -358,7 +338,6 @@ files:
358
338
  - lib/gris/generators/templates/api/spec/models/%name_underscore%_spec.rb.tt
359
339
  - lib/gris/generators/templates/create_table_migration/%migration_filename%.rb.tt
360
340
  - lib/gris/generators/templates/migration/%migration_filename%.rb.tt
361
- - lib/gris/generators/templates/scaffold/.env.example.tt
362
341
  - lib/gris/generators/templates/scaffold/.gitignore.tt
363
342
  - lib/gris/generators/templates/scaffold/.rspec.tt
364
343
  - lib/gris/generators/templates/scaffold/.rubocop.yml
@@ -376,6 +355,7 @@ files:
376
355
  - lib/gris/generators/templates/scaffold/config/database.yml.tt
377
356
  - lib/gris/generators/templates/scaffold/config/initializers/active_record.rb
378
357
  - lib/gris/generators/templates/scaffold/config/puma.rb
358
+ - lib/gris/generators/templates/scaffold/config/secrets.yml.tt
379
359
  - lib/gris/generators/templates/scaffold/db/schema.rb
380
360
  - lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
381
361
  - lib/gris/generators/templates/scaffold/spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- # Uncomment when using Gris::Middleware::Authentication
2
- # HEADER_PASSWORD=''
3
-
4
- SERVICE_NAME=<%= app_name %>
5
-
6
- DATABASE_USER='postgres'
7
- DATABASE_PASSWORD=''
8
- DATABASE_HOST=localhost
9
- DATABASE_NAME=<%= app_name.underscore %>_development
10
- BASE_URL=http://127.0.0.1:9393
11
- PERMITTED_TOKENS=replace-me