bs5 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 37f7ba7e614cc623e4041e6caf107313059069c11915bcaaa0b00b2a95ad9810
4
+ data.tar.gz: 7f150ed58e6820999d63483763cf17b4f836980acd7b6d63b3a3aef272d05067
5
+ SHA512:
6
+ metadata.gz: 7f7c2230879f59f7743bc0b89d4fadf09ea9bf887cb8b0bb68bd1f8a9617123dc9a47f6a5d2ee783ce57d6a11a6457d3e3b4796ce146bb09d639d6c5fd9a4c8c
7
+ data.tar.gz: 4a69710e2d7129473e5f0423dc27a7d359ee43982190d25f31e7da3167851f133ea3829a4151b75259b6717d29d9faa0bb1416eae31ea33813283139e5d00825
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Patrick Baselier
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.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Bs5
2
+
3
+ This is a Ruby on Rails engine to include [Bootstrap 5](https://v5.getbootstrap.com/).
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/bs5.svg)](https://badge.fury.io/rb/bs5)
6
+
7
+ ## Usage
8
+
9
+ How to use my plugin.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'bs5'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```bash
28
+ $ gem install bs5
29
+ ```
30
+
31
+ ## Configuration
32
+
33
+ Run the following command to setup your project to use Bootstrap 5.
34
+
35
+ $ rails generate bs5:install
36
+
37
+ ## Components
38
+
39
+ ### Alert 🖌
40
+
41
+ ```
42
+ <%= render Bs5::AlertComponent.new do %>
43
+ A simple primary alert—check it out!
44
+ <%- end %>
45
+ ```
46
+
47
+ ```
48
+ <%= render Bs5::AlertComponent.new(type: :warning, is_dismissable: true) do %>
49
+ <strong>Holy guacamole!</strong> You should check in on some of those fields below.
50
+ <%- end %>
51
+ ```
52
+
53
+ ## Previewing components
54
+
55
+ * http://localhost:3000/rails/view_components
56
+
57
+ ## Contributing
58
+
59
+ Contribution directions go here.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Bs5'
14
+ rdoc.options << '--line-numbers'
15
+ rdoc.rdoc_files.include('README.md')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
20
+ load 'rails/tasks/engine.rake'
21
+
22
+ load 'rails/tasks/statistics.rake'
23
+
24
+ require 'bundler/gem_tasks'
25
+
26
+ require 'rake/testtask'
27
+
28
+ Rake::TestTask.new(:test) do |t|
29
+ t.libs << 'test'
30
+ t.pattern = 'test/**/*_test.rb'
31
+ t.verbose = false
32
+ end
33
+
34
+ task default: :test
data/app/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - Add generator for installing `bs5`.
13
+ - Add ViewComponent for Alert component.
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/bs5 .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ <div class="<%= component_class %>" role="alert">
2
+ <%= content %>
3
+ <%- if is_dismissable %>
4
+ <button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
5
+ <%- end %>
6
+ </div>
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ class AlertComponent < ViewComponent::Base
5
+ TYPES = %i[primary secondary success danger warning info light dark].freeze
6
+
7
+ include ActiveModel::Validations
8
+
9
+ attr_reader :type, :is_dismissable
10
+
11
+ validates :type, inclusion: { in: TYPES, message: lambda do |_, data|
12
+ "#{data[:value].inspect} is not valid. Try #{TYPES.to_sentence(last_word_connector: ' or ')}."
13
+ end }
14
+
15
+ def initialize(type: :primary, is_dismissable: false)
16
+ @type = type.to_sym
17
+ @is_dismissable = is_dismissable
18
+ end
19
+
20
+ def before_render
21
+ raise errors.full_messages.to_sentence if invalid?
22
+ end
23
+
24
+ private
25
+
26
+ def component_class
27
+ class_names = ['alert', contextual_class]
28
+ class_names << %w[alert-dismissible fade show] if is_dismissable
29
+ class_names.join(' ')
30
+ end
31
+
32
+ def contextual_class
33
+ "alert-#{@type}"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Bs5
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Bs5
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Bs5
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Bs5
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Bs5
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Bs5</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "bs5/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Bs5::Engine.routes.draw do
2
+ end
data/lib/bs5.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "bs5/engine"
2
+
3
+ module Bs5
4
+ # Your code goes here...
5
+ end
data/lib/bs5/engine.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'view_component/engine'
4
+ module Bs5
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Bs5
7
+
8
+ # Previewing ViewComponents
9
+ config.before_configuration do |app|
10
+ app.config.view_component.preview_paths << "#{Bs5::Engine.root}/spec/components/previews"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs5
4
+ VERSION = '0.0.2'
5
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate install Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Bs5::InstallGenerator < Rails::Generators::Base
4
+ def add_bootstrap
5
+ run 'yarn add bootstrap@next popper.js'
6
+
7
+ create_file 'app/javascript/packs/styles.scss', <<~HEREDOC
8
+ @import "~bootstrap/scss/bootstrap";
9
+ HEREDOC
10
+
11
+ inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do
12
+ <<~HEREDOC
13
+ <%= stylesheet_pack_tag 'styles', media: 'all', 'data-turbolinks-track': 'reload' %>
14
+ HEREDOC
15
+ end
16
+
17
+ append_file 'app/javascript/packs/application.js', <<~HEREDOC
18
+ import "bootstrap";
19
+ HEREDOC
20
+
21
+ gsub_file 'config/webpacker.yml', 'extract_css: false', 'extract_css: true'
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bs5 do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bs5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Baselier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-15 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: 6.0.3
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.3.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.3
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.3.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: view_component
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 2.22.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.22.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 4.0.1
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 4.0.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: capybara
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.33'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.33'
89
+ description: "[WIP] Rails engine to include Bootstrap 5."
90
+ email:
91
+ - patrick.baselier@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - MIT-LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - app/CHANGELOG.md
100
+ - app/assets/config/bs5_manifest.js
101
+ - app/assets/stylesheets/bs5/application.css
102
+ - app/components/bs5/alert_component.html.erb
103
+ - app/components/bs5/alert_component.rb
104
+ - app/controllers/bs5/application_controller.rb
105
+ - app/helpers/bs5/application_helper.rb
106
+ - app/jobs/bs5/application_job.rb
107
+ - app/mailers/bs5/application_mailer.rb
108
+ - app/models/bs5/application_record.rb
109
+ - app/views/layouts/bs5/application.html.erb
110
+ - config/routes.rb
111
+ - lib/bs5.rb
112
+ - lib/bs5/engine.rb
113
+ - lib/bs5/version.rb
114
+ - lib/generators/bs5/install/USAGE
115
+ - lib/generators/bs5/install/install_generator.rb
116
+ - lib/tasks/bs5_tasks.rake
117
+ homepage: https://github.com/bazzel/bs5
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubygems_version: 3.0.3
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Bootstrap 5
140
+ test_files: []