guard-kemal 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 1e4716480b6f5592a520e5a157b631a97684742f
4
- data.tar.gz: 35d2c2f071d2f720483dec6019ff2a895ed6f67c
3
+ metadata.gz: 760a3aa9c986d69683888bc097943f5e7e2aa312
4
+ data.tar.gz: 52e4781b0c13b5b2f53bdf05b26ccbd096d06601
5
5
  SHA512:
6
- metadata.gz: c5478a2989807c146e3b00f4a4ddde023eadd41ddfcbcb648590c1b4205424d0250f36651812e92b2b947789daf53ef60338f00e89596cebf6f44d2a53fe57aa
7
- data.tar.gz: 1b390577c37adf038430f6b48c84e7ca404ced996ce2d6f26dd331111116e3923ca99ee5af8ece521075aae50ee9f31272ca561c236fabe4c690a807cc4ee45d
6
+ metadata.gz: 865f3c5a820c7c9e047960f306b088c41ce49b4bd20b2d138ae563d7d008bf6efd94fabe5e1d148834b796c6778a35850eb723d5f32dee70ce1ae195598af905
7
+ data.tar.gz: 0fa5f00019cf640335fb12acea0fa47f7a63955d55e33aa3db22c45770eaf76169c32d11484aeaf2de074c981a2ab97d24fbab8edf240b4d3f7b676f7eed25b9
data/README.md CHANGED
@@ -17,13 +17,20 @@ And then execute:
17
17
 
18
18
  ## Usage
19
19
 
20
+ Setup your `Guardfile` with this:
21
+
20
22
  ```ruby
21
23
  #Guardfile
22
24
  guard 'kemal', path: 'src', file: 'server.cr' do
23
- watch('src/server.cr')
25
+ watch('src/server.cr') # watch the main kemal server
26
+ watch(%r{src/.*\.ecr}) # watch your views
24
27
  end
25
28
  ```
26
29
 
30
+ Once you've updated your `Guardfile`, you will just run the `guard` command like normal. Crystal will compile whatever file you specified by the `file` option (in this case "server.cr"), and this file should be located in your `path` option (in this case "./src"). Once Crystal compiles this file, then it will boot that file, and watch whatever you have set to watch. If one of these matched files are changed, guard will kill kemal, recompile the file, then reboot.
31
+
32
+ If you're using [Slang](https://github.com/jeromegn/slang) for your views, make sure to watch `%r{src/.*\.slang}`. This would watch any file ending in `.slang` located in your `./src/whatever/*.slang` where **whatever** could be something like `views`.
33
+
27
34
  ## Development
28
35
 
29
36
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/guard-kemal.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'guard/kemal/version'
4
+ require 'guard/kemal'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "guard-kemal"
data/lib/guard/kemal.rb CHANGED
@@ -2,20 +2,22 @@ require 'guard/compat/plugin'
2
2
 
3
3
  module Guard
4
4
  class Kemal < Plugin
5
+ autoload :Runner, 'guard/kemal/runner'
6
+ VERSION = "0.1.3"
7
+
8
+ attr_reader :runner
9
+
5
10
  def initialize(options = {})
6
- @path = options.fetch(:path, '.')
7
- @file = options.fetch(:file, 'app.cr')
8
11
  super
12
+ @runner = Runner.new(options)
9
13
  end
10
14
 
11
15
  def start
12
- @crystal_pid = Kernel.fork do
13
- exec("crystal #{File.join(@path, @file)}")
14
- end
16
+ runner.start!
15
17
  end
16
18
 
17
19
  def stop
18
- `$(killall -s SIGINT "crystal-run-#{@file.split('.').first}.tmp")`.chomp.strip
20
+ runner.stop!
19
21
  end
20
22
 
21
23
  def reload
@@ -0,0 +1,33 @@
1
+ module Guard
2
+ class Kemal < Plugin
3
+ class Runner
4
+ attr_reader :options
5
+
6
+ def initialize(options = {})
7
+ @path = options.fetch(:path, '.')
8
+ @file = options.fetch(:file, 'app.cr')
9
+ end
10
+
11
+ def start!
12
+ system("crystal build #{filepath}")
13
+ @crystal_pid = Kernel.fork do
14
+ exec("./#{executable_name}")
15
+ end
16
+ end
17
+
18
+ def stop!
19
+ system("kill -9 #{@crystal_pid}")
20
+ end
21
+
22
+ private
23
+
24
+ def filepath
25
+ File.join(@path, @file)
26
+ end
27
+
28
+ def executable_name
29
+ @file.split(".").first
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-kemal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Woertink
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -105,8 +105,8 @@ files:
105
105
  - bin/setup
106
106
  - guard-kemal.gemspec
107
107
  - lib/guard/kemal.rb
108
+ - lib/guard/kemal/runner.rb
108
109
  - lib/guard/kemal/templates/Guardfile
109
- - lib/guard/kemal/version.rb
110
110
  homepage: https://github.com/jwoertink/guard-kemal
111
111
  licenses:
112
112
  - MIT
@@ -1,5 +0,0 @@
1
- module Guard
2
- module Kemal
3
- VERSION = "0.1.2"
4
- end
5
- end