revelry_generate 0.4.9 → 0.5.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: f2175dd3295ef8e46be5edcdd8595204baed2c49
4
- data.tar.gz: 9b3032177a17281d325bd13ce867d31d846a2778
3
+ metadata.gz: bd699664d6b70a221289915581113375d5c8741c
4
+ data.tar.gz: 9e64fa55eb9d21bbb73f203c20a916665d29c865
5
5
  SHA512:
6
- metadata.gz: 31ad4577be6817968f9cc34ca2d2cfcc65e0290bdaca858cb62a5e762473fe65325a61db6a0b8348040cce01ea79d20420a2af772f7e83473eae775c967df86a
7
- data.tar.gz: e00dc9b3d13ed19947ed5505f323a780460d2d8991913b3f52b6621fa0f23563882825ba0dd8d5f56f4cbb15ba8a81485b4291ef645143c6dd60be96629f2f24
6
+ metadata.gz: e346dd7faee1294ab76584277a45e0aaab68813fc854e6dc1d8b532ef3327be87eccf91eb89376dbaa5ce50767e55050f03bd2509b4344e7cadb5d6e3c2e134a
7
+ data.tar.gz: 6a6836f6a7a00f26f3358958cea0d602c4200e908c840b8c490a823efa28691b56fff57d8ab48e405af2620e7036bef1e9a16d57db5e8f89a8f8132d12951f0c
data/README.md CHANGED
@@ -1,41 +1,51 @@
1
- # generate
1
+ # revelry_generate
2
2
 
3
- Packages containing the application templates, scaffolds, and generators for the
4
- Revelry 2016 Name TBD stack.
3
+ Generate a Rails project with a React-based view engine.
5
4
 
6
- ## Using
5
+ ## Generated App Features
7
6
 
8
- ```
9
- rails new app_name -m template.rb -T -d postgresql
10
- ```
7
+ ### Node.js render service
11
8
 
12
- or
9
+ * Full-fledged Express app with Webpack, Babel, React, Redux, and more
10
+ * Domain-centric module structure for better code organization
11
+ * Receives POSTed JSON payloads, uses them as React props, and responds with HTML
13
12
 
14
- ```
15
- bin/rake rails:template LOCATION=template.rb
16
- ```
13
+ ### Rails glue
17
14
 
18
- This will generate an app using the default skeleton. The skeleton will give you
19
- further instructions from there.
15
+ * `jbuilder` templates define React props
16
+ * Controller concern connects view rendering to the Node service
17
+ * Generator hooks cause JavaScript modules to be generated in the render service as well
20
18
 
21
- ## slush (default) skeleton
19
+ ## Usage
22
20
 
23
- This provides a skeleton for rails with rails_render_service and the
24
- revelry framework. After creating a new app with the template (see above), you
25
- can:
21
+ ### Install
26
22
 
27
- ### Start the servers
23
+ ```
24
+ gem install revelry_generate
25
+ ```
26
+
27
+ ### Create a new app
28
28
 
29
29
  ```
30
- npm run dev
30
+ revelry_generate new my_app && cd my_app
31
31
  ```
32
32
 
33
33
  ### Scaffold a new resource
34
34
 
35
- Just do:
36
-
35
+ Same as a normal Rails app:
37
36
  ```
38
37
  rails g scaffold Article
39
38
  ```
40
39
 
41
- like a normal rails app.
40
+ ### Run local servers
41
+
42
+ ```
43
+ npm run dev
44
+ ```
45
+
46
+ ### Applying the template to an existing app
47
+
48
+ From the app's directory, run:
49
+ ```
50
+ revelry_generate install
51
+ ```
data/bin/after_bundle ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ system 'bin/rails g rspec:install'
4
+ system 'bin/rails g revelry_generate:skeleton'
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+
4
+ class RevelryGenerateCLI < Thor
5
+ desc 'new [NAME]', 'Create a new Rails app from the revelry_generate template'
6
+ def new(name)
7
+ system "rails new #{name} -m #{template_path} --skip-spring -T -d postgresql"
8
+ end
9
+
10
+ desc 'install', 'Apply the revelry_generate template to an existing Rails app'
11
+ def install
12
+ system "rails app:template LOCATION=#{template_path} && #{after_bundle_path}"
13
+ end
14
+
15
+ private
16
+
17
+ def template_path
18
+ @template_path ||= File.expand_path('../../template.rb', __FILE__)
19
+ end
20
+
21
+ def after_bundle_path
22
+ @after_bundle_path ||= File.expand_path('../after_bundle', __FILE__)
23
+ end
24
+ end
25
+
26
+ RevelryGenerateCLI.start ARGV
data/template.rb ADDED
@@ -0,0 +1,107 @@
1
+ gem 'rails_render_service'
2
+ gem 'foreman'
3
+ gem 'dotenv'
4
+
5
+ # Add our default server config
6
+ gem 'puma'
7
+ gem 'rails_12factor'
8
+
9
+ gem_group :development do
10
+ gem 'revelry_generate'
11
+ end
12
+
13
+ # Add our testing config
14
+ gem_group :development, :test do
15
+ gem "rspec-rails"
16
+ end
17
+
18
+ comment_lines 'Gemfile', 'turbolinks'
19
+ gsub_file('app/assets/javascripts/application.js', '//= require turbolinks', '')
20
+ comment_lines 'Gemfile', 'spring'
21
+
22
+ application 'Dotenv.load'
23
+ application <<-RB
24
+ config.generators do |g|
25
+ g.jbuilder = :jbuilder_props
26
+ g.assets = false
27
+ end
28
+ RB
29
+
30
+ file File.join('app', 'controllers', 'concerns', 'rejax.rb'), <<-RUBY
31
+ module Rejax
32
+ extend ActiveSupport::Concern
33
+
34
+ included do
35
+ alias_method :redirect_to_without_default_303, :redirect_to
36
+ alias_method :redirect_to, :redirect_to_with_default_303
37
+
38
+ alias_method :url_for_without_include_json_format_ext, :url_for
39
+ alias_method :url_for, :url_for_with_include_json_format_ext
40
+ end
41
+
42
+ def redirect_to_with_default_303(options = {}, response_status = {})
43
+ response_status.reverse_merge! status: 303
44
+ redirect_to_without_default_303 options, response_status
45
+ end
46
+
47
+ def url_for_with_include_json_format_ext(record_or_hash_or_array, options = {})
48
+ options.reverse_merge! format: :json if request.format == :json
49
+ url_for_without_include_json_format_ext options
50
+ end
51
+ end
52
+ RUBY
53
+
54
+ file File.join('app', 'helpers', 'json_helper.rb'), <<-RUBY
55
+ module JsonHelper
56
+ # E.g., json_form(@article, nest: [:author, :comments])
57
+ def json_form(model, opts = {})
58
+ # return unless model
59
+ Jbuilder.new do |json|
60
+ _json_form_json(json, model, opts)
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def _json_form_json(json, model, opts={})
67
+ return unless model
68
+ json.merge! model.attributes
69
+ json.errors model.errors.any? ? model.errors.to_hash : nil
70
+
71
+ # Requested inclusion of nested attributes
72
+ if opts[:nest]
73
+ opts[:nest].each do |relationship_sym|
74
+ nested_model = model.send(relationship_sym)
75
+ # Relationship is a collection we need to map
76
+ if nested_model.respond_to? :map
77
+ json.set! relationship_sym, nested_model do |model|
78
+ _json_form_json(json, model)
79
+ end
80
+ # Singular relationship to set
81
+ else
82
+ json.set! relationship_sym, json_form(nested_model)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ RUBY
89
+
90
+ inside(File.join('app', 'controllers')) do
91
+ inject_into_file 'application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do
92
+ " include RailsRenderService::Concern\n include Rejax\n"
93
+ end
94
+ end
95
+
96
+ initializer 'rails_render_service.rb', <<-ruby
97
+ Rails.application.config.rails_render_service.get_uri = lambda do
98
+ "unix://\#{Rails.root.join ENV['RENDER_SERVICE_SOCKET']}"
99
+ end
100
+ ruby
101
+
102
+ remove_file 'README.rdoc'
103
+
104
+ after_bundle do
105
+ run File.expand_path('../bin/after_bundle', __FILE__)
106
+ git :init
107
+ end
metadata CHANGED
@@ -1,24 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revelry_generate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Prehn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
33
+ - !ruby/object:Gem::Dependency
34
+ name: thor
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.19'
40
+ - - "<="
41
+ - !ruby/object:Gem::Version
42
+ version: '1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0.19'
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: '1'
13
53
  description: ''
14
54
  email:
15
55
  - robert@revelry.co
16
- executables: []
56
+ executables:
57
+ - revelry_generate
17
58
  extensions: []
18
59
  extra_rdoc_files: []
19
60
  files:
20
61
  - LICENSE
21
62
  - README.md
63
+ - bin/after_bundle
64
+ - bin/revelry_generate
22
65
  - lib/rails/generators/jbuilder_props/jbuilder_props_generator.rb
23
66
  - lib/rails/generators/jbuilder_props/templates/edit.json.jbuilder
24
67
  - lib/rails/generators/jbuilder_props/templates/index.json.jbuilder
@@ -59,6 +102,7 @@ files:
59
102
  - skeletons/slush/app.json
60
103
  - skeletons/slush/config/initializers/scaffold.rb
61
104
  - skeletons/slush/package.json
105
+ - template.rb
62
106
  homepage: https://github.com/revelrylabs/generate.git
63
107
  licenses:
64
108
  - MIT
@@ -79,8 +123,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
123
  version: '0'
80
124
  requirements: []
81
125
  rubyforge_project:
82
- rubygems_version: 2.6.8
126
+ rubygems_version: 2.5.2
83
127
  signing_key:
84
128
  specification_version: 4
85
129
  summary: ''
86
130
  test_files: []
131
+ has_rdoc: