Skip to content

Commit

Permalink
Update name and explain our purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDaugherty committed Nov 16, 2018
1 parent 1c2d158 commit 18e36e6
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in guard-jest.gemspec
# Specify your gem's dependencies in guard-jest_runner.gemspec
gemspec
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Guard::Jest
# Guard::JestRunner

Guard::Jest allows you to automatically run jest when you change a Javascript/ES6 file.
Guard::JestRunner allows you to automatically run jest when you change a Javascript/ES6 file.

Unlike [guard-jest](https://rubygems.org/gems/guard-jest), this guard runs just as directed by your Guardfile, which allows you to use it in a group and use a Red-Green-Refactor process.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'guard-jest'
gem 'guard-jest_runner'
```

And then execute:
Expand All @@ -16,7 +18,7 @@ And then execute:

Or install it yourself as:

$ gem install guard-jest
$ gem install guard-jest_runner

## Usage

Expand All @@ -33,6 +35,22 @@ guard :jest do
end
```

(**Recommended**) pair up with guard-eslint to get a Red-Green-Refactor process:

```ruby
group :red_green_refactor_js, halt_on_fail: true do
guard :jest_runner do
watch(%r{app/javascript/(.+)\.js$}) { |m| "spec/javascript/#{m[1]}.test.js" }
watch(%r{spec/javascript/.+\.js$})
end

guard :eslint, formatter: 'codeframe' do
watch(%r{app/javascript/(.+)\.js$}) { |m| ""}
watch(%r{spec/javascript/(.+)\.js$})
end
end
```

### List of available options:

``` ruby
Expand All @@ -48,7 +66,7 @@ default_paths: ['**/*.js', '**/*.es6'] # The default paths that will be used for

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/RobinDaugherty/guard-jest.
Bug reports and pull requests are welcome on GitHub at https://github.com/RobinDaugherty/guard-jest_runner.

* Please create a topic branch for every separate change you make.
* Make sure your patches are well-tested.
Expand Down
14 changes: 7 additions & 7 deletions guard-jest.gemspec → guard-jest_runner.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'guard/jest/version'
require 'guard/jest_runner/version'

Gem::Specification.new do |s|
s.name = "guard-jest"
s.version = Guard::JestVersion.to_s
s.name = "guard-jest_runner"
s.version = Guard::JestRunnerVersion.to_s
s.authors = %w[RobinDaugherty]
s.email = %w[[email protected]]

s.description = %q{Allows you to add jest to your Guard toolchain, so that jest is run.}
s.summary = %q{Guard to run jest.}
s.homepage = "https://github.com/RobinDaugherty/guard-jest"
s.homepage = "https://github.com/RobinDaugherty/guard-jest_runner"
s.license = "MIT"

if s.respond_to?(:metadata)
s.metadata['changelog_uri'] = 'https://github.com/RobinDaugherty/guard-jest/releases'
s.metadata['source_code_uri'] = 'https://github.com/RobinDaugherty/guard-jest'
s.metadata['bug_tracker_uri'] = 'https://github.com/RobinDaugherty/guard-jest/issues'
s.metadata['changelog_uri'] = 'https://github.com/RobinDaugherty/guard-jest_runner/releases'
s.metadata['source_code_uri'] = 'https://github.com/RobinDaugherty/guard-jest_runner'
s.metadata['bug_tracker_uri'] = 'https://github.com/RobinDaugherty/guard-jest_runner/issues'
else
puts "Your RubyGems does not support metadata. Update if you'd like to make a release."
end
Expand Down
8 changes: 4 additions & 4 deletions lib/guard/jest.rb → lib/guard/jest_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require 'guard/compat/plugin'

module Guard
class Jest < Plugin
autoload :Runner, 'guard/jest/runner'
class JestRunner < Plugin
autoload :Runner, 'guard/jest_runner/runner'

# Initializes a Guard plugin.
# Don't do any work here, especially as Guard plugins get initialized
Expand Down Expand Up @@ -36,7 +36,7 @@ def initialize(options = {})
# @return [Object] the task result
#
def start
Compat::UI.info 'Guard::Jest is running'
Compat::UI.info 'Guard::JestRunner is running'
run_all if options[:all_on_start]
end

Expand Down Expand Up @@ -90,7 +90,7 @@ def inspect_with_jest(paths = [])
@failed_paths = runner.failed_paths
throw :task_has_failed unless passed
rescue => error
Compat::UI.error 'The following exception occurred while running guard-jest: ' \
Compat::UI.error 'The following exception occurred while running guard-jest_runner: ' \
"#{error.backtrace.first} #{error.message} (#{error.class.name})"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'json'

module Guard
class Jest
class JestRunner
# This class runs `jest` command, retrieves result and notifies.
# An instance of this class is intended to invoke `jest` only once in its lifetime.
class Runner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Guard
# A workaround for some superclass BS
# where Jest < Guard has to exist?
module JestVersion
module JestRunnerVersion
# http://semver.org/
MAJOR = 1
MINOR = 0
Expand Down
4 changes: 2 additions & 2 deletions spec/guard/jest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'spec_helper'

describe Guard::Jest do
describe Guard::JestRunner do
it 'has a version number' do
expect(Guard::Jest::VERSION).not_to be nil
expect(Guard::JestRunnerVersion).not_to be nil
end

it 'does something useful' do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'guard/jest'
require 'guard/jest_runner'

0 comments on commit 18e36e6

Please sign in to comment.