Skip to content

Commit

Permalink
Move to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Aug 25, 2019
1 parent 1eea5c5 commit a6d8dc7
Show file tree
Hide file tree
Showing 20 changed files with 508 additions and 333 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ test/log

node_modules
yarn-error.log

!.babelrc
49 changes: 37 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ClientSideValidations-SimpleForm #

[![Gem Version](https://badge.fury.io/rb/client_side_validations-simple_form.svg)](https://badge.fury.io/rb/client_side_validations-simple_form)
[![npm version](https://badge.fury.io/js/%40client-side-validations%2Fsimple-form.svg)](https://badge.fury.io/js/%40client-side-validations%2Fsimple-form)
[![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations-simple_form.svg?branch=master)](https://travis-ci.org/DavyJonesLocker/client_side_validations-simple_form)
[![Code Climate](https://codeclimate.com/github/DavyJonesLocker/client_side_validations-simple_form/badges/gpa.svg)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations-simple_form)
[![Coverage Status](https://coveralls.io/repos/github/DavyJonesLocker/client_side_validations-simple_form/badge.svg?branch=master)](https://coveralls.io/github/DavyJonesLocker/client_side_validations-simple_form?branch=master)
Expand All @@ -22,31 +23,55 @@ required **before** `ClientSideValidations-SimpleForm`.

[Follow the remaining installation instructions for ClientSideValidations](https://github.com/DavyJonesLocker/client_side_validations/blob/master/README.md)

According to the web framework you are using, add **one** of the following lines to `app/assets/javascripts/application.js`
### JavaScript file ###

```javascript
Instructions depend on your technology stack.

#### When using Webpacker ####

Make sure that you are requiring jQuery and Client Side Validations.

Add the following package:

```sh
yarn add @client-side-validations/simple-form
```

Then, according to the web framework you are using, add **one** of the following
lines to your `app/javascript/packs/application.js` pack, **after**
`import '@client-side-validations/client-side-validations'`:

```js
// No framework / Generic frameworks / Bootstrap 3
//= require rails.validations.simple_form
import '@client-side-validations/simple-form'

// Bootstrap 4
//= require rails.validations.simple_form.bootstrap4
import '@client-side-validations/simple-form/dist/simple-form.bootstrap4'
```

Again, order matters. You should add this line after the require for `rails.validations` as described in the `ClientSideValidations` installation instructions.
#### When using Sprockets ####

If the asset pipeline is disabled the asset file will be copied
into `public/javascripts` when the `ClientSideValidations` install generator is run.
Make sure that you are requiring jQuery and Client Side Validations.

According to the web framework you are using, add **one** of the following
lines to your `app/assets/javascripts/application.js`, **after**
`//= require rails.validations`

```js
// No framework / Generic frameworks / Bootstrap 3
//= require rails.validations.simple_form

// Bootstrap 4
//= require rails.validations.simple_form.bootstrap4
```

At any time you can copy the asset file into your project by running:
If you need to copy the asset files from the gem into your project, run:

```
rails g client_side_validations:copy_assets
```

If the asset pipeline is disabled the asset file will be copied
into `public/javascripts`. Otherwise the asset file will be copied into
`app/assets/javascripts` (or whatever asset directory you have
defined)
Note: If you run `copy_assets`, you will need to run it again each time you update this project.

## Usage ##

Expand Down
34 changes: 7 additions & 27 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'bundler'
require File.join(File.expand_path(__dir__), 'coffeescript/processor')
Bundler::GemHelper.install_tasks
require 'rubocop/rake_task'

Expand All @@ -22,7 +21,7 @@ namespace :test do
end

desc %(Test Javascript code)
multitask js: ['test:server', 'test:open']
multitask js: ['regenerate_javascript', 'test:server', 'test:open']

desc %(Starts the test server)
task :server do
Expand All @@ -42,43 +41,24 @@ namespace :test do
end
end

desc %(Regenerate JavaScript file)
desc %(Regenerate JavaScript files)
task :regenerate_javascript do
regenerate_javascript
system 'yarn build'
end

desc %(Commit JavaScript file)
desc %(Commit JavaScript files)
task :commit_javascript do
perform_git_commit
end

def perform_git_commit
sh_with_code('git add vendor')
_, code = sh_with_code('git commit -m "Regenerated JavaScript"')
# rubocop:disable NumericPredicate
if code == 0
system('git add dist vendor', out: File::NULL, err: File::NULL)

if system('git commit -m "Regenerated JavaScript files"', out: File::NULL, err: File::NULL)
puts 'Committed changes'
else
puts 'Nothing to commit'
end
# rubocop:enable NumericPredicate
end

def regenerate_javascript
ClientSideValidations::Processor.run
puts 'Regenerated JavaScript'
end

def sh_with_code(frozen_cmd, &block)
cmd = frozen_cmd.dup
cmd << ' 2>&1'
outbuf = ''
Bundler.ui.debug(cmd)
Dir.chdir(Dir.pwd) do
outbuf = `#{cmd}`
yield outbuf if $CHILD_STATUS == 0 && block
end
[outbuf, $CHILD_STATUS]
end

PORT = 4567
Expand Down
1 change: 0 additions & 1 deletion client_side_validations-simple_form.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'simplecov', '~> 0.17.0'

# For QUnit testing
spec.add_development_dependency 'coffee-script', '~> 2.4'
spec.add_development_dependency 'shotgun', '~> 0.9.2'
spec.add_development_dependency 'sinatra', '~> 2.0'
spec.add_development_dependency 'thin', '~> 1.7'
Expand Down
135 changes: 0 additions & 135 deletions coffeelint.json

This file was deleted.

45 changes: 0 additions & 45 deletions coffeescript/processor.rb

This file was deleted.

35 changes: 0 additions & 35 deletions coffeescript/rails.validations.simple_form.bootstrap4.coffee

This file was deleted.

0 comments on commit a6d8dc7

Please sign in to comment.