gusto 1.0.0.beta5 → 1.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c1808ada1efad77009fd9f1496f9a51f3a323f2
4
- data.tar.gz: 43061acf4d0696732bf59e3fd430f9267d677764
3
+ metadata.gz: e0d60b26b8242dc202dc9449165409a42d237b9f
4
+ data.tar.gz: b02b6c3e680e45d7ddcc7694e7d28b3b1b98f7f4
5
5
  SHA512:
6
- metadata.gz: bf24f5a1eb91e800657f89e16c4283243ec8a40f3046cf5e05d1571af4fb4cdb711d4f096838fcd122ef16e89744ac51d95252668e71859b10af45c3f5aee6a0
7
- data.tar.gz: 340da76b5b3868259fc03f6e2bdc55c87c5ae3e8a1d01ed85a869ac5dabe8491182af6cd16f94fe1e6769cb527edf1f4a6e5db7c6c2fbaccbdd7657c5c917210
6
+ metadata.gz: 696d0053da6fcabc6aae8fd7705bdf20435db33bd3b1fb743f59187772213f67f469b4b42a381837b5011c6953a045641f5f43f86c5b789b1d1c305ba2420a2d
7
+ data.tar.gz: 1af4df4ed92749ac953d4ee16782c6750f148759d2a5f83280c31d2d4e47f234d06460722ea5230b021a4c562319514c02e68fe51c46722bfdc9773aa69a1dd0
@@ -0,0 +1,45 @@
1
+ module Gusto
2
+ module Configuration
3
+ class << self
4
+ def paths
5
+ [
6
+ File.join(Gusto.project_root, 'gusto.json'),
7
+ File.join(Gusto.project_root, 'config', 'gusto.json')
8
+ ]
9
+ end
10
+
11
+ def load
12
+ # Set configuration defaults
13
+ @data = {
14
+ 'port' => 4567,
15
+ 'lib_paths' => %w(lib),
16
+ 'spec_paths' => %w(spec)
17
+ }
18
+
19
+ # Load custom configuration file
20
+ paths.each do |path|
21
+ if File.exists? path
22
+ @data.merge! JSON.parse(File.read(path))
23
+ puts "Loaded configuration from “#{path}”"
24
+ end
25
+ end
26
+ end
27
+
28
+ def port
29
+ @data['port']
30
+ end
31
+
32
+ def port= value
33
+ @data['port'] = value
34
+ end
35
+
36
+ def lib_paths
37
+ @data['lib_paths']
38
+ end
39
+
40
+ def spec_paths
41
+ @data['spec_paths']
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/gusto/runner.rb CHANGED
@@ -5,8 +5,8 @@ module Gusto
5
5
  class Runner
6
6
  def load_gusto
7
7
  require File.join(File.dirname(__FILE__), '..', 'gusto')
8
- Gusto.load_configuration
9
- Gusto.port = @port
8
+ Gusto::Configuration.load
9
+ Gusto::Configuration.port = @port
10
10
  end
11
11
 
12
12
  def load_gusto_version
data/lib/gusto/server.rb CHANGED
@@ -4,13 +4,27 @@ require 'sinatra'
4
4
  require 'sass'
5
5
  require 'slim'
6
6
  require 'coffee-script'
7
+ require 'sprockets'
8
+ require 'sprockets-helpers'
7
9
  require File.expand_path(File.dirname(__FILE__) + '/../gusto')
8
10
 
9
11
  module Gusto
10
12
  class Server < Sinatra::Application
13
+ def self.start
14
+ Rack::Handler.default.run rack_app, :Port => Configuration.port
15
+ end
16
+
17
+ def self.rack_app
18
+ Rack::Builder.app do
19
+ map('/assets') { run Sprockets.environment }
20
+ map('/') { run Server }
21
+ end
22
+ end
23
+
11
24
  # Configure paths
12
- set :public_folder, ROOT + '/public'
13
- set :views, ROOT + '/views'
25
+ set :public_folder, File.join(Gusto.root, 'public')
26
+ set :views, File.join(Gusto.root, 'views')
27
+ set :assets_prefix, '/assets'
14
28
 
15
29
  # Configure slim for prettier code formatting
16
30
  Slim::Engine.set_default_options :pretty => true
@@ -18,13 +32,24 @@ module Gusto
18
32
  # Hide redundant log messages
19
33
  disable :logging
20
34
 
35
+ ::Sprockets::Helpers.configure do |config|
36
+ config.environment = Sprockets.environment
37
+ config.public_path = public_folder
38
+ config.prefix = assets_prefix
39
+ config.debug = true
40
+ end
41
+
42
+ helpers do
43
+ include ::Sprockets::Helpers
44
+ end
45
+
21
46
  # Processes request for page index
22
47
  get "/" do
23
48
  # Fetch list of all specification files in specs path
24
49
  @scripts = []
25
- Gusto.specs.each do |path|
26
- Dir["#{Gusto::PROJECT_ROOT}/#{path}/**/*spec.coffee"].each do |file|
27
- @scripts << $1 if file.match Regexp.new("^#{Regexp.escape Gusto::PROJECT_ROOT}\\/#{Regexp.escape path}\\/(.*).coffee$")
50
+ Gusto::Configuration.spec_paths.each do |path|
51
+ Dir["#{Gusto.project_root}/#{path}/**/*spec.coffee"].each do |file|
52
+ @scripts << $1 if file.match Regexp.new("^#{Regexp.escape Gusto.project_root}\\/#{Regexp.escape path}\\/(.*).coffee$")
28
53
  end
29
54
  end
30
55
 
@@ -0,0 +1,25 @@
1
+ module Gusto
2
+ module Sprockets
3
+ class << self
4
+ # Prepares a Sprockets::Environment object to serve coffeescript assets
5
+ def environment
6
+ @environment ||= ::Sprockets::Environment.new.tap do |environment|
7
+ configure_environment(environment)
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def configure_environment(environment)
14
+ environment.append_path File.join(Gusto.root, 'lib')
15
+ environment.append_path File.join(Gusto.root, 'assets')
16
+ puts "Using assets in #{all_paths.inspect}"
17
+ all_paths.each{ |path| environment.append_path(path) }
18
+ end
19
+
20
+ def all_paths
21
+ Configuration.lib_paths + Configuration.spec_paths
22
+ end
23
+ end
24
+ end
25
+ end
data/lib/gusto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gusto
2
- VERSION = "1.0.0.beta5"
2
+ VERSION = "1.0.0.beta6"
3
3
  end
data/lib/gusto.rb CHANGED
@@ -8,55 +8,21 @@ require 'json'
8
8
  require File.join(File.dirname(__FILE__), 'gusto', 'version')
9
9
 
10
10
  module Gusto
11
- ROOT = File.expand_path File.join(File.dirname(__FILE__), '..')
12
- PROJECT_ROOT = File.expand_path "."
13
-
14
- CONFIG_PATHS = [
15
- File.join(PROJECT_ROOT, 'gusto.json'),
16
- File.join(PROJECT_ROOT, 'config', 'gusto.json')
17
- ]
18
-
19
- @configuration = {}
11
+ autoload :Configuration, File.join(File.dirname(__FILE__), 'gusto', 'configuration')
12
+ autoload :Server, File.join(File.dirname(__FILE__), 'gusto', 'server')
13
+ autoload :Sprockets, File.join(File.dirname(__FILE__), 'gusto', 'sprockets')
20
14
 
21
15
  class << self
22
-
23
- def load_configuration
24
- # Set configuration defaults
25
- @configuration['port'] = 4567
26
- @configuration['lib_paths'] = %w(lib)
27
- @configuration['spec_paths'] = %w(spec)
28
-
29
- # Load custom configuration file
30
- CONFIG_PATHS.each do |path|
31
- if File.exists? path
32
- @configuration.merge! JSON.parse(File.read(path))
33
- puts "Loaded configuration from “#{path}”"
34
- end
35
- end
36
- end
37
-
38
- def port
39
- @configuration['port']
16
+ def root
17
+ File.expand_path File.join(File.dirname(__FILE__), '..')
40
18
  end
41
19
 
42
- def port= value
43
- @configuration['port'] = value
20
+ def project_root
21
+ File.expand_path "."
44
22
  end
45
23
 
46
24
  def root_url
47
- "http://localhost:#{port}/"
48
- end
49
-
50
- def libs
51
- @configuration['lib_paths']
52
- end
53
-
54
- def specs
55
- @configuration['spec_paths']
56
- end
57
-
58
- def all_paths
59
- libs + specs
25
+ "http://localhost:#{Configuration.port}/"
60
26
  end
61
27
 
62
28
  def server
@@ -80,32 +46,8 @@ module Gusto
80
46
  Process.waitall
81
47
  end
82
48
 
83
- # Prepares a Sprockets::Environment object to serve coffeescript assets
84
- def sprockets_environment
85
- @environment ||= Sprockets::Environment.new.tap do |environment|
86
- environment.append_path File.join(ROOT, 'lib')
87
- environment.append_path File.join(ROOT, 'assets')
88
- all_paths.each do |path|
89
- environment.append_path path
90
- end
91
- end
92
- end
93
-
94
- def start_server
95
- app = Rack::Builder.app do
96
- map '/assets' do
97
- run Gusto::sprockets_environment
98
- end
99
-
100
- map '/' do
101
- run Gusto::Server
102
- end
103
- end
104
- Rack::Handler.default.run app, :Port => port
105
- end
106
-
107
49
  def spawn_server
108
- @server = Process.fork{ $0 = 'gusto server'; start_server }
50
+ @server = Process.fork{ $0 = 'gusto server'; Server.start }
109
51
  wait_for_server_at(root_url)
110
52
  end
111
53
 
@@ -125,7 +67,7 @@ module Gusto
125
67
  def watch_for_changes
126
68
  require 'listen'
127
69
 
128
- @listener = Listen.to(PROJECT_ROOT)
70
+ @listener = Listen.to(project_root)
129
71
 
130
72
  # Match .coffee files in any project paths
131
73
  @listener.filter Regexp.new('^(' + all_paths.map{ |s| Regexp.escape s}.join('|') + ')\/.*\.coffee$')
@@ -158,5 +100,3 @@ module Gusto
158
100
  end
159
101
  end
160
102
  end
161
-
162
- require File.expand_path(File.dirname(__FILE__) + '/gusto/server')
data/views/index.slim CHANGED
@@ -4,14 +4,13 @@ head
4
4
  script type="text/javascript" src="jquery-1.5.2.js"
5
5
  script type="text/javascript" src="stacktrace.js"
6
6
  script type="text/javascript" src="jsdiff.js"
7
- link rel="stylesheet" href="/assets/spec.css" type="text/css"
8
- script type="text/javascript" src="/assets/Spec.js"
9
- script type="text/javascript" src="/assets/HtmlReport.js"
7
+ == stylesheet_tag 'spec'
8
+ == javascript_tag('Spec') + "\n"
9
+ == javascript_tag('HtmlReport') + "\n"
10
+ - @scripts.each do |script|
11
+ == javascript_tag(script) + "\n"
10
12
 
11
13
  body
12
- javascript:
13
- - @scripts.each do |file_name|
14
- script type="text/javascript" src="/assets/#{{file_name.sub /\.coffee$/, '.js'}}"
15
14
  javascript:
16
15
  $(function() {
17
16
  window.report = new HtmlReport(document.body);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gusto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta5
4
+ version: 1.0.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2013-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-script
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sprockets-helpers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: sinatra
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -135,8 +149,10 @@ files:
135
149
  - assets/spec.css.sass
136
150
  - assets/test_results.sass
137
151
  - bin/gusto
152
+ - lib/gusto/configuration.rb
138
153
  - lib/gusto/runner.rb
139
154
  - lib/gusto/server.rb
155
+ - lib/gusto/sprockets.rb
140
156
  - lib/gusto/version.rb
141
157
  - lib/gusto.rb
142
158
  - lib/HtmlReport.coffee
@@ -177,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
193
  version: 1.3.1
178
194
  requirements: []
179
195
  rubyforge_project:
180
- rubygems_version: 2.0.0
196
+ rubygems_version: 2.0.3
181
197
  signing_key:
182
198
  specification_version: 4
183
199
  summary: Coffeescript testing framework