grape-app 0.3.0 → 0.3.1

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: 9786d097c5c829ddf0628b46d4205fbbb82dd3ac
4
- data.tar.gz: 8d9b2b6524336370ea0944cf836ab55f83a187d9
3
+ metadata.gz: 43dac369723077de72a8a3d319dbb658fc6d5813
4
+ data.tar.gz: 722586a98f7c44a8a80320e5a7a1d75b756e8c4b
5
5
  SHA512:
6
- metadata.gz: 4d4ff67a6ed976dd8d1e4e18e7de26f12e6da49873a7c339412adfe3456ed5a3f1ca3ae4f624e53d61a75479fe72c46a6e2d85f7883d4d2adc4b725cdb63d0d0
7
- data.tar.gz: 58c318856bbe67e1a96dea8e4a873e2a0aef478c9833cf76a7dd4336b804a2502e64ce864a87810616a3058485498e6e29d82dfea7392e00ca83d3d4753e3d0e
6
+ metadata.gz: c85da03fd8fef202a373c55a5c00b317c6c715fe50aac5d6984d5661d387816a0c3507cfdfb3c6ea2ba182970cfcd169a9961cb98f7f859a81323378f12f0414
7
+ data.tar.gz: 491d3599fc772929f358f5a36203da90ed2a211425e3f75222df071e7421009e1c97c8daabc51267c95bd596fd04ff1a3b5bd04bcc4d2e323d23f5c6838811c4
@@ -1,18 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-app (0.3.0)
4
+ grape-app (0.3.1)
5
5
  activesupport
6
6
  activesupport-json_encoder
7
7
  grape
8
8
  grape-entity
9
9
  hashie-forbidden_attributes
10
10
  rack-cors
11
+ thor
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- activesupport (4.2.1)
16
+ activesupport (4.2.2)
16
17
  i18n (~> 0.7)
17
18
  json (~> 1.7, >= 1.7.7)
18
19
  minitest (~> 5.1)
@@ -31,7 +32,7 @@ GEM
31
32
  thread_safe (~> 0.3, >= 0.3.1)
32
33
  diff-lcs (1.2.5)
33
34
  equalizer (0.0.11)
34
- grape (0.11.0)
35
+ grape (0.12.0)
35
36
  activesupport
36
37
  builder
37
38
  hashie (>= 2.1.0)
@@ -53,10 +54,10 @@ GEM
53
54
  minitest (5.7.0)
54
55
  multi_json (1.11.1)
55
56
  multi_xml (0.5.5)
56
- rack (1.6.1)
57
+ rack (1.6.2)
57
58
  rack-accept (0.4.5)
58
59
  rack (>= 0.4)
59
- rack-cors (0.3.1)
60
+ rack-cors (0.4.0)
60
61
  rack-mount (0.8.3)
61
62
  rack (>= 1.0.0)
62
63
  rake (10.4.2)
@@ -73,6 +74,7 @@ GEM
73
74
  diff-lcs (>= 1.2.0, < 2.0)
74
75
  rspec-support (~> 3.3.0)
75
76
  rspec-support (3.3.0)
77
+ thor (0.19.1)
76
78
  thread_safe (0.3.5)
77
79
  tzinfo (1.2.2)
78
80
  thread_safe (~> 0.1)
data/README.md CHANGED
@@ -2,9 +2,32 @@
2
2
 
3
3
  Grape::App is an attempt to 'railsify' the process of developing standalone grape apps.
4
4
 
5
- ## TODO
5
+ ## Usage
6
6
 
7
- * Write app generator
7
+ Install via gem:
8
+
9
+ ```shell
10
+ $ gem install grape-app
11
+ ```
12
+
13
+ Generate a new app:
14
+
15
+ ```shell
16
+ $ grape-app new my_app
17
+ create my_app/config/locales/en.yml
18
+ create my_app/config/environments/production.rb
19
+ ...
20
+ ```
21
+
22
+ Install bundle:
23
+
24
+ ```shell
25
+ $ cd my_app
26
+ $ bundle install
27
+ ..
28
+ Bundle complete! 10 Gemfile dependencies, 48 gems now installed.
29
+ Use `bundle show [gemname]` to see where a bundled gem is installed.
30
+ ```
8
31
 
9
32
  ## Licence
10
33
 
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if File.exist?(File.expand_path('../../.git', __FILE__))
4
+ $:.unshift(File.expand_path('../../lib', __FILE__))
5
+ end
6
+ require "grape/app/cli"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'grape-app'
5
- s.version = '0.3.0'
5
+ s.version = '0.3.1'
6
6
  s.authors = ['Black Square Media Ltd']
7
7
  s.email = ['info@blacksquaremedia.com']
8
8
  s.summary = %{Stanalone Grape API apps}
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'activesupport-json_encoder'
22
22
  s.add_dependency 'hashie-forbidden_attributes'
23
23
  s.add_dependency 'rack-cors'
24
+ s.add_dependency 'thor'
24
25
 
25
26
  s.add_development_dependency 'bundler'
26
27
  s.add_development_dependency 'rake'
@@ -0,0 +1,37 @@
1
+ require 'grape/app'
2
+ require 'thor'
3
+
4
+ module Grape::App::CLI
5
+
6
+ class Builder < Thor::Group
7
+ include Thor::Actions
8
+ argument :name, required: true
9
+
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), 'templates')
12
+ end
13
+
14
+ def copy_templates
15
+ prefix = File.join(self.class.source_root, "")
16
+
17
+ Dir[File.join(self.class.source_root, '**', '*')].each do |file|
18
+ next if File.directory?(file)
19
+
20
+ file.sub! prefix, ""
21
+ copy_file file, File.join(name, file)
22
+ end
23
+ end
24
+
25
+ def init_lib
26
+ empty_directory File.join(name, "lib", name)
27
+ end
28
+
29
+ end
30
+
31
+ class Runner < Thor
32
+ register Builder, :new, "new NAME", "create a new application"
33
+ end
34
+
35
+ end
36
+
37
+ Grape::App::CLI::Runner.start
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'grape-app'
4
+
5
+ group 'development' do
6
+ gem 'rake'
7
+ end
8
+
9
+ group 'development', 'test' do
10
+ gem 'rspec'
11
+ end
12
+
13
+ group 'test' do
14
+ gem 'airborne'
15
+ gem 'database_cleaner'
16
+ gem 'factory_girl'
17
+ gem 'faker'
18
+ gem 'rspec-collection_matchers'
19
+ gem 'rspec-its'
20
+ gem 'shoulda-matchers'
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler/setup'
2
+ require 'rspec/core/rake_task'
3
+
4
+ load 'grape/app/tasks.rake'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ module API
2
+ extend ActiveSupport::Autoload
3
+
4
+ # Autoload API components
5
+ autoload :V1
6
+ end
7
+
8
+
9
+ # Mount root API to app
10
+ Grape::App.mount API::V1
@@ -0,0 +1,15 @@
1
+ class API::V1 < API::Base
2
+ version 'v1'
3
+ prefix 'api'
4
+ format :json
5
+
6
+ # Custom rescues:
7
+ #
8
+ # rescue_from ActiveRecord::RecordNotFound do |e|
9
+ # error_response message: e.message, status: 404
10
+ # end
11
+
12
+ # Mount components
13
+ # mount API::Posts
14
+
15
+ end
@@ -0,0 +1,4 @@
1
+ # Add your model names below
2
+ Grape::App.autoload %w|
3
+
4
+ |
@@ -0,0 +1,4 @@
1
+ require File.expand_path('../config/environment', __FILE__)
2
+
3
+ run Grape::App.middleware
4
+
@@ -0,0 +1,4 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+
3
+ require 'grape/app'
4
+ Grape::App.init!
@@ -0,0 +1,3 @@
1
+ Grape::App.configure do |config|
2
+ config.raise_on_missing_translations = true
3
+ end
@@ -0,0 +1,12 @@
1
+ Grape::App.configure do |config|
2
+
3
+ # Force SSL
4
+ # config.force_ssl = true
5
+
6
+ # CORS is disabled by default, set to ['*'] to enable for all
7
+ # config.cors_allow_origins = nil
8
+
9
+ # Don't raise errors on missing translations
10
+ # config.raise_on_missing_translations = false
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ Grape::App.configure do |config|
2
+ config.raise_on_missing_translations = true
3
+ end
@@ -0,0 +1,2 @@
1
+ # en:
2
+ # custom: translation
@@ -0,0 +1 @@
1
+ # Add your seeds here
@@ -0,0 +1,26 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+
4
+ RSpec.configure do |config|
5
+
6
+ # DatabaseCleaner
7
+ config.before :suite do
8
+ DatabaseCleaner.strategy = :transaction
9
+ DatabaseCleaner.clean_with :truncation
10
+ end
11
+ config.around :each do |example|
12
+ DatabaseCleaner.cleaning { example.run }
13
+ end
14
+
15
+ # FactoryGirl
16
+ config.include FactoryGirl::Syntax::Methods
17
+ config.before :suite do
18
+ FactoryGirl.find_definitions
19
+ end
20
+
21
+ end
22
+
23
+ # Test with Airborne
24
+ Airborne.configure do |config|
25
+ config.rack_app = Grape::App
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -148,9 +162,11 @@ files:
148
162
  - Gemfile.lock
149
163
  - README.md
150
164
  - Rakefile
165
+ - bin/grape-app
151
166
  - grape-app.gemspec
152
167
  - lib/grape-app.rb
153
168
  - lib/grape/app.rb
169
+ - lib/grape/app/cli.rb
154
170
  - lib/grape/app/helpers.rb
155
171
  - lib/grape/app/helpers/params.rb
156
172
  - lib/grape/app/helpers/respond_with.rb
@@ -158,6 +174,20 @@ files:
158
174
  - lib/grape/app/initializers/pre.rb
159
175
  - lib/grape/app/tasks.rake
160
176
  - lib/grape/app/tasks/databases.rake
177
+ - lib/grape/app/templates/Gemfile
178
+ - lib/grape/app/templates/Rakefile
179
+ - lib/grape/app/templates/app/api.rb
180
+ - lib/grape/app/templates/app/api/v1.rb
181
+ - lib/grape/app/templates/app/models.rb
182
+ - lib/grape/app/templates/config.ru
183
+ - lib/grape/app/templates/config/environment.rb
184
+ - lib/grape/app/templates/config/environments/development.rb
185
+ - lib/grape/app/templates/config/environments/production.rb
186
+ - lib/grape/app/templates/config/environments/test.rb
187
+ - lib/grape/app/templates/config/initializers/.gitkeep
188
+ - lib/grape/app/templates/config/locales/en.yml
189
+ - lib/grape/app/templates/db/seeds.rb
190
+ - lib/grape/app/templates/spec/spec_helper.rb
161
191
  - lib/grape_app.rb
162
192
  - spec/grape/app_spec.rb
163
193
  - spec/scenario/Gemfile