guard-roxy 0.0.2

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.
@@ -0,0 +1,18 @@
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
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in guard-roxy.gemspec
4
+ gemspec
5
+
6
+ gem 'guard'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Paxton Hare
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.
@@ -0,0 +1,21 @@
1
+ # Guard::Roxy
2
+
3
+ This guard runs Roxy Unit tests. See http://github.com/marklogic/roxy
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'guard-roxy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install guard-roxy
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ require 'guard/roxy/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "guard-roxy"
8
+ gem.version = Guard::RoxyVersion::VERSION
9
+ gem.authors = ["Paxton Hare"]
10
+ gem.email = ["paxton@greenllama.com"]
11
+ gem.description = %q{Guard gem for running Roxy Unit Tests. Roxy is a Framework for writing xquery application in MarkLogic.}
12
+ gem.summary = %q{Guard gem for running Roxy Unit Tests}
13
+ gem.homepage = "https://github.com/paxtonhare/guard-roxy"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,71 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'guard/watcher'
4
+ require 'rexml/document'
5
+
6
+ module Guard
7
+ class Roxy < Guard
8
+
9
+ # # Calls #run_all if the :all_on_start option is present.
10
+ def start
11
+ run_all if options[:all_on_start]
12
+ end
13
+
14
+ # Call #run_on_change for all files which match this guard.
15
+ def run_all
16
+ deploy_code
17
+ run_test
18
+ end
19
+
20
+ # Print the result of the command(s), if there are results to be printed.
21
+ def run_on_change(paths)
22
+ puts paths
23
+ deploy_code
24
+ paths.each do |path|
25
+ run_test(path) if File.exists?("src/#{path}")
26
+ end
27
+ end
28
+
29
+ def deploy_code
30
+ output = `ml local deploy modules`
31
+ end
32
+
33
+ def run_test(test = nil)
34
+ test_str = "--test=#{test}" if test
35
+ output = `ml local test #{test_str} --format=xml`
36
+ doc = REXML::Document.new(output)
37
+ assertions = doc.root.attribute('assertions').to_s.to_i
38
+ successes = doc.root.attribute('successes').to_s.to_i
39
+ failures = doc.root.attribute('failures').to_s.to_i
40
+ errors = doc.root.attribute('errors').to_s.to_i
41
+ time = doc.root.attribute('time').to_s
42
+
43
+ msg = "Ran #{assertions} assertions, #{successes} successes, #{failures} failures, #{errors} errors in #{time} seconds."
44
+ ::Guard::Notifier.notify(
45
+ msg,
46
+ :title => "Roxy:Test results",
47
+ :image => (failures == 0 && errors == 0) ? :success : :failed
48
+ )
49
+ # puts output
50
+ print_stack_dump(doc)
51
+ end
52
+
53
+ def print_stack_dump(doc)
54
+ REXML::XPath.each(doc, '//error:error') do |error|
55
+ puts "#{error.elements['./error:name'].text}: #{error.elements['./error:code'].text}"
56
+ puts "\nCall Stack:\n"
57
+
58
+ index = -1
59
+ last_operation = ''
60
+ error.each_element('error:stack/error:frame') do |frame|
61
+ index += 1
62
+ uri = frame.elements['error:uri']
63
+ uri = uri ? uri.text : "evaluated code"
64
+ line = frame.elements['error:line'].text
65
+ puts "#{uri}:#{line}\n\t#{last_operation}\n\n" if index > 0
66
+ last_operation = frame.elements['error:operation'].text
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,4 @@
1
+ guard :roxy do
2
+ watch(%r|(/test/.*-test\.xqy)|) { |m| m[1] }
3
+ watch(%r|src/((?!test).*\.xqy)|) { |m| "/test/#{m[1].gsub(/\.xqy/, '-test.xqy')}" }
4
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module RoxyVersion
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-roxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paxton Hare
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Guard gem for running Roxy Unit Tests. Roxy is a Framework for writing
15
+ xquery application in MarkLogic.
16
+ email:
17
+ - paxton@greenllama.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - guard-roxy.gemspec
28
+ - lib/guard/roxy.rb
29
+ - lib/guard/roxy/templates/Guardfile
30
+ - lib/guard/roxy/version.rb
31
+ homepage: https://github.com/paxtonhare/guard-roxy
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Guard gem for running Roxy Unit Tests
55
+ test_files: []