guard-julia 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4dae592b4db8e802357b8d630cf98269ba68bab
4
+ data.tar.gz: c3aa6141bb137975202c9465b367535a0845a125
5
+ SHA512:
6
+ metadata.gz: 35bc8190b13378cd9764485dc029d113ab6a2a696685901a7c23176db5b88123d028dc16965cd853ade91268bc06df09ac068165eff81c467801bc7e1d2784e1
7
+ data.tar.gz: a76e4ec317fa51647f6bd8b2ca935630fa68049c78a89baad68902968fad8e8260234465506d1cf67f4b7a2f1ef8cc7c98cf442b984fe39a91d33269a0f8e5df
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
data/CHANGELOG.yml ADDED
@@ -0,0 +1,5 @@
1
+ %YAML 1.2
2
+ ---
3
+ changes:
4
+ v0.0.0:
5
+ - TODO(svs14): Update before release.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
7
+ group :development, :test do
8
+ gem 'minitest'
9
+ gem 'mocha'
10
+ gem 'guard-minitest', require: false
11
+ gem 'guard-rubocop', require: false
12
+ end
13
+
14
+ # Test group will be installed
15
+ # on Travis CI
16
+ group :test do
17
+ gem 'coveralls', require: false
18
+ end
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :minitest do
2
+ # with Minitest::Spec
3
+ watch(%r{^spec/(.*)_spec\.rb$})
4
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
+ watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
6
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Samuel Jenkins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Guard::Julia
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/guard-julia.png)](http://badge.fury.io/rb/guard-julia)
4
+ [![Build Status](https://travis-ci.org/svs14/guard-julia.png?branch=master)](https://travis-ci.org/svs14/guard-julia)
5
+ [![Dependency Status](https://gemnasium.com/svs14/guard-julia.png)](https://gemnasium.com/svs14/guard-julia)
6
+ [![Code Climate](https://codeclimate.com/github/svs14/guard-julia.png)](https://codeclimate.com/github/svs14/guard-julia)
7
+ [![Coverage Status](https://coveralls.io/repos/svs14/guard-julia/badge.png?branch=master)](https://coveralls.io/r/svs14/guard-julia)
8
+ [![Inline docs](http://inch-ci.org/github/svs14/guard-julia.png)](http://inch-ci.org/github/svs14/guard-julia)
9
+
10
+ Julia guard automatically launches
11
+ respective tests when Julia files are modified.
12
+
13
+ The codebase's architecture is largely derived from
14
+ [guard-minitest](https://github.com/guard/guard-minitest).
15
+
16
+ ## Installation
17
+
18
+ Ruby must be installed, then run:
19
+
20
+ $ gem install bundler
21
+ $ cd /your/julia/project/dir
22
+ $ bundle init
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'guard-julia'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ ## Usage
33
+
34
+ Please read [Guard usage documentation](http://github.com/guard/guard#readme).
35
+
36
+ To create the Guardfile run:
37
+
38
+ $ bundle exec guard init julia
39
+
40
+ Then run guard itself:
41
+
42
+ $ bundle exec guard
43
+
44
+ ## Options
45
+
46
+ ```ruby
47
+ all_on_start: true # Run all tests on startup
48
+ julia_file_path: 'julia' # File path to Julia executable
49
+ all_tests_file: 'test/runtests.jl' # File to run all tests
50
+ cli: ['--code-coverage'] # CLI arguments to Julia
51
+ env: {} # Environment variables
52
+ ```
53
+
54
+ You can pass any of these options in the Guardfile like so:
55
+ ```ruby
56
+ guard :julia, cli: ['--code-coverage', '-p 1'] do
57
+ # ...
58
+ end
59
+ ```
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it ( http://github.com/svs14/guard-julia/fork )
64
+ 2. Get all dependencies (`bundle`)
65
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 5. Make sure tests pass (`bundle exec rake test`)
68
+ 6. Follow RuboCop's advice (`bundle exec rubocop`)
69
+ 7. Push to the branch (`git push origin my-new-feature`)
70
+ 8. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'spec'
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'guard/julia/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'guard-julia'
8
+ spec.version = Guard::JuliaVersion::VERSION
9
+ spec.authors = ['Samuel Jenkins']
10
+ spec.email = ['svs14.41svs@gmail.com']
11
+ spec.summary = 'Guard plugin for Julia language'
12
+ spec.description = 'Guard::Julia automatically runs tests when files change'
13
+ spec.homepage = 'https://rubygems.org/gems/guard-julia'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+ spec.add_dependency 'guard', '~> 2.6'
23
+ spec.add_dependency 'bundler', '~> 1.5'
24
+ end
@@ -0,0 +1,67 @@
1
+ require 'guard'
2
+ require 'guard/plugin'
3
+
4
+ module Guard
5
+ # Guard plugin for the Julia language.
6
+ class Julia < Plugin
7
+ require 'guard/julia/version'
8
+ require 'guard/julia/runner'
9
+
10
+ # Options for plugin.
11
+ attr_accessor :options
12
+ # Runner that handles Julia commands.
13
+ attr_accessor :runner
14
+
15
+ def initialize(options = {})
16
+ super
17
+
18
+ @options = {
19
+ all_on_start: true
20
+ }.merge(options)
21
+ @runner = Runner.new(@options)
22
+ end
23
+
24
+ def start
25
+ UI.info "Guard::Julia #{JuliaVersion::VERSION} is running"
26
+ run_all if @options[:all_on_start]
27
+ end
28
+
29
+ def stop
30
+ true
31
+ end
32
+
33
+ def reload
34
+ true
35
+ end
36
+
37
+ def run_all
38
+ UI.info 'Running: all tests', reset: true
39
+ throw_on_failed_tests { runner.run_all }
40
+ end
41
+
42
+ def run_on_changes(_)
43
+ true
44
+ end
45
+
46
+ def run_on_additions(_)
47
+ true
48
+ end
49
+
50
+ def run_on_modifications(paths)
51
+ UI.info "Running: #{paths.join(', ')}", reset: true
52
+ throw_on_failed_tests { runner.run_on_modifications(paths) }
53
+ end
54
+
55
+ def run_on_removals(_)
56
+ true
57
+ end
58
+
59
+ private
60
+
61
+ # Runs block and throws :task_has_failed
62
+ # when return is false.
63
+ def throw_on_failed_tests
64
+ throw :task_has_failed unless yield
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,73 @@
1
+ module Guard
2
+ class Julia
3
+ # Runner that handles Julia calls and Guard notifications.
4
+ class Runner
5
+ # Options for runner.
6
+ attr_accessor :options
7
+
8
+ # Initializes Runner.
9
+ #
10
+ # @param options [Dict] Options for runner.
11
+ def initialize(options = {})
12
+ @options = {
13
+ julia_file_path: 'julia',
14
+ all_tests_file: 'test/runtests.jl',
15
+ cli: ['--code-coverage'],
16
+ env: {}
17
+ }.merge(options)
18
+ end
19
+
20
+ # Runs Julia on all tests file and notifies.
21
+ def run_all
22
+ paths = [@options[:all_tests_file]]
23
+ ret_code = run_julia_command(paths)
24
+ guard_notify(paths, ret_code)
25
+ end
26
+
27
+ # Runs Julia on target paths (triggered by file modifications).
28
+ #
29
+ # @param paths [Array<String>] Paths of files.
30
+ def run_on_modifications(paths)
31
+ return_code = run_julia_command(paths)
32
+ guard_notify(paths, return_code)
33
+ end
34
+
35
+ private
36
+
37
+ # Runs Julia command from paths and options.
38
+ # Returns system return code.
39
+ def run_julia_command(paths)
40
+ cmd_parts = build_julia_command(paths)
41
+ system(@options[:env], *cmd_parts)
42
+ end
43
+
44
+ # Build Julia command from paths and options.
45
+ # Returns array of command parts.
46
+ def build_julia_command(paths)
47
+ cmd_parts = []
48
+ cmd_parts << "#{@options[:julia_file_path]}"
49
+ cmd_parts.push(*@options[:cli])
50
+ cmd_parts.push(*paths)
51
+
52
+ cmd_parts
53
+ end
54
+
55
+ # Guard notification of Julia success/failure.
56
+ def guard_notify(paths, success)
57
+ # Build notification
58
+ if success
59
+ title = 'Success'
60
+ message = paths.join('\n')
61
+ image = :success
62
+ else
63
+ title = 'Failed'
64
+ message = paths.join('\n')
65
+ image = :failed
66
+ end
67
+
68
+ # Notify via Guard
69
+ ::Guard::Notifier.notify(message, title: title, image: image)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,8 @@
1
+ guard :julia do
2
+ # Run all tests when [PackageName].jl changes.
3
+ watch(%r{^src/(.*/)?(.*?[A-Z].*)\.jl}) { |m| "test/runtests.jl" }
4
+ # Run respective test when a source file changes.
5
+ watch(%r{^src/(.*/)?([^A-Z]*)\.jl}) { |m| "test/#{m[1]}test_#{m[2]}.jl"}
6
+ # Run test file when it changes.
7
+ watch(%r{^test/(.*/)?(.*)\.jl}) { |m| "test/#{m[1]}#{m[2]}.jl" }
8
+ end
@@ -0,0 +1,6 @@
1
+ module Guard
2
+ # Julia guard plugin version.
3
+ module JuliaVersion
4
+ VERSION = '0.0.1'
5
+ end
6
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Julia::Runner do
4
+ subject { Guard::Julia::Runner }
5
+
6
+ let(:default_options) do
7
+ {
8
+ julia_file_path: 'julia',
9
+ all_tests_file: 'test/runtests.jl',
10
+ cli: ['--code-coverage'],
11
+ env: {}
12
+ }
13
+ end
14
+
15
+ describe '#options' do
16
+ it 'defaults' do
17
+ subject.new.options.must_equal(default_options)
18
+ end
19
+ end
20
+
21
+ describe '#run_all' do
22
+ it 'runs all tests file' do
23
+ subject.any_instance.expects(:system).with(
24
+ {}, 'julia', '--code-coverage', 'test/runtests.jl'
25
+ ).returns(true)
26
+ ::Guard::Notifier.expects(:notify).with(
27
+ 'test/runtests.jl', title: 'Success', image: :success
28
+ )
29
+ subject.new.run_all
30
+ end
31
+ end
32
+ describe '#run_on_modifications' do
33
+ describe 'when julia exits successfully' do
34
+ it 'it notifies success' do
35
+ subject.any_instance.expects(:system).with(
36
+ {}, 'julia', '--code-coverage',
37
+ 'test/test_example.jl', 'test/test_dummy.jl'
38
+ ).returns(true)
39
+ ::Guard::Notifier.expects(:notify).with(
40
+ 'test/test_example.jl\ntest/test_dummy.jl',
41
+ title: 'Success', image: :success
42
+ )
43
+
44
+ subject.new.run_on_modifications(
45
+ ['test/test_example.jl', 'test/test_dummy.jl']
46
+ )
47
+ end
48
+ end
49
+
50
+ describe 'when julia exits with failure' do
51
+ it 'it notifies failure' do
52
+ subject.any_instance.expects(:system).with(
53
+ {}, 'julia', '--code-coverage',
54
+ 'test/test_example.jl', 'test/test_dummy.jl'
55
+ ).returns(false)
56
+ ::Guard::Notifier.expects(:notify).with(
57
+ 'test/test_example.jl\ntest/test_dummy.jl',
58
+ title: 'Failed', image: :failed
59
+ )
60
+
61
+ subject.new.run_on_modifications(
62
+ ['test/test_example.jl', 'test/test_dummy.jl']
63
+ )
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::JuliaVersion do
4
+ subject { Guard::JuliaVersion }
5
+
6
+ describe '::VERSION' do
7
+ it 'provides the version' do
8
+ subject::VERSION.must_match(/^[0-9]+\.[0-9]+\.[0-9]+/)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Julia do
4
+ subject { Guard::Julia }
5
+
6
+ let(:runner) { Guard::Julia::Runner }
7
+ let(:guard) { subject.new }
8
+
9
+ describe '#initialize' do
10
+ it 'passes options to runner' do
11
+ runner.expects(:new).with(all_on_start: true)
12
+ subject.new
13
+ end
14
+ end
15
+
16
+ describe '#start' do
17
+ describe 'when using defaults' do
18
+ it 'runs all tests' do
19
+ subject.any_instance.expects(:run_all)
20
+ subject.new.start
21
+ end
22
+ end
23
+ describe 'when run_all_on_start: false' do
24
+ it 'does not run all tests' do
25
+ subject.any_instance.expects(:run_all).never
26
+ subject.new(all_on_start: false).start
27
+ end
28
+ end
29
+ end
30
+ describe '#stop' do
31
+ it 'returns true' do
32
+ guard.stop.must_equal true
33
+ end
34
+ end
35
+ describe '#reload' do
36
+ it 'returns true' do
37
+ guard.reload.must_equal true
38
+ end
39
+ end
40
+
41
+ describe '#run_all' do
42
+ it 'delegates to runner, then notifies' do
43
+ runner.any_instance.expects(run_all: true)
44
+ Guard::UI.expects(:info).with(
45
+ 'Running: all tests',
46
+ reset: true
47
+ )
48
+ guard.run_all
49
+ end
50
+ end
51
+
52
+ describe '#run_on_changes' do
53
+ it 'returns true' do
54
+ guard.run_on_changes([]).must_equal true
55
+ end
56
+ end
57
+ describe '#run_on_removals' do
58
+ it 'returns true' do
59
+ guard.run_on_removals([]).must_equal true
60
+ end
61
+ end
62
+ describe '#run_on_additions' do
63
+ it 'returns true' do
64
+ guard.run_on_additions([]).must_equal true
65
+ end
66
+ end
67
+
68
+ describe '#run_on_modifications' do
69
+ it 'delegates to runner, then notifies' do
70
+ runner.any_instance.expects(run_on_modifications: true)
71
+ Guard::UI.expects(:info).with(
72
+ 'Running: test/test_example.jl, test/test_dummy.jl',
73
+ reset: true
74
+ )
75
+ guard.run_on_modifications(['test/test_example.jl', 'test/test_dummy.jl'])
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+
3
+ if ENV['CI']
4
+ require 'coveralls'
5
+ Coveralls.wear! do
6
+ add_filter 'spec'
7
+ end
8
+ end
9
+
10
+ ENV['GUARD_ENV'] = 'test'
11
+ require 'guard/julia'
12
+
13
+ require 'minitest/autorun'
14
+ require 'minitest/pride'
15
+ require 'mocha/mini_test'
16
+
17
+ module MiniTest
18
+ #
19
+ class Spec
20
+ before(:each) do
21
+ # Stub all UI methods, so no visible output appears for the UI class
22
+ ::Guard::UI.stubs(:info)
23
+ ::Guard::UI.stubs(:warning)
24
+ ::Guard::UI.stubs(:error)
25
+ ::Guard::UI.stubs(:debug)
26
+ ::Guard::UI.stubs(:deprecation)
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-julia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Jenkins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ description: Guard::Julia automatically runs tests when files change
42
+ email:
43
+ - svs14.41svs@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CHANGELOG.yml
51
+ - Gemfile
52
+ - Guardfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - guard-julia.gemspec
57
+ - lib/guard/julia.rb
58
+ - lib/guard/julia/runner.rb
59
+ - lib/guard/julia/templates/Guardfile
60
+ - lib/guard/julia/version.rb
61
+ - spec/guard/julia/runner_spec.rb
62
+ - spec/guard/julia/version_spec.rb
63
+ - spec/guard/julia_spec.rb
64
+ - spec/spec_helper.rb
65
+ homepage: https://rubygems.org/gems/guard-julia
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.9.2
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.3.0
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Guard plugin for Julia language
89
+ test_files:
90
+ - spec/guard/julia/runner_spec.rb
91
+ - spec/guard/julia/version_spec.rb
92
+ - spec/guard/julia_spec.rb
93
+ - spec/spec_helper.rb
94
+ has_rdoc: