spark 0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDA3ZjYzMDdjNGNlMzNjM2Q3MDllYTI0MDI4MWYzMmRjM2QzYWE2YQ==
5
+ data.tar.gz: !binary |-
6
+ NTc3MmQ4NjRkMTlhY2QyMTYyYWIxMzkyN2M1MzcyYWMzMDliMDk3MQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWFjZTIyMzg3MWM3MTZkZmEyZTBmOWY5MmJiNGViNjQwOGNjMTJmZWI4MDcz
10
+ N2NlZWU2NGJmMWFlYmVkOGY5NTk3M2M0MWYyN2Y5NTNmNGE1NDBjMTNhMjE3
11
+ NTk4NGNjODEwOGQ3YzU2NDE5OGQ2YTE3NDJmYjlmN2QyY2I4MmI=
12
+ data.tar.gz: !binary |-
13
+ ZGNkNGE1MzAxZTcyZTY4YTY2N2VlZTkwNzU3ODBkMmQ4ODhlMmE2YWM3MjVj
14
+ NDZlMDIzZTgzM2RiNWU2MmI5ZGZiNjAyN2NjN2FhNTEyNzliNWRmNzI1NGQw
15
+ NTAxYTQyMDE5Yjc0NGFkYjg4M2YzZDcxZjI1YTI3M2QxZmZiNjY=
@@ -0,0 +1,16 @@
1
+ Copyright (C) 2013 elliottcable
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
15
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ Spark
2
+ =====
3
+ Pretty–printing [Rake][] tasks and other execution tools for [Speck][].
4
+
5
+ Ideas, feature requests, and bugs can be reported on Speck’s [GitHub][] issue tracker:
6
+
7
+ <http://github.com/elliottcable/Speck/issues>
8
+
9
+ [Rake]: http://rake.rubyforge.org/ "Rake’s RDocs"
10
+ [Speck]: http://github.com/elliottcable/Speck "Speck on GitHub"
11
+ [GitHub]: http://github.com/
12
+
13
+ License
14
+ -------
15
+ This project is licensed very openly for your use, under a variation of the ‘MIT license.’
16
+ Details are available in [LICENSE][].
17
+
18
+ [LICENSE]: <./LICENSE.text>
@@ -0,0 +1,74 @@
1
+ require 'speck'
2
+
3
+ require 'spark/core_ext'
4
+
5
+ module Spark
6
+ VERSION = 0
7
+
8
+ ##
9
+ # “Plays” a `Speck`, or `Speck:Battery`, recursively. This consists of:
10
+ #
11
+ # - Printing data about the `Speck` or `Battery`
12
+ # - Executing the `Battery`
13
+ # - Executing the `Speck`(s)
14
+ # - Executing each `Check` belonging to the `Speck`(s)
15
+ # - Printing data about each `Check` and its result
16
+ # - Recursively repeating the above for each child `Speck` or `Battery`
17
+ def self.playback target, indent = 0
18
+ if target.respond_to? :specks and target.respond_to? :targets
19
+ target.specks.each {|speck| Spark::playback speck }
20
+ target.targets.each {|object, battery| Spark::playback battery }
21
+ else
22
+ # TODO: FUCK FUCK FUCK THIS IS UGLY CODE ARRRGH
23
+ puts (" " * indent) + target.target.inspect if target.target
24
+ indent += 1
25
+
26
+ target.execute
27
+
28
+ checks = target.checks.group_by do |check|
29
+ begin
30
+ check.execute unless check.status
31
+ rescue Speck::Exception::CheckFailed
32
+ end
33
+ puts (" " * indent) + case check.status
34
+ when :passed then (" # " + check.status.to_s).green
35
+ when :failed then (" # " + check.status.to_s).red
36
+ when :future then (" # " + check.status.to_s).yellow
37
+ else (" # " + check.status.to_s).cyan
38
+ end
39
+ check.status
40
+ end
41
+
42
+ child_checks = target.children
43
+ .inject({:passed => [], :failed => []}) do |children_checks, speck|
44
+ child_checks = Spark::playback speck, indent
45
+ child_checks.each do |k,v|
46
+ children_checks[k] ||= Array.new
47
+ children_checks[k] += v || Array.new
48
+ end
49
+ children_checks
50
+ end
51
+
52
+ child_checks.each do |k,v|
53
+ checks[k] ||= Array.new
54
+ checks[k] += v || Array.new
55
+ end
56
+
57
+
58
+ indent -= 1
59
+
60
+ # TODO: FUCK FUCK FUCK THIS IS EVEN UGLIER THAN THE ABOVE CODE!!!!1!1
61
+ total = checks.inject(0) {|t, (k,v)| t + v.size }
62
+ passed = checks[:passed].size
63
+ failed = checks[:failed].size
64
+ other = checks.inject(0) {|t, (k,v)| t += v.size unless [:passed, :failed].include? k; t }
65
+ puts (" " * indent) + "(#{
66
+ checks[:failed].size > 0 ?
67
+ checks[:passed].size.to_s.red : checks[:passed].size.to_s.green
68
+ }#{other &&! other.zero? ? '/' + other.to_s.cyan : nil } of #{total})" unless total.zero?
69
+
70
+ return checks
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1 @@
1
+ require 'spark/core_ext/string'
@@ -0,0 +1,35 @@
1
+ class String
2
+
3
+ ##
4
+ # Provides some methods to colourize strings for output to the terminal.
5
+ module ANSI
6
+
7
+ # The available ANSI colour codes. The index in the array is the ANSI
8
+ # code.
9
+ Colours = [
10
+ :black,
11
+ :red,
12
+ :green,
13
+ :yellow,
14
+ :blue,
15
+ :magenta,
16
+ :cyan,
17
+ :white
18
+ ]
19
+
20
+ Colours.each.with_index do |colour, index|
21
+ define_method colour do
22
+ self.wrap_ansi "[3#{index}m"
23
+ end
24
+ end
25
+
26
+ ##
27
+ # Wraps this string in the given ANSI code.
28
+ def wrap_ansi code
29
+ "\033#{code}#{self}\033[0m"
30
+ end
31
+
32
+ end
33
+
34
+ include ANSI
35
+ end
@@ -0,0 +1,56 @@
1
+ require 'spark'
2
+
3
+ require 'rake/tasklib'
4
+
5
+ module Spark
6
+ module Rake
7
+
8
+ class SpeckTask < ::Rake::TaskLib
9
+ attr_accessor :name
10
+ attr_accessor :description
11
+ attr_accessor :files
12
+ attr_accessor :batteries
13
+
14
+ def initialize name = :specks, batteries = Array.new
15
+ @name = name
16
+ @batteries = batteries.is_a?(Array) ? batteries : [batteries]
17
+ @files = []
18
+ @description = "Recursively runs all unbound Specks"
19
+
20
+ yield self if block_given?
21
+ @files << 'specifications/**/*_specs.rb' if @files.empty?
22
+
23
+ self.files += ENV['SPECK_FILES'].split(/[ ,]/) if ENV['SPECK_FILES']
24
+
25
+ define
26
+ end
27
+
28
+ def define
29
+ desc @description
30
+ task @name do
31
+ # TODO: AND SUDDENLY, UGLY CODES! KILOBYTES OF THEM!
32
+ [@files].flatten.map {|p| p.include?("*") ? Dir[p] : p }.flatten
33
+ .each {|f| require File.expand_path(f) }
34
+
35
+ targets = @batteries.empty? ? Speck::unbound : @batteries
36
+ checks = targets.inject(Array.new) do |acc, target|
37
+ puts '-~- ' * 10 + '*' + ' -~-' * 10 if targets.size > 1
38
+ target = target.call if target.respond_to? :call
39
+ acc << Spark.playback(target)
40
+ end
41
+ puts '-~- ' * 10 + '*' + ' -~-' * 10 if targets.size > 1
42
+
43
+ if targets.size == 0
44
+ puts 'No specifications found.'
45
+ exit 1
46
+ end
47
+
48
+ exit(1) if checks.map {|c| c[:failed] ? c[:failed].size : 0 }
49
+ .inject {|acc,e| acc + e } > 0
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spark
3
+ version: !ruby/object:Gem::Version
4
+ version: '0'
5
+ platform: ruby
6
+ authors:
7
+ - elliottcable [http://ell.io/tt]
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: speck
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 10.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 10.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.5.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.5.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: maruku
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.1
69
+ description:
70
+ email:
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/spark/core_ext/string.rb
76
+ - lib/spark/core_ext.rb
77
+ - lib/spark/rake/speck_task.rb
78
+ - lib/spark.rb
79
+ - README.markdown
80
+ - LICENSE.text
81
+ homepage: http://github.com/elliottcable/spark
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.0.0
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: An extension to Speck, providing Rake tasks and pretty test runners.
105
+ test_files: []
106
+ has_rdoc: