set_builder 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +14 -0
- data/assets/javascripts/array.js +100 -0
- data/assets/javascripts/set_builder.js +415 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/set_builder.rb +58 -0
- data/lib/set_builder/constraint.rb +67 -0
- data/lib/set_builder/modifier.rb +134 -0
- data/lib/set_builder/modifier/adverb.rb +11 -0
- data/lib/set_builder/modifier/base.rb +105 -0
- data/lib/set_builder/modifier/verb.rb +24 -0
- data/lib/set_builder/modifier_collection.rb +41 -0
- data/lib/set_builder/modifiers.rb +3 -0
- data/lib/set_builder/modifiers/date_modifier.rb +83 -0
- data/lib/set_builder/modifiers/number_modifier.rb +48 -0
- data/lib/set_builder/modifiers/string_modifier.rb +81 -0
- data/lib/set_builder/query_builders/string.rb +0 -0
- data/lib/set_builder/set.rb +81 -0
- data/lib/set_builder/trait.rb +74 -0
- data/lib/set_builder/traits.rb +42 -0
- data/lib/set_builder/value_map.rb +62 -0
- data/lib/set_builder/version.rb +3 -0
- data/set_builder.gemspec +25 -0
- data/spec/commands/example_command.rb +19 -0
- data/spec/dom.html +24 -0
- data/spec/lib/images/bg.png +0 -0
- data/spec/lib/images/hr.png +0 -0
- data/spec/lib/images/loading.gif +0 -0
- data/spec/lib/images/sprites.bg.png +0 -0
- data/spec/lib/images/sprites.png +0 -0
- data/spec/lib/images/vr.png +0 -0
- data/spec/lib/jspec.css +149 -0
- data/spec/lib/jspec.growl.js +115 -0
- data/spec/lib/jspec.jquery.js +88 -0
- data/spec/lib/jspec.js +1908 -0
- data/spec/lib/jspec.nodejs.js +18 -0
- data/spec/lib/jspec.shell.js +39 -0
- data/spec/lib/jspec.timers.js +154 -0
- data/spec/lib/jspec.xhr.js +210 -0
- data/spec/node.js +10 -0
- data/spec/rhino.js +10 -0
- data/spec/server.html +18 -0
- data/spec/server.rb +4 -0
- data/spec/unit/array.spec.js +82 -0
- data/spec/unit/set_builder.spec.js +166 -0
- data/spec/unit/spec.helper.js +0 -0
- data/test/date_modifier_test.rb +13 -0
- data/test/inflector_test.rb +27 -0
- data/test/modifier_test.rb +90 -0
- data/test/set_test.rb +96 -0
- data/test/test_helper.rb +79 -0
- data/test/trait_test.rb +49 -0
- data/test/traits_test.rb +41 -0
- data/test/value_map_test.rb +30 -0
- data/uninstall.rb +1 -0
- metadata +191 -0
data/set_builder.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'set_builder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "set_builder"
|
8
|
+
spec.version = SetBuilder::VERSION
|
9
|
+
spec.authors = ["Bob Lail"]
|
10
|
+
spec.email = ["bob.lailfamily@gmail.com"]
|
11
|
+
spec.description = %q{A gem for describing constraints on data sets}
|
12
|
+
spec.summary = %q{Define traits on a model, create sets that constrain those traits, and generate both natural-language descriptions of the sets and queries to select them}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rails", "< 4.0"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "turn"
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
# uncomment and call with `$ jspec example `
|
3
|
+
|
4
|
+
# command :example do |c|
|
5
|
+
# c.syntax = 'jspec example [options]'
|
6
|
+
# c.description = 'Just an example command'
|
7
|
+
# c.option '-f', '--foo string', 'Does some foo with <string>'
|
8
|
+
# c.option '-b', '--bar [string]', 'Does some bar with [string]'
|
9
|
+
# c.example 'Do some foo', 'jspec example --foo bar'
|
10
|
+
# c.example 'Do some bar', 'jspec example --bar'
|
11
|
+
# c.when_called do |args, options|
|
12
|
+
# p args
|
13
|
+
# p options.__hash__
|
14
|
+
# # options.foo
|
15
|
+
# # options.bar
|
16
|
+
# # options.__hash__[:foo]
|
17
|
+
# # options.__hash__[:bar]
|
18
|
+
# end
|
19
|
+
# end
|
data/spec/dom.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link type="text/css" rel="stylesheet" href="./lib/jspec.css" />
|
4
|
+
<script src="./lib/jspec.js"></script>
|
5
|
+
<script src="./lib/jspec.xhr.js"></script>
|
6
|
+
<script src="../assets/array.js"></script>
|
7
|
+
<script src="../assets/set_builder.js"></script>
|
8
|
+
<script src="unit/spec.helper.js"></script>
|
9
|
+
<script>
|
10
|
+
function runSuites() {
|
11
|
+
JSpec
|
12
|
+
.exec('unit/set_builder.spec.js')
|
13
|
+
.exec('unit/array.spec.js')
|
14
|
+
.run({ fixturePath: 'fixtures' })
|
15
|
+
.report()
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
</head>
|
19
|
+
<body class="jspec" onLoad="runSuites();">
|
20
|
+
<div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
|
21
|
+
<div id="jspec"></div>
|
22
|
+
<div id="jspec-bottom"></div>
|
23
|
+
</body>
|
24
|
+
</html>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/lib/jspec.css
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
body.jspec {
|
2
|
+
margin: 45px 0;
|
3
|
+
font: 12px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
4
|
+
background: #efefef url(images/bg.png) top left repeat-x;
|
5
|
+
text-align: center;
|
6
|
+
}
|
7
|
+
#jspec {
|
8
|
+
margin: 0 auto;
|
9
|
+
padding-top: 30px;
|
10
|
+
width: 1008px;
|
11
|
+
background: url(images/vr.png) top left repeat-y;
|
12
|
+
text-align: left;
|
13
|
+
}
|
14
|
+
#jspec-top {
|
15
|
+
position: relative;
|
16
|
+
margin: 0 auto;
|
17
|
+
width: 1008px;
|
18
|
+
height: 40px;
|
19
|
+
background: url(images/sprites.bg.png) top left no-repeat;
|
20
|
+
}
|
21
|
+
#jspec-bottom {
|
22
|
+
margin: 0 auto;
|
23
|
+
width: 1008px;
|
24
|
+
height: 15px;
|
25
|
+
background: url(images/sprites.bg.png) bottom left no-repeat;
|
26
|
+
}
|
27
|
+
#jspec .loading {
|
28
|
+
margin-top: -45px;
|
29
|
+
width: 1008px;
|
30
|
+
height: 80px;
|
31
|
+
background: url(images/loading.gif) 50% 50% no-repeat;
|
32
|
+
}
|
33
|
+
#jspec-title {
|
34
|
+
position: absolute;
|
35
|
+
top: 15px;
|
36
|
+
left: 20px;
|
37
|
+
width: 160px;
|
38
|
+
font-size: 22px;
|
39
|
+
font-weight: normal;
|
40
|
+
background: url(images/sprites.png) 0 -126px no-repeat;
|
41
|
+
text-align: center;
|
42
|
+
}
|
43
|
+
#jspec-title em {
|
44
|
+
font-size: 10px;
|
45
|
+
font-style: normal;
|
46
|
+
color: #BCC8D1;
|
47
|
+
}
|
48
|
+
#jspec-report * {
|
49
|
+
margin: 0;
|
50
|
+
padding: 0;
|
51
|
+
background: none;
|
52
|
+
border: none;
|
53
|
+
}
|
54
|
+
#jspec-report {
|
55
|
+
padding: 15px 40px;
|
56
|
+
font: 11px "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
57
|
+
color: #7B8D9B;
|
58
|
+
}
|
59
|
+
#jspec-report.has-failures {
|
60
|
+
padding-bottom: 30px;
|
61
|
+
}
|
62
|
+
#jspec-report .hidden {
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
#jspec-report .heading {
|
66
|
+
margin-bottom: 15px;
|
67
|
+
}
|
68
|
+
#jspec-report .heading span {
|
69
|
+
padding-right: 10px;
|
70
|
+
}
|
71
|
+
#jspec-report .heading .passes em {
|
72
|
+
color: #0ea0eb;
|
73
|
+
}
|
74
|
+
#jspec-report .heading .failures em {
|
75
|
+
color: #FA1616;
|
76
|
+
}
|
77
|
+
#jspec-report table {
|
78
|
+
font-size: 11px;
|
79
|
+
border-collapse: collapse;
|
80
|
+
}
|
81
|
+
#jspec-report td {
|
82
|
+
padding: 8px;
|
83
|
+
text-indent: 30px;
|
84
|
+
color: #7B8D9B;
|
85
|
+
}
|
86
|
+
#jspec-report tr.body {
|
87
|
+
display: none;
|
88
|
+
}
|
89
|
+
#jspec-report tr.body pre {
|
90
|
+
margin: 0;
|
91
|
+
padding: 0 0 5px 25px;
|
92
|
+
}
|
93
|
+
#jspec-report tr.even:hover + tr.body,
|
94
|
+
#jspec-report tr.odd:hover + tr.body {
|
95
|
+
display: block;
|
96
|
+
}
|
97
|
+
#jspec-report tr td:first-child em {
|
98
|
+
display: block;
|
99
|
+
clear: both;
|
100
|
+
font-style: normal;
|
101
|
+
font-weight: normal;
|
102
|
+
color: #7B8D9B;
|
103
|
+
}
|
104
|
+
#jspec-report tr.even:hover,
|
105
|
+
#jspec-report tr.odd:hover {
|
106
|
+
text-shadow: 1px 1px 1px #fff;
|
107
|
+
background: #F2F5F7;
|
108
|
+
}
|
109
|
+
#jspec-report td + td {
|
110
|
+
padding-right: 0;
|
111
|
+
width: 15px;
|
112
|
+
}
|
113
|
+
#jspec-report td.pass {
|
114
|
+
background: url(images/sprites.png) 3px -7px no-repeat;
|
115
|
+
}
|
116
|
+
#jspec-report td.fail {
|
117
|
+
background: url(images/sprites.png) 3px -158px no-repeat;
|
118
|
+
font-weight: bold;
|
119
|
+
color: #FC0D0D;
|
120
|
+
}
|
121
|
+
#jspec-report td.requires-implementation {
|
122
|
+
background: url(images/sprites.png) 3px -333px no-repeat;
|
123
|
+
}
|
124
|
+
#jspec-report tr.description td {
|
125
|
+
margin-top: 25px;
|
126
|
+
padding-top: 25px;
|
127
|
+
font-size: 12px;
|
128
|
+
font-weight: bold;
|
129
|
+
text-indent: 0;
|
130
|
+
color: #1a1a1a;
|
131
|
+
}
|
132
|
+
#jspec-report tr.description:first-child td {
|
133
|
+
border-top: none;
|
134
|
+
}
|
135
|
+
#jspec-report .assertion {
|
136
|
+
display: block;
|
137
|
+
float: left;
|
138
|
+
margin: 0 0 0 1px;
|
139
|
+
padding: 0;
|
140
|
+
width: 1px;
|
141
|
+
height: 5px;
|
142
|
+
background: #7B8D9B;
|
143
|
+
}
|
144
|
+
#jspec-report .assertion.failed {
|
145
|
+
background: red;
|
146
|
+
}
|
147
|
+
.jspec-sandbox {
|
148
|
+
display: none;
|
149
|
+
}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
// JSpec - Growl - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
|
+
|
4
|
+
;(function(){
|
5
|
+
|
6
|
+
Growl = {
|
7
|
+
|
8
|
+
// --- Version
|
9
|
+
|
10
|
+
version: '1.0.0',
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Execute the given _cmd_, returning an array of lines from stdout.
|
14
|
+
*
|
15
|
+
* Examples:
|
16
|
+
*
|
17
|
+
* Growl.exec('growlnotify', '-m', msg)
|
18
|
+
*
|
19
|
+
* @param {string ...} cmd
|
20
|
+
* @return {array}
|
21
|
+
* @api public
|
22
|
+
*/
|
23
|
+
|
24
|
+
exec: function(cmd) {
|
25
|
+
var lines = [], line
|
26
|
+
with (JavaImporter(java.lang, java.io)) {
|
27
|
+
var proccess = Runtime.getRuntime().exec(Array.prototype.slice.call(arguments))
|
28
|
+
var stream = new DataInputStream(proccess.getInputStream())
|
29
|
+
while (line = stream.readLine())
|
30
|
+
lines.push(line + '')
|
31
|
+
stream.close()
|
32
|
+
}
|
33
|
+
return lines
|
34
|
+
},
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Return the extension of the given _path_ or null.
|
38
|
+
*
|
39
|
+
* @param {string} path
|
40
|
+
* @return {string}
|
41
|
+
* @api private
|
42
|
+
*/
|
43
|
+
|
44
|
+
extname: function(path) {
|
45
|
+
return path.lastIndexOf('.') != -1 ?
|
46
|
+
path.slice(path.lastIndexOf('.') + 1, path.length) :
|
47
|
+
null
|
48
|
+
},
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Version of the 'growlnotify' binary.
|
52
|
+
*
|
53
|
+
* @return {string}
|
54
|
+
* @api private
|
55
|
+
*/
|
56
|
+
|
57
|
+
binVersion: function() {
|
58
|
+
try { return this.exec('growlnotify', '-v')[0].split(' ')[1] } catch (e) {}
|
59
|
+
},
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Send growl notification _msg_ with _options_.
|
63
|
+
*
|
64
|
+
* Options:
|
65
|
+
*
|
66
|
+
* - title Notification title
|
67
|
+
* - sticky Make the notification stick (defaults to false)
|
68
|
+
* - name Application name (defaults to growlnotify)
|
69
|
+
* - image
|
70
|
+
* - path to an icon sets --iconpath
|
71
|
+
* - path to an image sets --image
|
72
|
+
* - capitalized word sets --appIcon
|
73
|
+
* - filename uses extname as --icon
|
74
|
+
* - otherwise treated as --icon
|
75
|
+
*
|
76
|
+
* Examples:
|
77
|
+
*
|
78
|
+
* Growl.notify('New email')
|
79
|
+
* Growl.notify('5 new emails', { title: 'Thunderbird' })
|
80
|
+
*
|
81
|
+
* @param {string} msg
|
82
|
+
* @param {options} hash
|
83
|
+
* @api public
|
84
|
+
*/
|
85
|
+
|
86
|
+
notify: function(msg, options) {
|
87
|
+
options = options || {}
|
88
|
+
var args = ['growlnotify', '-m', msg]
|
89
|
+
if (!this.binVersion()) throw new Error('growlnotify executable is required')
|
90
|
+
if (image = options.image) {
|
91
|
+
var flag, ext = this.extname(image)
|
92
|
+
flag = flag || ext == 'icns' && 'iconpath'
|
93
|
+
flag = flag || /^[A-Z]/.test(image) && 'appIcon'
|
94
|
+
flag = flag || /^png|gif|jpe?g$/.test(ext) && 'image'
|
95
|
+
flag = flag || ext && (image = ext) && 'icon'
|
96
|
+
flag = flag || 'icon'
|
97
|
+
args.push('--' + flag, image)
|
98
|
+
}
|
99
|
+
if (options.sticky) args.push('--sticky')
|
100
|
+
if (options.name) args.push('--name', options.name)
|
101
|
+
if (options.title) args.push(options.title)
|
102
|
+
this.exec.apply(this, args)
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
JSpec.include({
|
107
|
+
name: 'Growl',
|
108
|
+
reporting: function(options){
|
109
|
+
var stats = JSpec.stats
|
110
|
+
if (stats.failures) Growl.notify('failed ' + stats.failures + ' assertions', { title: 'JSpec'})
|
111
|
+
else Growl.notify('passed ' + stats.passes + ' assertions', { title: 'JSpec' })
|
112
|
+
}
|
113
|
+
})
|
114
|
+
|
115
|
+
})()
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
// JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
|
+
|
4
|
+
JSpec
|
5
|
+
.requires('jQuery', 'when using jspec.jquery.js')
|
6
|
+
.include({
|
7
|
+
name: 'jQuery',
|
8
|
+
|
9
|
+
// --- Initialize
|
10
|
+
|
11
|
+
init : function() {
|
12
|
+
jQuery.ajaxSetup({ async: false })
|
13
|
+
},
|
14
|
+
|
15
|
+
// --- Utilities
|
16
|
+
|
17
|
+
utilities : {
|
18
|
+
element: jQuery,
|
19
|
+
elements: jQuery,
|
20
|
+
sandbox : function() {
|
21
|
+
return jQuery('<div class="sandbox"></div>')
|
22
|
+
}
|
23
|
+
},
|
24
|
+
|
25
|
+
// --- Matchers
|
26
|
+
|
27
|
+
matchers : {
|
28
|
+
have_tag : "jQuery(expected, actual).length === 1",
|
29
|
+
have_one : "alias have_tag",
|
30
|
+
have_tags : "jQuery(expected, actual).length > 1",
|
31
|
+
have_many : "alias have_tags",
|
32
|
+
have_any : "alias have_tags",
|
33
|
+
have_child : "jQuery(actual).children(expected).length === 1",
|
34
|
+
have_children : "jQuery(actual).children(expected).length > 1",
|
35
|
+
have_text : "jQuery(actual).text() === expected",
|
36
|
+
have_value : "jQuery(actual).val() === expected",
|
37
|
+
be_enabled : "!jQuery(actual).attr('disabled')",
|
38
|
+
have_class : "jQuery(actual).hasClass(expected)",
|
39
|
+
be_animated : "jQuery(actual).queue().length > 0",
|
40
|
+
|
41
|
+
be_visible : function(actual) {
|
42
|
+
return jQuery(actual).css('display') != 'none' &&
|
43
|
+
jQuery(actual).css('visibility') != 'hidden' &&
|
44
|
+
jQuery(actual).attr('type') != 'hidden'
|
45
|
+
},
|
46
|
+
|
47
|
+
be_hidden : function(actual) {
|
48
|
+
return !JSpec.does(actual, 'be_visible')
|
49
|
+
},
|
50
|
+
|
51
|
+
have_classes : function(actual) {
|
52
|
+
return !JSpec.any(JSpec.toArray(arguments, 1), function(arg){
|
53
|
+
return !JSpec.does(actual, 'have_class', arg)
|
54
|
+
})
|
55
|
+
},
|
56
|
+
|
57
|
+
have_attr : function(actual, attr, value) {
|
58
|
+
return value ? jQuery(actual).attr(attr) == value:
|
59
|
+
jQuery(actual).attr(attr)
|
60
|
+
},
|
61
|
+
|
62
|
+
have_event_handlers : function(actual, expected) {
|
63
|
+
if (jQuery(actual).data('events') && jQuery(actual).data('events').hasOwnProperty(expected)) {
|
64
|
+
return true;
|
65
|
+
} else if (jQuery(actual.context).data('events') && jQuery(actual.context).data('events').hasOwnProperty(expected)) {
|
66
|
+
var events = jQuery(actual.context).data('events')[expected];
|
67
|
+
|
68
|
+
for (index in events) {
|
69
|
+
if (events[index].selector === actual.selector) {
|
70
|
+
return true;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return false;
|
75
|
+
},
|
76
|
+
|
77
|
+
'be disabled selected checked' : function(attr) {
|
78
|
+
return 'jQuery(actual).attr("' + attr + '")'
|
79
|
+
},
|
80
|
+
|
81
|
+
'have type id title alt href src sel rev name target' : function(attr) {
|
82
|
+
return function(actual, value) {
|
83
|
+
return JSpec.does(actual, 'have_attr', attr, value)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
})
|
88
|
+
|