jasmine-jstd-conf 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/CHANGELOG.rdoc +7 -0
- data/README.rdoc +2 -0
- data/lib/jasmine-jstd-conf.rb +16 -36
- data/lib/jasmine-jstd-conf/version.rb +1 -1
- data/lib/views/conf.mustache +6 -0
- data/lib/views/usage.mustache +22 -0
- data/spec/lib/conf_spec.rb +2 -2
- metadata +5 -1
data/.travis.yml
ADDED
data/CHANGELOG.rdoc
ADDED
data/README.rdoc
CHANGED
data/lib/jasmine-jstd-conf.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
# Standard lib
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# Relative
|
1
5
|
require "jasmine-jstd-conf/version"
|
6
|
+
|
7
|
+
# Gems
|
2
8
|
require 'rubygems'
|
3
9
|
require 'bundler'
|
4
10
|
require 'jasmine'
|
@@ -7,16 +13,6 @@ require 'mustache'
|
|
7
13
|
module Jasmine
|
8
14
|
module JSTD
|
9
15
|
module Conf
|
10
|
-
# This looks like YAML, but it's hard to be sure...
|
11
|
-
TEMPLATE = <<EOF
|
12
|
-
server: {{server}}
|
13
|
-
|
14
|
-
load:
|
15
|
-
{{#paths}}
|
16
|
-
- {{.}}
|
17
|
-
{{/paths}}
|
18
|
-
EOF
|
19
|
-
|
20
16
|
def self.map(doc)
|
21
17
|
paths = doc.js_files
|
22
18
|
|
@@ -36,7 +32,7 @@ EOF
|
|
36
32
|
end
|
37
33
|
|
38
34
|
def self.render
|
39
|
-
Mustache.render(
|
35
|
+
Mustache.render(raw_mustache('conf'), map(Jasmine::Config.new))
|
40
36
|
end
|
41
37
|
|
42
38
|
def self.write(path)
|
@@ -44,43 +40,27 @@ EOF
|
|
44
40
|
end
|
45
41
|
|
46
42
|
def self.show_usage
|
47
|
-
puts
|
48
|
-
Usage: #{$PROGRAM_NAME} path [--help]
|
49
|
-
|
50
|
-
path Path to write to.
|
51
|
-
--help Show this help text.
|
52
|
-
|
53
|
-
Based on jasmine.yml, write a JSTD config file to the supplied path.
|
54
|
-
|
55
|
-
Example:
|
56
|
-
|
57
|
-
$ #{$PROGRAM_NAME} jsTestDriver.conf
|
58
|
-
$ cat jsTestDriver.conf
|
59
|
-
server: http://localhost:9876
|
60
|
-
|
61
|
-
load:
|
62
|
-
- /path/to/jasmine.js
|
63
|
-
- spec/javascripts/support/JasmineAdapter.js
|
64
|
-
- spec/javascripts/helpers/jasmine-jquery-1.3.1.js
|
65
|
-
- spec/javascripts/FooSpec.js
|
66
|
-
- spec/javascripts/BarSpec.js
|
67
|
-
- spec/javascripts/BazSpec.js
|
68
|
-
- spec/javascripts/QuxSpec.js
|
69
|
-
# [...]
|
70
|
-
EOF
|
43
|
+
puts Mustache.render(raw_mustache('usage'), {:program_name => $PROGRAM_NAME})
|
71
44
|
exit -1
|
72
45
|
end
|
73
46
|
|
74
47
|
private
|
75
48
|
|
76
49
|
def self.jasmine_js_path
|
77
|
-
|
50
|
+
# jsTestDriver can only use relative paths. Not sure why...
|
51
|
+
absolute_path = "#{locate_gem}/lib/jasmine-core/jasmine.js"
|
52
|
+
relative_path = Pathname.new(absolute_path).relative_path_from(Pathname.pwd)
|
53
|
+
relative_path.to_s
|
78
54
|
end
|
79
55
|
|
80
56
|
def self.locate_gem
|
81
57
|
spec = Bundler.load.specs.find{|s| s.name == 'jasmine-core' }
|
82
58
|
spec.full_gem_path
|
83
59
|
end
|
60
|
+
|
61
|
+
def self.raw_mustache(name)
|
62
|
+
File.read(File.join(File.dirname(__FILE__), "views/#{name}.mustache"))
|
63
|
+
end
|
84
64
|
end
|
85
65
|
end
|
86
66
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Usage: {{program_name}} path [--help]
|
2
|
+
|
3
|
+
path Path to write to.
|
4
|
+
--help Show this help text.
|
5
|
+
|
6
|
+
Based on jasmine.yml, write a JSTD config file to the supplied path.
|
7
|
+
|
8
|
+
Example:
|
9
|
+
|
10
|
+
$ {{program_name}} jsTestDriver.conf
|
11
|
+
$ cat jsTestDriver.conf
|
12
|
+
server: http://localhost:9876
|
13
|
+
|
14
|
+
load:
|
15
|
+
- /path/to/jasmine.js
|
16
|
+
- spec/javascripts/support/JasmineAdapter.js
|
17
|
+
- spec/javascripts/helpers/jasmine-jquery-1.3.1.js
|
18
|
+
- spec/javascripts/FooSpec.js
|
19
|
+
- spec/javascripts/BarSpec.js
|
20
|
+
- spec/javascripts/BazSpec.js
|
21
|
+
- spec/javascripts/QuxSpec.js
|
22
|
+
# [...]
|
data/spec/lib/conf_spec.rb
CHANGED
@@ -22,10 +22,10 @@ module Jasmine::JSTD
|
|
22
22
|
rendered.should match(%r{^ - spec/javascripts/BarSpec.rb$})
|
23
23
|
end
|
24
24
|
|
25
|
-
it 'includes jasmine.js from the jasmine-core gem' do
|
25
|
+
it 'includes jasmine.js from the jasmine-core gem as a relative path' do
|
26
26
|
rendered = render
|
27
27
|
|
28
|
-
md = rendered.match(%r{^ - (
|
28
|
+
md = rendered.match(%r{^ - (../.*?/jasmine.js)$})
|
29
29
|
md.should_not be_nil
|
30
30
|
jasmine_js_path = md[1]
|
31
31
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jasmine-jstd-conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Benjamin Oakes
|
@@ -103,6 +103,8 @@ files:
|
|
103
103
|
- .gitignore
|
104
104
|
- .rspec
|
105
105
|
- .rvmrc
|
106
|
+
- .travis.yml
|
107
|
+
- CHANGELOG.rdoc
|
106
108
|
- Gemfile
|
107
109
|
- MIT-LICENSE
|
108
110
|
- README.rdoc
|
@@ -112,6 +114,8 @@ files:
|
|
112
114
|
- jasmine-jstd-conf.gemspec
|
113
115
|
- lib/jasmine-jstd-conf.rb
|
114
116
|
- lib/jasmine-jstd-conf/version.rb
|
117
|
+
- lib/views/conf.mustache
|
118
|
+
- lib/views/usage.mustache
|
115
119
|
- spec/lib/conf_spec.rb
|
116
120
|
- spec/spec_helper.rb
|
117
121
|
has_rdoc: true
|