bootstrap_form 5.4.0 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer.json +38 -0
  3. data/.github/workflows/ruby.yml +19 -7
  4. data/.gitignore +21 -7
  5. data/.rubocop.yml +25 -15
  6. data/CHANGELOG.md +3 -0
  7. data/CONTRIBUTING.md +53 -111
  8. data/DOCKER.md +95 -0
  9. data/Gemfile +7 -1
  10. data/README.md +166 -100
  11. data/RELEASING.md +4 -10
  12. data/Rakefile +34 -16
  13. data/bootstrap_form.gemspec +1 -1
  14. data/compose.yml +36 -0
  15. data/gemfiles/7.2.gemfile +10 -0
  16. data/gemfiles/8.0.gemfile +10 -0
  17. data/gemfiles/8.1.gemfile +9 -0
  18. data/gemfiles/common.gemfile +10 -9
  19. data/gemfiles/edge.gemfile +5 -1
  20. data/lib/bootstrap_form/action_view_extensions/form_helper.rb +6 -6
  21. data/lib/bootstrap_form/components/labels.rb +17 -13
  22. data/lib/bootstrap_form/components/validation.rb +6 -3
  23. data/lib/bootstrap_form/configuration.rb +17 -2
  24. data/lib/bootstrap_form/engine.rb +12 -0
  25. data/lib/bootstrap_form/form_builder.rb +14 -6
  26. data/lib/bootstrap_form/form_group.rb +4 -4
  27. data/lib/bootstrap_form/form_group_builder.rb +17 -8
  28. data/lib/bootstrap_form/helpers/bootstrap.rb +15 -9
  29. data/lib/bootstrap_form/helpers/field.rb +2 -0
  30. data/lib/bootstrap_form/inputs/base.rb +11 -6
  31. data/lib/bootstrap_form/inputs/check_box.rb +13 -6
  32. data/lib/bootstrap_form/inputs/collection_check_boxes.rb +3 -8
  33. data/lib/bootstrap_form/inputs/collection_radio_buttons.rb +1 -0
  34. data/lib/bootstrap_form/inputs/file_field.rb +1 -1
  35. data/lib/bootstrap_form/inputs/inputs_collection.rb +67 -11
  36. data/lib/bootstrap_form/inputs/radio_button.rb +2 -1
  37. data/lib/bootstrap_form/inputs/range_field.rb +1 -1
  38. data/lib/bootstrap_form/inputs/rich_text_area.rb +2 -0
  39. data/lib/bootstrap_form/inputs/submit.rb +3 -1
  40. data/lib/bootstrap_form/inputs/text_area.rb +2 -0
  41. data/lib/bootstrap_form/inputs/time_zone_select.rb +1 -1
  42. data/lib/bootstrap_form/version.rb +4 -2
  43. data/lib/bootstrap_form.rb +4 -15
  44. metadata +17 -18
  45. data/.yarnrc +0 -5
  46. data/Dockerfile +0 -22
  47. data/docker-compose-system-test.yml +0 -45
  48. data/docker-compose.yml +0 -29
  49. data/gemfiles/6.1.gemfile +0 -4
  50. data/gemfiles/7.0.gemfile +0 -5
  51. data/gemfiles/7.1.gemfile +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f83f141afb358e5297da435acb97a61de05d38ba70493ce820a0679f002eab41
4
- data.tar.gz: edf0410f0a0239f36c0ea4a779e235cc5ee494a2efa2d9ecda2875222c1ba1fe
3
+ metadata.gz: '080b03659b41c88ebbce90498ef35b440c8f41f557b290369a7193c3d8ae3e3e'
4
+ data.tar.gz: 6659f30906b3c7ce3b01f276b7e12dc777ef8fdd0213977aeb42dccdd7b5ef0d
5
5
  SHA512:
6
- metadata.gz: 714e076f29f7067163d28e28e373db2adb41da65d60ee41b90cdabbdd0516d337ed8353e06fad10b86138d6fcd0bc2a14ea21cf6370ef2b74e8a56e2d93052d5
7
- data.tar.gz: edf5fa822ad030d78df3a4c7b2f702406e34d956f9a8c02c0ac034fa94589fda0d0ef2a8ff2755a5fecdb15d5c9cdf27e5fdd189d2bf9d91625189681dfcd00e
6
+ metadata.gz: 4a39ff618a9f881079640c35c345a1e64e376259bad7eeaf20442a22804083ec1661b2d2babb9ef4dbcf420eb7b5681f2907dc68df20688c3234bf1ebc776a98
7
+ data.tar.gz: df4ce96547bd4e460d5e6960262c74619a377a7ae47d5dcac3e930c0a39f175a8853017e4536419a8e179c91c53930a8902a53be176c61dea2013a5cf9b492c6
@@ -0,0 +1,38 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3
+ {
4
+ "name": "bootstrap_form",
5
+
6
+ // Update the 'dockerComposeFile' list if you have more compose files or use different names.
7
+ "dockerComposeFile": ["compose.yml", "compose.override.yml"],
8
+
9
+ // The 'service' property is the name of the service for the container that VS Code should
10
+ // use. Update this value and .devcontainer/docker-compose.yml to the real service name.
11
+ "service": "web",
12
+
13
+ // The optional 'workspaceFolder' property is the path VS Code should open by default when
14
+ // connected. This is typically a file mount in .devcontainer/docker-compose.yml
15
+ "workspaceFolder": "/app",
16
+ // "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
17
+
18
+ // Features to add to the dev container. More info: https://containers.dev/features.
19
+ // "features": {},
20
+
21
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
22
+ // "forwardPorts": [],
23
+
24
+ // Uncomment the next line if you want start specific services in your Docker Compose config.
25
+ // "runServices": [],
26
+
27
+ // Uncomment the next line if you want to keep your containers running after VS Code shuts down.
28
+ "shutdownAction": "none"
29
+
30
+ // Uncomment the next line to run commands after the container is created.
31
+ // "postCreateCommand": "cat /etc/os-release",
32
+
33
+ // Configure tool-specific properties.
34
+ // "customizations": {},
35
+
36
+ // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
37
+ // "remoteUser": "reid"
38
+ }
@@ -3,19 +3,20 @@ name: Ruby
3
3
  on:
4
4
  push:
5
5
  pull_request:
6
+ workflow_dispatch:
6
7
 
7
8
  jobs:
8
9
  Lint:
9
10
  runs-on: ubuntu-latest
10
11
  env:
11
- BUNDLE_GEMFILE: gemfiles/6.1.gemfile
12
+ BUNDLE_GEMFILE: gemfiles/7.2.gemfile
12
13
  steps:
13
- - uses: actions/checkout@v3
14
+ - uses: actions/checkout@v5
14
15
  with:
15
16
  fetch-depth: 0
16
17
  - uses: ruby/setup-ruby@v1
17
18
  with:
18
- ruby-version: 3.0.6
19
+ ruby-version: 3.2
19
20
  bundler-cache: true
20
21
  # Disabled since it requires access not granted by GitHub Actions for PRs
21
22
  # - name: Danger
@@ -31,12 +32,15 @@ jobs:
31
32
  strategy:
32
33
  fail-fast: false
33
34
  matrix:
34
- ruby-version: [ '3.2', '3.1', '3.0', 'ruby-head' ]
35
- gemfile: [ '7.1', '7.0', '6.1', 'edge' ]
35
+ ruby-version: [ '3.4', '3.3', '3.2', 'ruby-head' ]
36
+ gemfile: [ '8.1', '8.0', '7.2', 'edge' ]
37
+ exclude:
38
+ - ruby-version: 3.2
39
+ - gemfile: 'edge'
36
40
  env:
37
41
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
38
42
  steps:
39
- - uses: actions/checkout@v3
43
+ - uses: actions/checkout@v5
40
44
  - name: Set up Ruby
41
45
  uses: ruby/setup-ruby@v1
42
46
  with:
@@ -47,12 +51,20 @@ jobs:
47
51
  Demo:
48
52
  runs-on: ubuntu-latest
49
53
  steps:
50
- - uses: actions/checkout@v3
54
+ - uses: actions/checkout@v5
51
55
  - name: Set up Ruby
52
56
  uses: ruby/setup-ruby@v1
53
57
  with:
54
58
  working-directory: demo
55
59
  bundler-cache: true
60
+ ruby-version: 3.4
61
+ env:
62
+ BUNDLE_GEMFILE: '../Gemfile'
56
63
  - name: Run tests
57
64
  working-directory: demo
58
65
  run: bundle exec rake test:all
66
+ # - name: Commit changed screenshots and other files
67
+ # if: failure()
68
+ # working-directory: demo
69
+ # run: bundle exec rake commit
70
+
data/.gitignore CHANGED
@@ -4,14 +4,22 @@
4
4
  .npm/_npx
5
5
 
6
6
  .idea
7
- log/*.log
8
- pkg/
7
+ /doc/
8
+ /log/*.log
9
+ /pkg/
10
+ /tmp/
11
+
9
12
  demo/db/*.sqlite3
10
13
  demo/db/*.sqlite3-shm
11
14
  demo/db/*.sqlite3-wal
12
15
  demo/doc/screenshots/**/*.diff.png
16
+ demo/doc/screenshots/**/*.base.png
13
17
  demo/log/*.log
18
+ demo/storage
14
19
  demo/tmp/
20
+
21
+ test/dummy/
22
+
15
23
  *.gem
16
24
  .rbenv-gemsets
17
25
  *.swp
@@ -21,16 +29,13 @@ gemfiles/*.lock
21
29
  /.ruby-version
22
30
  Vagrantfile
23
31
  .vagrant
32
+ .yarnrc
24
33
  **/.yarn/**/cache
25
34
  **/.yarn/install-state.gz
26
35
  **/.yarn/unplugged
27
36
 
28
37
  # For the demo app.
29
38
 
30
- # Ignore uploaded files in development.
31
- demo/storage/*
32
- !demo/storage/.keep
33
-
34
39
  demo/public/assets
35
40
  **/.byebug_history
36
41
 
@@ -47,13 +52,14 @@ demo/.yarn-integrity
47
52
  demo/vendor/bundle
48
53
 
49
54
  # For stuff that gets created if using the Dockerfile image
50
- .bundle/
55
+ /.bundle/
51
56
  .cache/
52
57
  vendor/bundle
53
58
 
54
59
  # or .local/share/pry/pry_history if you need to be more exact
55
60
  .local/
56
61
  .irb_history
62
+ .rdbg_history
57
63
  .byebug_history
58
64
  # For Debian images with Bash
59
65
  .bash_history
@@ -61,4 +67,12 @@ vendor/bundle
61
67
  .ash_history
62
68
  .sqlite_history
63
69
 
70
+ compose.override.yml
64
71
  docker-compose.override.yml
72
+
73
+ .vscode-server/
74
+ .dotnet/
75
+ .gnupg/
76
+ .ssh/
77
+ .gitconfig
78
+ .gk/
data/.rubocop.yml CHANGED
@@ -1,12 +1,12 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-performance
3
3
  - rubocop-rails
4
4
 
5
5
  AllCops:
6
6
  DisplayCopNames: true
7
7
  DisplayStyleGuide: true
8
- TargetRubyVersion: 3.0
9
- TargetRailsVersion: 6.1
8
+ TargetRubyVersion: 3.2
9
+ TargetRailsVersion: 7.2
10
10
  NewCops: enable
11
11
  Exclude:
12
12
  - bin/*
@@ -25,7 +25,7 @@ AllCops:
25
25
  - gemfiles/vendor/bundle/**/*
26
26
  - vendor/bundle/**/*
27
27
  - Guardfile
28
- - Rakefile
28
+ - test/dummy/**/*
29
29
  - vendor/**/*
30
30
 
31
31
  Layout/LineLength:
@@ -39,9 +39,7 @@ Layout/SpaceAroundEqualsInParameterDefault:
39
39
 
40
40
  Metrics/AbcSize:
41
41
  Max: 18
42
- Exclude:
43
- - "demo/test/**/*"
44
- - "test/**/*"
42
+ Enabled: false
45
43
 
46
44
  Metrics/BlockLength:
47
45
  Exclude:
@@ -56,11 +54,7 @@ Metrics/ClassLength:
56
54
  - "test/**/*"
57
55
 
58
56
  Metrics/MethodLength:
59
- Max: 12
60
- Exclude:
61
- - "demo/db/migrate/*"
62
- - "demo/test/**/*"
63
- - "test/**/*"
57
+ Enabled: false
64
58
 
65
59
  Naming/MemoizedInstanceVariableName:
66
60
  EnforcedStyleForLeadingUnderscores: optional
@@ -75,6 +69,10 @@ Rails/ApplicationRecord:
75
69
  Exclude:
76
70
  - "demo/db/migrate/**"
77
71
 
72
+ Rails/RakeEnvironment:
73
+ Exclude:
74
+ - "Rakefile"
75
+
78
76
  Rails/RefuteMethods:
79
77
  Enabled: false
80
78
 
@@ -96,9 +94,6 @@ Style/DoubleNegation:
96
94
  Style/EmptyMethod:
97
95
  Enabled: false
98
96
 
99
- Style/FrozenStringLiteralComment:
100
- Enabled: false
101
-
102
97
  Style/NumericPredicate:
103
98
  Enabled: false
104
99
 
@@ -107,3 +102,18 @@ Style/StringLiterals:
107
102
 
108
103
  Style/TrivialAccessors:
109
104
  AllowPredicates: true
105
+
106
+ Style/FrozenStringLiteralComment:
107
+ Enabled: true
108
+ EnforcedStyle: always # or 'always' or 'never' depending on your preference
109
+ SafeAutoCorrect: true # Set to true for safe autocorrection, false if you need to review changes
110
+ Exclude:
111
+ - ./**/Gemfile*
112
+ - bootstrap_form.gemspec
113
+ - Dangerfile
114
+ - demo/config/**/*
115
+ - demo/config.ru
116
+ - demo/db/migrate/**/*
117
+ - gemfiles/*
118
+ - Rakefile
119
+ - Vagrantfile
data/CHANGELOG.md CHANGED
@@ -6,6 +6,8 @@ https://github.com/bootstrap-ruby/bootstrap_form/releases
6
6
 
7
7
  ## Diffs
8
8
 
9
+ - [5.5.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.4.0...v5.5.0)
10
+ [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2023-10-30T00A00..2025-10-30T00)
9
11
  - [5.4.0](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.3.2...v5.4.0)
10
12
  [Closed issues](https://github.com/bootstrap-ruby/bootstrap_form/issues?q=closed%3A2023-09-15T21%3A00..2023-10-30T00)
11
13
  - [5.3.2](https://github.com/bootstrap-ruby/bootstrap_form/compare/v5.3.1...v5.3.2)
@@ -57,6 +59,7 @@ The tooling to support our old way of doing the change log doesn't work anymore,
57
59
  * [#573](https://github.com/bootstrap-ruby/bootstrap_form/issues/573): Add support for Bootstrap 5's floating labels
58
60
 
59
61
  * [#215](https://github.com/bootstrap-ruby/bootstrap_form/issues/215): Add `include_hidden` option to `check_box`
62
+
60
63
  ### Bugfixes
61
64
 
62
65
  * [#582](https://github.com/bootstrap-ruby/bootstrap_form/issues/582): Fix tests in bootstrap-5 branch, removes Rubocop offenses, and adds testing with Rails 6.1.
data/CONTRIBUTING.md CHANGED
@@ -6,9 +6,26 @@ We want everyone to feel welcome to contribute. We encourage respectful exchange
6
6
 
7
7
  There are a number of ways you can contribute to `bootstrap_form`:
8
8
 
9
- - Fix a bug or add a new feature
10
- - Add to the documentation
11
- - Review pull requests
9
+ - Test pre-release versions of the gem, by using the `main` branch.
10
+ - Fix a bug or add a new feature.
11
+ - Add to the documentation.
12
+ - Review pull requests.
13
+
14
+ ## Testing
15
+
16
+ `bootstrap_form` has an extensive automated test suite. But there are a multitude of combinations of use cases for this gem. It's impossible to cover all the combinations.
17
+
18
+ You can help us test by using the `main` branch from GitHub, rather than a released version of the gem. To do so, replace the `bootstrap_form` line in your `Gemfile` with:
19
+
20
+ ```
21
+ gem "bootstrap_form", git: "https://bootstrap-ruby/bootstrap_form"
22
+ ```
23
+
24
+ and run `bundle update`.
25
+
26
+ If you run into problems, you can always switch back to the released version of `bootstrap_form` from your provider of gems. Please [raise an issue](https://github.com/bootstrap-ruby/bootstrap_form/issues/new/choose) if you think you found a problem.
27
+
28
+ And a big thank-you for helping us test `bootstrap_form`.
12
29
 
13
30
  ## Code Contributions
14
31
 
@@ -50,140 +67,65 @@ You may find the [demo application](#the-demo-application) useful for developmen
50
67
  - If your PR fixes an issues, be sure to put "Fixes #nnn" in the description of the PR (where `nnn` is the issue number). Github will automatically close the issue when the PR is merged.
51
68
  - When the PR is submitted, check if GitHub Actions ran all the tests successfully, and didn't raise any issues.
52
69
 
53
- ### 7. Done
54
-
55
- Somebody will shortly review your pull request and if everything is good, it will be
56
- merged into the main branch. Eventually the gem will be published with your changes.
57
-
58
- ### Coding guidelines
59
-
60
- This project uses [RuboCop](https://github.com/bbatsov/rubocop) to enforce standard Ruby coding
61
- guidelines.
62
-
63
- - Test that your contribution passes with `rake rubocop`.
64
- - RuboCop is also run as part of the full test suite with `bundle exec rake`.
65
- - Note the Travis build will fail and your PR cannot be merged if RuboCop finds offences.
66
-
67
- Note that most editors have plugins to run RuboCop as you type, or when you save a file. You may find it well worth your time to install and configure the RuboCop plugin for your editor. Read the [RuboCop documentation](https://rubocop.readthedocs.io/en/latest/integration_with_other_tools/).
68
-
69
- ### Supported Versions of Ruby and Rails
70
-
71
- The goal of `bootstrap_form` is to support all versions of Rails currently supported for bug fixes and security issues. We do not test against versions supported for severe security issues. We test against the minimum [version of Ruby required](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#ruby-versions) for those versions of Rails.
72
-
73
- The Ruby on Rails support policy is [here](https://guides.rubyonrails.org/maintenance_policy.html).
74
-
75
- ### Developing with Docker
76
-
77
- This repository offers experimental support support for a couple of ways to develop using Docker, if you're interested:
78
-
79
- - Using `docker-compose`. This way is less tested, and is an attempt to make the Docker container a more complete environment where you can conveniently develop and release the gem.
80
- - Using just a simple Dockerfile. This way works for simple testing, but doesn't make it easy to release the gem, among other things.
70
+ When you create or update a pull request, GitHub automatically runs tests that generate the screenshots in the [`README.md`](/README.md). If any of the screenshots change, GitHub will add an additional commit to your branch, with the updated screenshots.
81
71
 
82
- Docker is _not_ required to work on this gem.
72
+ Normally, the screenshots should _not_ change. If the screenshots changed, please review them _carefully_. Some clear reasons why you would want to keep the changed screenshots:
83
73
 
84
- #### Using `docker-compose`
74
+ - Your PR was fixing behaviour that was wrong in the screenshot.
75
+ - You added new examples in the documentation, so there are new screenshots.
76
+ - A change to the images used by GitHub in their actions changes the behaviour of Chrome, although if you think it's this you should probably prepare a separate PR that _only_ updates the screenshots, so it's clear what the change is and why we're making the change.
85
77
 
86
- The `docker-compose` approach should link to enough of your networking configuration that you can release the gem.
87
- However, you have to do some of the configuration yourself, because it's dependent on your host operating system.
88
-
89
- First, build the image for whatever version of Ruby you need (typically either the earliest supported version or the latest):
78
+ Unless you have one of the above reasons, or you have a good explanation for why the screenshots have changed with your PR, you need to get rid of the changed screenshots (i.e. revert the last commit) and fix your PR so the screenshots don't change. (The reason you should revert the commit with the screenshots is so that the next time you push, GitHub will compare against the original screenshots, not the ones changed by your previous push.) Here's how to get rid of the changed screenshots:
90
79
 
91
80
  ```bash
92
- RUBY_VERSION=3.2 docker-compose build
81
+ git pull # to bring the additional commit to your local branch.
82
+ git revert HEAD # to remove the changes.
93
83
  ```
94
84
 
95
- You can run a shell in a Docker container that pretty much should behave like a Debian distribution with:
85
+ Then fix the code and push your branch again.
96
86
 
97
- ```bash
98
- docker-compose run --service-ports shell
99
- ```
100
-
101
- (`--service-ports` exposes port 3000 so you can browse to the demo app on `localhost:3000`. If you just want to run a one-off command, or run the test suite, leave off the `--service-ports`.)
102
-
103
- The following instructions work for an Ubuntu host, and will probably work for other common Linux distributions.
104
-
105
- Add a `docker-compose.override.yml` in the local directory, that looks like this:
106
-
107
- ```docker-compose.yml
108
- version: '3.3'
109
-
110
- # https://blog.giovannidemizio.eu/2021/05/24/how-to-set-user-and-group-in-docker-compose/
111
-
112
- services:
113
- shell:
114
- # You have to set the user and group for this process, because you're going to be
115
- # creating all kinds of files from inside the container, that need to persist
116
- # outside the container.
117
- # Change `1000:1000` to the user and default group of your laptop user.
118
- user: 1000:1000
119
- volumes:
120
- - /etc/passwd:/etc/passwd:ro
121
- - ~/.gem/credentials:/app/.gem/credentials:ro
122
- # $HOME here is your host computer's `~`, e.g. `/home/reid`.
123
- # `ssh` explicitly looks for its config in the home directory from `/etc/passwd`,
124
- # so the target for this has to look like your home directory on the host.
125
- - ~/.ssh:${HOME}/.ssh:ro
126
- - ${SSH_AUTH_SOCK}:/ssh-agent
127
- environment:
128
- - SSH_AUTH_SOCK=/ssh-agent
129
- ```
87
+ If the change was intended, a comment in the PR explaing why the change is expected would be very much appreciated. More than appreciated. It will avoid us having to ask you for an explanation.
130
88
 
131
- You may have to change the `1000:1000` to the user and group IDs of your laptop. You may also have to change the `version` parameter to match the version of the `docker-compose.yml` file.
132
-
133
- Adapting the above `docker-compose.override.yml` for MacOS should be relatively straight-forward. Windows users, I'm afraid you're on your own. If you figure this out, a PR documenting how to do it would be most welcome.
134
-
135
- The above doesn't allow you to run the system tests. To keep the image small, it doesn't include Chrome or any other browser.
136
-
137
- There is an experimental `docker-compose-system-test.yml` file, that runs the `bootstrap_forms` docker container along with an off-the-shelf Selenium container. To start this configuration:
138
-
139
- ```bash
140
- RUBY_VERSION=3.2 docker-compose -f docker-compose-system-test.yml -f docker-compose.override.yml up&
141
- RUBY_VERSION=3.2 docker-compose -f docker-compose-system-test.yml -f docker-compose.override.yml exec shell /bin/bash
142
- ```
143
-
144
- (Sometimes, on shutdown, the Rails server PID file isn't removed, and so the above will fail. `rm demo/tmp/pids/server.pid` will fix it.)
145
-
146
- Once in the shell:
89
+ You can run the tests that generate the screenshots locally, but unless your environment is very much like the GitHub CI environment -- Ubuntu running Chrome with default fonts -- all the screenshots will be reported as having changed. To generate the screenshots:
147
90
 
148
91
  ```bash
149
92
  cd demo
150
- bundle exec rails test:system
93
+ bundle exec rails test:all # or test:system
151
94
  ```
152
95
 
153
- Note that this system test approach is highly experimental and has some rough edges. The docker compose file and/or steps to run system tests may change. The tests currently fail, because the files with which they're being compared were generated on a Mac, but the Docker containers are running Linux.
96
+ The [Docker development environment](#developing-with-docker) appears to generate screenshots that are the same as what GitHub generates.
154
97
 
155
- #### Simple Dockerfile
98
+ Finally, maintainers may sometimes push changes directly to `main` or use other workflows to update the code. If pushing to `main` generates a commit for screenshot changes, please consider reverting your change immediately by executing the above `pull` and `revert` and another `push`, for the sanity of users who are using the edge (`main` branch) version of the gem. At any rate, review the changes promptly and use your judgement.
156
99
 
157
- This repository includes a `Dockerfile` to build an image with the minimum `bootstrap_form`-supported Ruby environment. To build the image:
100
+ ### 7. Done
158
101
 
159
- ```bash
160
- docker build --tag bootstrap_form .
161
- ```
102
+ Somebody will shortly review your pull request and if everything is good, it will be
103
+ merged into the main branch. Eventually the gem will be published with your changes.
162
104
 
163
- This builds an image called `bootstrap_form`. You can change that to any tag you wish. Just make sure you use the same tag name in the `docker run` command.
105
+ ### Coding guidelines
164
106
 
165
- If you want to use a different Ruby version, or a smaller Linux distribution (although the distro may be missing tools you need):
107
+ This project uses [RuboCop](https://github.com/bbatsov/rubocop) to enforce standard Ruby coding
108
+ guidelines.
166
109
 
167
- ```bash
168
- docker build --build-arg "RUBY_VERSION=3.0" --build-arg "DISTRO=slim-buster" --tag bootstrap_form .
169
- ```
110
+ - Test that your contribution passes with `rake rubocop`.
111
+ - RuboCop is also run as part of the full test suite with `bundle exec rake`.
112
+ - Note the Travis build will fail and your PR cannot be merged if RuboCop finds offences.
170
113
 
171
- Then run the container you built with the shell, and create the bundle:
114
+ Note that most editors have plugins to run RuboCop as you type, or when you save a file. You may find it well worth your time to install and configure the RuboCop plugin for your editor. Read the [RuboCop documentation](https://rubocop.readthedocs.io/en/latest/integration_with_other_tools/).
172
115
 
173
- ```bash
174
- docker run --volume "$PWD:/app" --user $UID:`grep ^$USERNAME /etc/passwd | cut -d: -f4` -it bootstrap_form /bin/bash
175
- bundle install
176
- ```
116
+ ### Supported Versions of Ruby and Rails
177
117
 
178
- You can run tests in the container as normal, with `rake test`.
118
+ The goal of `bootstrap_form` is to support all versions of Rails currently supported for bug fixes and security issues. We do not test against versions supported for severe security issues. We test against the minimum [version of Ruby required](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#ruby-versions) for those versions of Rails.
119
+
120
+ The Ruby on Rails support policy is [here](https://guides.rubyonrails.org/maintenance_policy.html).
179
121
 
180
- (Some of that command line is need for Linux hosts, to run the container as the current user.)
122
+ ### Developing with Docker
181
123
 
182
- One of the disadvantages of this approach is that you can't release the gem from here, because the Docker container doesn't have access to your SSH credentials, or the right user name, or perhaps other things needed to release a gem. But for simple testing, it works.
124
+ This repository offers experimental support for development using Docker. Docker is _not_ required to do development work on this gem.
183
125
 
184
- #### Troubleshooting Docker
126
+ One advantage of the Docker environment is that it allows you to generate and compare the screenshots with the expected screenshots in the repo. It also allows you to develop in an environment that is isolated from your own computer's set-up, so there's less risk of breaking other things you might be doing with your computer.
185
127
 
186
- - With the above configuration, the gems are kept in `vendor/bundle` on your hosts, which is `$GEM_HOME` or `/app/vendor/bundle` in the running Docker container. If you're having permission problems when switching versions of Ruby or Rails, you can try `sudo rm -rf vendor/bundle` on the host, then run `BUNDLE_GEMFILES=gemfiles/7.0.gemfile bundle update` in the Docker container to re-install all the gems with the right permissions.
128
+ If you're intested in trying the Docker approach, read the [documentation](DOCKER.md).
187
129
 
188
130
  ### The Demo Application
189
131
 
@@ -226,7 +168,7 @@ Please try to keep the checked-in `.ruby-version` set to the oldest supported ve
226
168
  For the record, the demo app is set up as if the Rails app had been created with:
227
169
 
228
170
  ```sh
229
- rails new --skip-hotwire -d sqlite --edge -j esbuild -c bootstrap .
171
+ rails new -d sqlite --edge -j esbuild -c bootstrap .
230
172
  ```
231
173
 
232
174
  This means it's using `esbuild` to pre-process the JavaScript and (S)CSS, and that it's using [`jsbunding-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails) to put the assets in `app/assets/builds`, before the Sprockets assets pipeline serves them in development, or pre-compiles them in production.
data/DOCKER.md ADDED
@@ -0,0 +1,95 @@
1
+ # Working With Docker
2
+
3
+ This repository offers experimental support support for developing using Docker, if you're interested. Docker is _not_ required to work on this gem.
4
+
5
+ The `docker compose` approach should link to enough of your networking configuration that you can release the gem.
6
+ However, you have to do some of the configuration yourself, because it's dependent on your host operating system.
7
+
8
+ ## Set-Up
9
+
10
+ Put your personal and OS-specific configuration in a `compose.override.yml` file.
11
+
12
+ The following instructions work for an Ubuntu host, and will probably work for other common Linux distributions. Add a `compose.override.yml` in the local directory, that looks like this:
13
+
14
+ ```compose.override.yml
15
+ # https://blog.giovannidemizio.eu/2021/05/24/how-to-set-user-and-group-in-docker compose/
16
+
17
+ services:
18
+ web:
19
+ # You have to set the user and group for this process, because you're going to be
20
+ # creating all kinds of files from inside the container, that need to persist
21
+ # outside the container.
22
+ # Change `1000:1000` to the user and default group of your laptop user.
23
+ user: 1000:1000
24
+ volumes:
25
+ - /etc/passwd:/etc/passwd:ro
26
+ - ~/.gem/credentials:/app/.gem/credentials:ro
27
+ # $HOME here is your host computer's `~`, e.g. `/home/reid`.
28
+ # `ssh` explicitly looks for its config in the home directory from `/etc/passwd`,
29
+ # so the target for this has to look like your home directory on the host.
30
+ - ~/.ssh:${HOME}/.ssh:ro
31
+ - ${SSH_AUTH_SOCK}:/ssh-agent
32
+ environment:
33
+ - SSH_AUTH_SOCK=/ssh-agent
34
+ ```
35
+
36
+ You may have to change the `1000:1000` to the user and group IDs of your laptop. You may also have to change the `version` parameter to match the version of the `docker compose.yml` file.
37
+
38
+ Adapting the above `compose.override.yml` for MacOS should be relatively straight-forward. Windows users, I'm afraid you're on your own. If you figure this out, a PR documenting how to do it would be most welcome.
39
+
40
+ ## Running
41
+
42
+ Start the containers:
43
+
44
+ ```bash
45
+ docker compose up -d
46
+ ```
47
+
48
+ You may need to install or update the gems:
49
+
50
+ ```bash
51
+ docker compose exec web bundle install
52
+ ```
53
+
54
+ To get a shell in the container:
55
+
56
+ ```bash
57
+ docker compose exec web /bin/bash
58
+ ```
59
+
60
+ Once in the shell, run tests:
61
+
62
+ ```bash
63
+ bundle exec rake test
64
+ ```
65
+
66
+ Run the demo app and browse to it:
67
+
68
+ ```bash
69
+ cd demo
70
+ bin/dev
71
+ ```
72
+
73
+ On the host, not the Docker container, get the port number(s) you can use in the browser to access the test app running in the Docker container:
74
+
75
+ ```bash
76
+ docker compose port web 3001 | cut -d: -f 2 # Browser
77
+ docker compose port web 7900 | cut -d: -f 2 # To watch the browser execute system tests.
78
+ ```
79
+
80
+ Browse to `localhost:<port number from above>`.
81
+
82
+ Run system tests:
83
+
84
+ ```bash
85
+ cd demo
86
+ bundle exec rails test:system
87
+ ```
88
+
89
+ Note that this system test approach is highly experimental and has some rough edges. The docker compose file and/or steps to run system tests may change.
90
+
91
+ ## Troubleshooting Docker
92
+
93
+ - With the above configuration, the gems are kept in `vendor/bundle` on your hosts, which is `$GEM_HOME` or `/app/vendor/bundle` in the running Docker container. If you're having permission problems when switching versions of Ruby or Rails, you can try `sudo rm -rf vendor/bundle` on the host, then run `BUNDLE_GEMFILES=gemfiles/7.0.gemfile bundle update` in the Docker container to re-install all the gems with the right permissions.
94
+ - Sometimes, on shutdown, the Rails server PID file isn't removed, and so the above will fail. `rm demo/tmp/pids/server.pid` will fix it.
95
+
data/Gemfile CHANGED
@@ -3,5 +3,11 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
3
3
 
4
4
  require "#{__dir__}/lib/bootstrap_form/version"
5
5
 
6
+ gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
7
+ gem "cssbundling-rails"
8
+ gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
9
+ gem "jsbundling-rails"
10
+ gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
6
11
  gem "rails", BootstrapForm::REQUIRED_RAILS_VERSION
7
- gem "sprockets-rails", require: "sprockets/railtie"
12
+ gem "propshaft"
13
+ gem "sqlite3"