granule 0.1.7 → 0.1.8

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
  SHA256:
3
- metadata.gz: 36c6e3904ef0412b890f1ef65ed92960a3b1e914607989f387a4c124ad7ddd4a
4
- data.tar.gz: 8412718336be9b9648da1fa3e653ac9e7b4580bf48c675e1f6f8f8a1bf0c3e86
3
+ metadata.gz: 15935412881b5ce2177ac68bbdc885c732bbd211dd356dbdb2902787b9a86266
4
+ data.tar.gz: 2978610921cbf21678373d2c44f99ebd938646c3ca0ccafca2b1490ddd0ea0d1
5
5
  SHA512:
6
- metadata.gz: b1fb416fa5cbac9176c66047a08acc71c7f3239e00dec11f4718faea790b09ecdf5909520ef97b36da3bf03948d82cbf7eea7c1f3c361ff7a5337cc68ad8aad0
7
- data.tar.gz: 6315f37cba131cc7a59aff0de80d8dc4697915b6b9ffb39e6a7e1aa692927b56c2718877b616da1d99ed86d31a3b16cc39fcec6b790738eb61f53a800f8f3d79
6
+ metadata.gz: 0e7021a4eabddd0cf3d0b1a652214d412be9b4ae0e9d98056fcc622c712ed982a1f50feacd2587cdcfb4872ccad3914400fc6ffd15e5445e3eb0594049f4acc0
7
+ data.tar.gz: 244ad295380443cbb35477c9c7e84ec96a1c075a9bdf707a8bb971cdf2c850ab0d823eaffaedb346c3d13cda7cd94c31936bb5defc77a100b6368a41453f11a5
@@ -0,0 +1,19 @@
1
+ ARG RUBY_VERSION
2
+ ARG BUNDLER_VERSION
3
+ FROM ruby:$RUBY_VERSION-alpine
4
+
5
+ # Configure bundler
6
+ ENV LANG=C.UTF-8 \
7
+ BUNDLE_JOBS=4 \
8
+ BUNDLE_RETRY=3
9
+
10
+ RUN apk add --update --no-cache \
11
+ openssh \
12
+ build-base \
13
+ git \
14
+ && apk add --no-cache yarn --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community" \
15
+ && gem update --system \
16
+ && gem install bundler \
17
+ && mkdir -p /granule
18
+
19
+ WORKDIR /granule
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Ruby 2.7",
3
+ "dockerComposeFile": "docker-compose.yml",
4
+ "service": "gem",
5
+ "workspaceFolder": "/workspace",
6
+ "settings": {
7
+ "terminal.integrated.shell.linux": "/bin/ash"
8
+ },
9
+ "extensions": [
10
+ "rebornix.Ruby"
11
+ ]
12
+ }
@@ -0,0 +1,14 @@
1
+ version: '3.7'
2
+
3
+ services:
4
+ gem:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ args:
9
+ RUBY_VERSION: '2.7.0'
10
+ BUNDLER_VERSION: '2.1.4'
11
+ volumes:
12
+ - ..:/workspace:cached
13
+ command: sleep infinity
14
+ image: granule:0.1.0
@@ -4,9 +4,9 @@ require:
4
4
  - rubocop-rspec
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.6
7
+ TargetRubyVersion: 2.7
8
8
 
9
- Metrics/LineLength:
9
+ Layout/LineLength:
10
10
  Max: 120
11
11
 
12
12
  Style/Documentation:
@@ -25,4 +25,4 @@ RSpec/MultipleExpectations:
25
25
  Enabled: false
26
26
 
27
27
  RSpec/ExampleLength:
28
- Max: 20
28
+ Max: 50
@@ -0,0 +1,53 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+
5
+ {
6
+ "name": "RSpec - all",
7
+ "type": "Ruby",
8
+ "request": "launch",
9
+ "useBundler": true,
10
+ "cwd": "${workspaceRoot}",
11
+ "pathToBundler": "/usr/local/bin/bundle",
12
+ "pathToRDebugIDE": "/usr/local/bundle/ruby/2.7.0/gems/ruby-debug-ide-0.7.0/bin/rdebug-ide",
13
+ "debuggerPort": "1235",
14
+ "program": "/usr/local/bin/bundle",
15
+ "args": [
16
+ "exec",
17
+ "rspec"
18
+ ]
19
+ },
20
+ {
21
+ "name": "Debug RSpec - open spec file",
22
+ "type": "Ruby",
23
+ "request": "launch",
24
+ "cwd": "${workspaceRoot}",
25
+ "useBundler": true,
26
+ "pathToBundler": "/usr/local/bin/bundle",
27
+ "pathToRDebugIDE": "/usr/local/bundle/ruby/2.7.0/gems/ruby-debug-ide-0.7.0/bin/rdebug-ide",
28
+ "debuggerPort": "1235",
29
+ "program": "/usr/local/bin/bundle",
30
+ "args": [
31
+ "exec",
32
+ "rspec",
33
+ "${file}"
34
+ ]
35
+ },
36
+ {
37
+ "name": "Debug RSpec - open spec file on a certain line",
38
+ "type": "Ruby",
39
+ "request": "launch",
40
+ "cwd": "${workspaceRoot}",
41
+ "useBundler": true,
42
+ "pathToBundler": "/usr/local/bin/bundle",
43
+ "pathToRDebugIDE": "/usr/local/bundle/ruby/2.7.0/gems/ruby-debug-ide-0.7.0/bin/rdebug-ide",
44
+ "debuggerPort": "1235",
45
+ "program": "/usr/local/bin/bundle",
46
+ "args": [
47
+ "exec",
48
+ "rspec",
49
+ "${file}:${lineNumber}"
50
+ ]
51
+ },
52
+ ]
53
+ }
data/README.md CHANGED
@@ -84,20 +84,21 @@ Test
84
84
  ├── app
85
85
  │ ├── controllers
86
86
  │ │ ├── applications_controller.rb # Default
87
- │ │ └── sessions_controller.rb # Typical rails controller
87
+ │ │ ├── fallback_controller.rb # Controller with predefined handlers
88
+ │ │ └── pages_controller.rb # Typical rails controller
88
89
  │ ├── core
89
90
  │ │ ├── application_interactor.rb # Parent interactor class
90
- │ │ ├── application_contract.rb # Parent contract class
91
- │ │ └── session_create # Feature folder (controller_action name)
92
- │ │ ├── contract.rb # params validations
93
- │ │ ├── interactor.rb # business logic
94
- │ │ ├── policy.rb # authorization layer
95
- │ │ ├── serializer.rb # json presenter
96
- │ │ └── you_name_it.rb # custom logic
91
+ │ │ └── pages # Feature folder (controller name plural)
92
+ │ │ ├── index # action name
93
+ │ │ ... ├── contract.rb # params validations
94
+ │ │ ├── interactor.rb # business logic
95
+ │ │ ├── policy.rb # authorization layer
96
+ │ │ ├── serializer.rb # json presenter
97
+ │ │ └── you_name_it.rb # custom logic
97
98
  │ ...
98
99
  ├── spec
99
100
  │ ├── core
100
- │ │ ├── session_create_spec.rb # Unit tests input/output
101
+ │ │ ├── pages_index_spec.rb # Unit tests input/output
101
102
  │ │ ...
102
103
  │ ├── request
103
104
  │ │ ├── sessions_request_spec.rb # Integration tests (SUCCESS/FAIL)
@@ -106,39 +107,6 @@ Test
106
107
  │ ├── login_spec.rb # Rails System specs (using browser driver)
107
108
  │ ...
108
109
 
109
- ## Features
110
-
111
- What's all the bells and whistles this project can perform?
112
- * What's the main functionality
113
- * You can also do another thing
114
- * If you get really randy, you can even do this
115
-
116
- ## Usage
117
-
118
- ### Controllers
119
-
120
- TBD
121
-
122
- ### Matchers
123
-
124
- TBD
125
-
126
- ### Interactors
127
-
128
- TBD
129
-
130
- ### Contracts
131
-
132
- TBD
133
-
134
- ### Authorization
135
-
136
- TBD
137
-
138
- ## Contributing
139
-
140
- TBD
141
-
142
110
  Bug reports and pull requests are welcome on GitHub at https://github.com/leksster/granule. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
143
111
 
144
112
  ## License
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['leksster@gmail.com']
12
12
 
13
13
  spec.summary = 'Rails apps bootstrapper.'
14
- spec.description = spec.summary
14
+ spec.description = 'Opinionated Rails App Bootstrapper aimed to even faster prototyping'
15
15
  spec.homepage = 'http://github.com/leksster/granule'
16
16
  spec.license = 'MIT'
17
17
 
@@ -39,10 +39,12 @@ Gem::Specification.new do |spec|
39
39
  spec.add_runtime_dependency 'rails', Granule::RAILS_VERSION
40
40
 
41
41
  spec.add_development_dependency 'bundler', '~> 2.0'
42
- spec.add_development_dependency 'pry'
42
+ spec.add_development_dependency 'pry', '~> 0.12'
43
43
  spec.add_development_dependency 'rake', '~> 10.0'
44
44
  spec.add_development_dependency 'rspec', '~> 3.0'
45
- spec.add_development_dependency 'rubocop'
46
- spec.add_development_dependency 'rubocop-performance'
47
- spec.add_development_dependency 'rubocop-rspec'
45
+ spec.add_development_dependency 'rubocop', '~> 0.78'
46
+ spec.add_development_dependency 'rubocop-performance', '~> 1.5'
47
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
48
+ spec.add_development_dependency 'ruby-debug-ide'
49
+ spec.add_development_dependency 'debase'
48
50
  end
@@ -16,10 +16,21 @@ module Granule
16
16
  def new(name)
17
17
  cmd = "rails new #{name} #{DEFAULT_OPTIONS}"
18
18
 
19
- if defined?(Bundler)
20
- Bundler.with_clean_env { run(cmd) }
21
- else
22
- run(cmd)
19
+ run(cmd)
20
+
21
+ insert_into_file "./#{name}/config/environments/development.rb", after: "Rails.application.configure do\n" do
22
+ <<-RUBY
23
+ # Ignore warnings while in docker environemnts
24
+ config.web_console.whiny_requests = false
25
+
26
+ RUBY
27
+ end
28
+
29
+ insert_into_file "./#{name}/config/routes.rb", after: "Rails.application.routes.draw do\n" do
30
+ <<-RUBY
31
+ resources :pages
32
+
33
+ RUBY
23
34
  end
24
35
  end
25
36
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/AbcSize
3
4
  def call
4
5
  template 'Gemfile.tt', force: true
5
6
  template '.rubocop.yml.tt', force: true
@@ -10,7 +11,16 @@ def call
10
11
  template 'README.md.tt', force: true
11
12
  template 'database.yml.tt', 'config/database.yml', force: true
12
13
  template 'database.yml.tt', 'config/database.sample.yml', force: true
14
+ template 'application_interactor.rb.tt', 'app/core/application_interactor.rb', force: true
15
+ template 'dry.rb.tt', 'config/initializers/dry.rb', force: true
16
+ template 'fallback_controller.rb.tt', 'app/controllers/fallback_controller.rb', force: true
17
+ template 'pages_controller.rb.tt', 'app/controllers/pages_controller.rb', force: true
18
+ template 'index.html.erb.tt', 'app/views/pages/index.html.erb', force: true
19
+ template 'show.html.erb.tt', 'app/views/pages/show.html.erb', force: true
20
+ template 'index.rb.tt', 'app/core/pages/index.rb', force: true
21
+ template 'show.rb.tt', 'app/core/pages/show.rb', force: true
13
22
  end
23
+ # rubocop:enable Metrics/AbcSize
14
24
 
15
25
  def source_paths
16
26
  [__dir__ + '/base']
@@ -4,15 +4,15 @@ require:
4
4
  - rubocop-rspec
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.6
7
+ TargetRubyVersion: 2.7
8
8
 
9
- Metrics/LineLength:
9
+ Layout/LineLength:
10
10
  Max: 120
11
11
 
12
- Documentation:
12
+ Style/Documentation:
13
13
  Enabled: false
14
14
 
15
- FrozenStringLiteralComment:
15
+ Style/FrozenStringLiteralComment:
16
16
  Enabled: false
17
17
 
18
18
  Style/LambdaCall:
@@ -2,15 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
4
 
5
- ruby '<%= RUBY_VERSION %>'
5
+ ruby '2.7.0'
6
6
 
7
7
  gem 'bootsnap', require: false
8
8
 
9
9
  # Authentication
10
10
  gem 'devise'
11
11
 
12
- # Interactors
13
- gem 'dry-matcher'
12
+ # Interactor
14
13
  gem 'dry-monads'
15
14
 
16
15
  # Validation
@@ -8,7 +8,7 @@ Install dependencies and create/migrate db schema with seeds
8
8
  $ docker-compose run --rm runner
9
9
 
10
10
  > bundle install
11
- > yarn install
11
+ > rails webpacker:install
12
12
  > rails db:create
13
13
  > rails db:migrate
14
14
  > rails data:migrate
@@ -0,0 +1,6 @@
1
+ class ApplicationInteractor
2
+ def self.inherited(subclass)
3
+ subclass.include(Dry::Monads::Do.for(:call))
4
+ subclass.include(Dry::Monads[:result])
5
+ end
6
+ end
@@ -7,10 +7,10 @@ services:
7
7
  context: .
8
8
  dockerfile: ./Dockerfile.dev
9
9
  args:
10
- RUBY_VERSION: '2.6.5'
11
- ALPINE_VERSION: '3.10'
12
- BUNDLER_VERSION: '2.0.2'
13
- image: app-dev:1.0.0
10
+ RUBY_VERSION: '2.7.0'
11
+ ALPINE_VERSION: ''
12
+ BUNDLER_VERSION: '2.1.2'
13
+ image: <%= "#{app_name}:1.0.0" %>
14
14
  tmpfs:
15
15
  - /tmp
16
16
 
@@ -32,7 +32,6 @@ services:
32
32
  - packs:/app/public/packs
33
33
  depends_on:
34
34
  - postgres
35
- - webpacker
36
35
 
37
36
  runner:
38
37
  <<: *backend
@@ -0,0 +1,2 @@
1
+ require 'dry/monads'
2
+ require 'dry/monads/do'
@@ -0,0 +1,38 @@
1
+ class FallbackController < ApplicationController
2
+ private
3
+
4
+ def handle_with(klass, params: {}, **context)
5
+ klass.new.call(params, context) do |monad|
6
+ case monad
7
+ in Dry::Monads::Failure(errors)
8
+ respond_to do |format|
9
+ format.html do
10
+ raise ActionController::RoutingError.new(errors)
11
+ end
12
+
13
+ format.json do
14
+ render json: errors
15
+ end
16
+ end
17
+
18
+ in Dry::Monads::Success(resource)
19
+ respond_to do |format|
20
+ format.html { @data = resource }
21
+
22
+ format.json do
23
+ render json: resource.to_json
24
+ end
25
+ end
26
+
27
+ in Dry::Monads::Success(*list)
28
+ respond_to do |format|
29
+ format.html { @data = list }
30
+
31
+ format.json do
32
+ render json: list.to_json
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ <%% @data.each do |page| %>
2
+ <h1><%%= page.title %></h1>
3
+ <p><%%= page.content %></p>
4
+ <%% end %>
@@ -0,0 +1,16 @@
1
+ module Pages
2
+ class Index < ApplicationInteractor
3
+ def call(_params, **)
4
+ pages = yield obtain_pages
5
+
6
+ Success(pages)
7
+ end
8
+
9
+ def obtain_pages
10
+ Success([
11
+ OpenStruct.new(id: '1', title: 'Page Title 1', content: 'Page Content 1'),
12
+ OpenStruct.new(id: '2', title: 'Page Title 2', content: 'Page Content 2')
13
+ ])
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class PagesController < FallbackController
2
+ def index
3
+ handle_with Pages::Index
4
+ end
5
+
6
+ def show
7
+ handle_with Pages::Show, params: params
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ <h1><%%= @data.title %></h1>
2
+ <p><%%= @data.content %></p>
@@ -0,0 +1,20 @@
1
+ module Pages
2
+ class Show < ApplicationInteractor
3
+ def call(params, **)
4
+ pages = yield find_page(params[:id])
5
+
6
+ Success(pages)
7
+ end
8
+
9
+ def find_page(id)
10
+ case id
11
+ in '1'
12
+ Success(OpenStruct.new(id: '1', title: 'Page Title 1', content: 'Page Content 1'))
13
+ in '2'
14
+ Success(OpenStruct.new(id: '2', title: 'Page Title 2', content: 'Page Content 2'))
15
+ else
16
+ Failure(:not_found)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Granule
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.8'
5
5
  RAILS_VERSION = '6.0.2'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Bykov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-24 00:00:00.000000000 Z
11
+ date: 2020-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,18 +84,46 @@ dependencies:
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '0.78'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '0.78'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-performance
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.37'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.37'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ruby-debug-ide
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -109,7 +137,7 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: rubocop-rspec
140
+ name: debase
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -122,7 +150,7 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
- description: Rails apps bootstrapper.
153
+ description: Opinionated Rails App Bootstrapper aimed to even faster prototyping
126
154
  email:
127
155
  - leksster@gmail.com
128
156
  executables:
@@ -130,11 +158,15 @@ executables:
130
158
  extensions: []
131
159
  extra_rdoc_files: []
132
160
  files:
161
+ - ".devcontainer/Dockerfile"
162
+ - ".devcontainer/devcontainer.json"
163
+ - ".devcontainer/docker-compose.yml"
133
164
  - ".github/workflows/ruby.yml"
134
165
  - ".gitignore"
135
166
  - ".rspec"
136
167
  - ".rubocop.yml"
137
168
  - ".travis.yml"
169
+ - ".vscode/launch.json"
138
170
  - CODE_OF_CONDUCT.md
139
171
  - Gemfile
140
172
  - LICENSE.txt
@@ -177,8 +209,16 @@ files:
177
209
  - lib/granule/new/base/Dockerfile.dev.tt
178
210
  - lib/granule/new/base/Gemfile.tt
179
211
  - lib/granule/new/base/README.md.tt
212
+ - lib/granule/new/base/application_interactor.rb.tt
180
213
  - lib/granule/new/base/database.yml.tt
181
214
  - lib/granule/new/base/docker-compose.yml.tt
215
+ - lib/granule/new/base/dry.rb.tt
216
+ - lib/granule/new/base/fallback_controller.rb.tt
217
+ - lib/granule/new/base/index.html.erb.tt
218
+ - lib/granule/new/base/index.rb.tt
219
+ - lib/granule/new/base/pages_controller.rb.tt
220
+ - lib/granule/new/base/show.html.erb.tt
221
+ - lib/granule/new/base/show.rb.tt
182
222
  - lib/granule/version.rb
183
223
  homepage: http://github.com/leksster/granule
184
224
  licenses:
@@ -203,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
243
  - !ruby/object:Gem::Version
204
244
  version: '0'
205
245
  requirements: []
206
- rubygems_version: 3.0.3
246
+ rubygems_version: 3.1.2
207
247
  signing_key:
208
248
  specification_version: 4
209
249
  summary: Rails apps bootstrapper.