gris 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +1 -0
  5. data/.rubocop_todo.yml +67 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +203 -0
  10. data/Guardfile +82 -0
  11. data/MIT-LICENSE +20 -0
  12. data/README.md +7 -0
  13. data/Rakefile +11 -0
  14. data/bin/gris +5 -0
  15. data/gris.gemspec +40 -0
  16. data/lib/gris.rb +37 -0
  17. data/lib/gris/cli.rb +71 -0
  18. data/lib/gris/deprecations.rb +9 -0
  19. data/lib/gris/deprecations/gris_setup.rb +14 -0
  20. data/lib/gris/generators.rb +3 -0
  21. data/lib/gris/generators/api_generator.rb +31 -0
  22. data/lib/gris/generators/migration_generator.rb +228 -0
  23. data/lib/gris/generators/scaffold_generator.rb +21 -0
  24. data/lib/gris/generators/templates/api/app/apis/%name_tableize%_endpoint.rb.tt +65 -0
  25. data/lib/gris/generators/templates/api/app/models/%name_underscore%.rb.tt +2 -0
  26. data/lib/gris/generators/templates/api/app/presenters/%name_tableize%_presenter.rb.tt +5 -0
  27. data/lib/gris/generators/templates/api/app/presenters/%name_underscore%_presenter.rb.tt +10 -0
  28. data/lib/gris/generators/templates/api/spec/apis/%name_tableize%_endpoint_spec.rb.tt +70 -0
  29. data/lib/gris/generators/templates/api/spec/fabricators/%name_tableize%_fabricator.rb.tt +2 -0
  30. data/lib/gris/generators/templates/api/spec/models/%name_underscore%_spec.rb.tt +7 -0
  31. data/lib/gris/generators/templates/create_table_migration/%migration_filename%.rb.tt +19 -0
  32. data/lib/gris/generators/templates/migration/%migration_filename%.rb.tt +39 -0
  33. data/lib/gris/generators/templates/scaffold/.Procfile.tt +1 -0
  34. data/lib/gris/generators/templates/scaffold/.env.test.tt +11 -0
  35. data/lib/gris/generators/templates/scaffold/.env.tt +10 -0
  36. data/lib/gris/generators/templates/scaffold/.gitignore.tt +11 -0
  37. data/lib/gris/generators/templates/scaffold/.rspec.tt +3 -0
  38. data/lib/gris/generators/templates/scaffold/.rubocop.yml +18 -0
  39. data/lib/gris/generators/templates/scaffold/.ruby-gemset.tt +1 -0
  40. data/lib/gris/generators/templates/scaffold/.ruby-version.tt +1 -0
  41. data/lib/gris/generators/templates/scaffold/Gemfile.tt +33 -0
  42. data/lib/gris/generators/templates/scaffold/README.md.tt +3 -0
  43. data/lib/gris/generators/templates/scaffold/Rakefile +9 -0
  44. data/lib/gris/generators/templates/scaffold/app.rb +57 -0
  45. data/lib/gris/generators/templates/scaffold/app/apis/application_endpoint.rb +9 -0
  46. data/lib/gris/generators/templates/scaffold/app/presenters/root_presenter.rb +20 -0
  47. data/lib/gris/generators/templates/scaffold/config.ru.tt +6 -0
  48. data/lib/gris/generators/templates/scaffold/config/database.yml.tt +19 -0
  49. data/lib/gris/generators/templates/scaffold/config/initializers/active_record.rb +4 -0
  50. data/lib/gris/generators/templates/scaffold/db/schema.rb +11 -0
  51. data/lib/gris/generators/templates/scaffold/public/errors/404.html +11 -0
  52. data/lib/gris/generators/templates/scaffold/public/errors/500.html +11 -0
  53. data/lib/gris/generators/templates/scaffold/spec/apis/cors_spec.rb +31 -0
  54. data/lib/gris/generators/templates/scaffold/spec/spec_helper.rb +26 -0
  55. data/lib/gris/generators/templates/scaffold/spec/support/app_helper.rb +3 -0
  56. data/lib/gris/grape_extensions/crud_helpers.rb +26 -0
  57. data/lib/gris/identity.rb +50 -0
  58. data/lib/gris/middleware/app_monitor.rb +17 -0
  59. data/lib/gris/output_formatters/paginated_presenter.rb +41 -0
  60. data/lib/gris/output_formatters/presenter.rb +15 -0
  61. data/lib/gris/rspec_extensions/response_helpers.rb +57 -0
  62. data/lib/gris/setup.rb +17 -0
  63. data/lib/gris/version.rb +38 -0
  64. data/lib/tasks/db.rake +81 -0
  65. data/lib/tasks/routes.rake +11 -0
  66. data/spec/generators/api_generator_spec.rb +76 -0
  67. data/spec/generators/migration_generator_spec.rb +96 -0
  68. data/spec/generators/scaffold_generator_spec.rb +119 -0
  69. data/spec/grape_extensions/crud_helpers_spec.rb +5 -0
  70. data/spec/identity_spec.rb +86 -0
  71. data/spec/spec_helper.rb +10 -0
  72. data/spec/support/spec_generators_helper.rb +11 -0
  73. data/spec/version_spec.rb +40 -0
  74. metadata +426 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f85d97c1f4ca0b9033d5ee37002fb6217991ff0
4
+ data.tar.gz: 78696b9f4b50e7b004a4895c3a1c295ec604804a
5
+ SHA512:
6
+ metadata.gz: a799d514738422209054b720e61282579d78b476f36688845f37d6b132a5044e618dd7fa7aeeb61bd8011d8ab1ae86bec87b0bbed20145a2074c01a3820bc827
7
+ data.tar.gz: 55814e34671b7cd39c1e581b0835700511c21e54391301628c9d30b5b2ae2f74585e3c6fd4643ab162c21ec7c46278c995ca10d74f64b1d28414f964effd4e0d
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ test/tmp
5
+ test/version_tmp
6
+ tmp
7
+ .DS_Store
8
+ .keep
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --profile
3
+ --format documentation
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,67 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-02-01 07:58:32 -0500 using RuboCop version 0.28.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ # Configuration parameters: AlignWith, SupportedStyles.
10
+ Lint/EndAlignment:
11
+ Enabled: false
12
+
13
+ # Offense count: 1
14
+ Lint/LiteralInInterpolation:
15
+ Enabled: false
16
+
17
+ # Offense count: 4
18
+ Metrics/AbcSize:
19
+ Max: 40
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: CountComments.
23
+ Metrics/ClassLength:
24
+ Max: 112
25
+
26
+ # Offense count: 2
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 11
29
+
30
+ # Offense count: 34
31
+ # Configuration parameters: AllowURI, URISchemes.
32
+ Metrics/LineLength:
33
+ Max: 159
34
+
35
+ # Offense count: 6
36
+ # Configuration parameters: CountComments.
37
+ Metrics/MethodLength:
38
+ Max: 29
39
+
40
+ # Offense count: 16
41
+ # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
42
+ Style/CaseIndentation:
43
+ Enabled: false
44
+
45
+ # Offense count: 21
46
+ Style/Documentation:
47
+ Enabled: false
48
+
49
+ # Offense count: 3
50
+ Style/DoubleNegation:
51
+ Enabled: false
52
+
53
+ # Offense count: 2
54
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist.
55
+ Style/PredicateName:
56
+ Enabled: false
57
+
58
+ # Offense count: 3
59
+ # Configuration parameters: MaxSlashes.
60
+ Style/RegexpLiteral:
61
+ Enabled: false
62
+
63
+ # Offense count: 2
64
+ # Cop supports --auto-correct.
65
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
66
+ Style/TrivialAccessors:
67
+ Enabled: false
@@ -0,0 +1 @@
1
+ gris
@@ -0,0 +1 @@
1
+ ruby-2.1.5
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'byebug'
7
+ gem 'rubocop'
8
+ gem 'guard-rspec', require: false
9
+ gem 'guard-rubocop'
10
+ gem 'rake', '~> 10.0'
11
+ gem 'fakefs', '~> 0.4'
12
+ end
@@ -0,0 +1,203 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gris (0.0.2)
5
+ activesupport (~> 4.2, >= 4.2.0)
6
+ dotenv (~> 1.0.2, >= 1.0.2)
7
+ git (~> 1.2, >= 1.2.8)
8
+ grape (~> 0.10.1, >= 0.10.1)
9
+ grape-roar (~> 0.3.0, >= 0.3.0)
10
+ grape-swagger (~> 0.9.0, >= 0.9.0)
11
+ logging
12
+ racksh (~> 1.0)
13
+ rake (~> 10.4, >= 10.4.2)
14
+ roar (~> 1.0.0, >= 1.0.0)
15
+ thor (~> 0.19, >= 0.19.1)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ activemodel (4.2.0)
21
+ activesupport (= 4.2.0)
22
+ builder (~> 3.1)
23
+ activerecord (4.2.0)
24
+ activemodel (= 4.2.0)
25
+ activesupport (= 4.2.0)
26
+ arel (~> 6.0)
27
+ activesupport (4.2.0)
28
+ i18n (~> 0.7)
29
+ json (~> 1.7, >= 1.7.7)
30
+ minitest (~> 5.1)
31
+ thread_safe (~> 0.3, >= 0.3.4)
32
+ tzinfo (~> 1.1)
33
+ acts_as_fu (0.0.9)
34
+ activerecord
35
+ sqlite3
36
+ arel (6.0.0)
37
+ ast (2.0.0)
38
+ astrolabe (1.3.0)
39
+ parser (>= 2.2.0.pre.3, < 3.0)
40
+ axiom-types (0.1.1)
41
+ descendants_tracker (~> 0.0.4)
42
+ ice_nine (~> 0.11.0)
43
+ thread_safe (~> 0.3, >= 0.3.1)
44
+ builder (3.2.2)
45
+ byebug (3.5.1)
46
+ columnize (~> 0.8)
47
+ debugger-linecache (~> 1.2)
48
+ slop (~> 3.6)
49
+ celluloid (0.16.0)
50
+ timers (~> 4.0.0)
51
+ coderay (1.1.0)
52
+ coercible (1.0.0)
53
+ descendants_tracker (~> 0.0.1)
54
+ columnize (0.9.0)
55
+ debugger-linecache (1.2.0)
56
+ descendants_tracker (0.0.4)
57
+ thread_safe (~> 0.3, >= 0.3.1)
58
+ diff-lcs (1.2.5)
59
+ dotenv (1.0.2)
60
+ equalizer (0.0.9)
61
+ fakefs (0.6.4)
62
+ ffi (1.9.6)
63
+ formatador (0.2.5)
64
+ git (1.2.9.1)
65
+ grape (0.10.1)
66
+ activesupport
67
+ builder
68
+ hashie (>= 2.1.0)
69
+ multi_json (>= 1.3.2)
70
+ multi_xml (>= 0.5.2)
71
+ rack (>= 1.3.0)
72
+ rack-accept
73
+ rack-mount
74
+ virtus (>= 1.0.0)
75
+ grape-entity (0.4.4)
76
+ activesupport
77
+ multi_json (>= 1.3.2)
78
+ grape-roar (0.3.0)
79
+ grape
80
+ roar (>= 1.0)
81
+ grape-swagger (0.9.0)
82
+ grape (>= 0.8.0)
83
+ grape-entity
84
+ guard (2.11.1)
85
+ formatador (>= 0.2.4)
86
+ listen (~> 2.7)
87
+ lumberjack (~> 1.0)
88
+ nenv (~> 0.1)
89
+ notiffany (~> 0.0)
90
+ pry (>= 0.9.12)
91
+ shellany (~> 0.0)
92
+ thor (>= 0.18.1)
93
+ guard-compat (1.2.0)
94
+ guard-rspec (4.5.0)
95
+ guard (~> 2.1)
96
+ guard-compat (~> 1.1)
97
+ rspec (>= 2.99.0, < 4.0)
98
+ guard-rubocop (1.1.0)
99
+ guard (~> 2.0)
100
+ rubocop (~> 0.20)
101
+ hashie (3.3.2)
102
+ hitimes (1.2.2)
103
+ i18n (0.7.0)
104
+ ice_nine (0.11.1)
105
+ json (1.8.2)
106
+ listen (2.8.5)
107
+ celluloid (>= 0.15.2)
108
+ rb-fsevent (>= 0.9.3)
109
+ rb-inotify (>= 0.9)
110
+ little-plugger (1.1.3)
111
+ logging (1.8.2)
112
+ little-plugger (>= 1.1.3)
113
+ multi_json (>= 1.8.4)
114
+ lumberjack (1.0.9)
115
+ method_source (0.8.2)
116
+ mini_portile (0.6.2)
117
+ minitest (5.5.1)
118
+ multi_json (1.10.1)
119
+ multi_xml (0.5.5)
120
+ nenv (0.1.1)
121
+ nokogiri (1.6.6.2)
122
+ mini_portile (~> 0.6.0)
123
+ notiffany (0.0.2)
124
+ nenv (~> 0.1)
125
+ shellany (~> 0.0)
126
+ parser (2.2.0.2)
127
+ ast (>= 1.1, < 3.0)
128
+ powerpack (0.0.9)
129
+ pry (0.10.1)
130
+ coderay (~> 1.1.0)
131
+ method_source (~> 0.8.1)
132
+ slop (~> 3.4)
133
+ rack (1.6.0)
134
+ rack-accept (0.4.5)
135
+ rack (>= 0.4)
136
+ rack-mount (0.8.3)
137
+ rack (>= 1.0.0)
138
+ rack-test (0.6.3)
139
+ rack (>= 1.0)
140
+ racksh (1.0.0)
141
+ rack (>= 1.0)
142
+ rack-test (>= 0.5)
143
+ rainbow (2.0.0)
144
+ rake (10.4.2)
145
+ rb-fsevent (0.9.4)
146
+ rb-inotify (0.9.5)
147
+ ffi (>= 0.5.0)
148
+ representable (2.1.4)
149
+ multi_json
150
+ nokogiri
151
+ uber (~> 0.0.7)
152
+ roar (1.0.0)
153
+ representable (>= 2.0.1, <= 3.0.0)
154
+ rspec (3.1.0)
155
+ rspec-core (~> 3.1.0)
156
+ rspec-expectations (~> 3.1.0)
157
+ rspec-mocks (~> 3.1.0)
158
+ rspec-core (3.1.7)
159
+ rspec-support (~> 3.1.0)
160
+ rspec-expectations (3.1.2)
161
+ diff-lcs (>= 1.2.0, < 2.0)
162
+ rspec-support (~> 3.1.0)
163
+ rspec-mocks (3.1.3)
164
+ rspec-support (~> 3.1.0)
165
+ rspec-support (3.1.2)
166
+ rubocop (0.28.0)
167
+ astrolabe (~> 1.3)
168
+ parser (>= 2.2.0.pre.7, < 3.0)
169
+ powerpack (~> 0.0.6)
170
+ rainbow (>= 1.99.1, < 3.0)
171
+ ruby-progressbar (~> 1.4)
172
+ ruby-progressbar (1.7.1)
173
+ shellany (0.0.1)
174
+ slop (3.6.0)
175
+ sqlite3 (1.3.10)
176
+ thor (0.19.1)
177
+ thread_safe (0.3.4)
178
+ timers (4.0.1)
179
+ hitimes
180
+ tzinfo (1.2.2)
181
+ thread_safe (~> 0.1)
182
+ uber (0.0.13)
183
+ virtus (1.0.4)
184
+ axiom-types (~> 0.1)
185
+ coercible (~> 1.0)
186
+ descendants_tracker (~> 0.0, >= 0.0.3)
187
+ equalizer (~> 0.0, >= 0.0.9)
188
+
189
+ PLATFORMS
190
+ ruby
191
+
192
+ DEPENDENCIES
193
+ activerecord (~> 4.2, >= 4.2.0)
194
+ acts_as_fu (~> 0)
195
+ bundler (~> 1.7.10, >= 1.7.10)
196
+ byebug
197
+ fakefs (~> 0.4)
198
+ gris!
199
+ guard-rspec
200
+ guard-rubocop
201
+ rake (~> 10.0)
202
+ rspec (~> 3.1, >= 3.1.0)
203
+ rubocop
@@ -0,0 +1,82 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), the you will want to move the Guardfile
18
+ ## to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: 'bundle exec rspec' do
36
+ require 'guard/rspec/dsl'
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.call("routing/#{m[1]}_routing"),
59
+ rspec.spec.call("controllers/#{m[1]}_controller"),
60
+ rspec.spec.call("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
76
+ end
77
+ end
78
+
79
+ guard :rubocop do
80
+ watch(%r{.+\.rb$})
81
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
82
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Dylan Fareed
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ # Gris
2
+
3
+ Gris is a framework for building Rack-based hypermedia APIs using Grape, Roar and ActiveRecord.
4
+
5
+ It is derived from/inspired by the stellar and more sophisticated [Napa framework by Bellycard Inc.](https://github.com/bellycard/napa).
6
+
7
+ 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.
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rake/testtask'
4
+ require 'bundler/gem_tasks'
5
+
6
+ Rake::TestTask.new(:spec) do |test|
7
+ test.libs << 'lib' << 'spec'
8
+ test.pattern = 'spec/**/*_spec.rb'
9
+ end
10
+
11
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gris/cli'
4
+
5
+ Gris::CLI::Base.start(ARGV)