fiveruns_tuneup_merb 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README +70 -0
- data/Rakefile +49 -0
- data/TODO +2 -0
- data/app/controllers/application.rb +3 -0
- data/app/controllers/runs.rb +15 -0
- data/app/helpers/application_helper.rb +64 -0
- data/app/views/layout/fiveruns_tuneup_merb.html.erb +16 -0
- data/lib/fiveruns_tuneup_merb/api_key.rb +23 -0
- data/lib/fiveruns_tuneup_merb/instrumentation.rb +193 -0
- data/lib/fiveruns_tuneup_merb/merbtasks.rb +106 -0
- data/lib/fiveruns_tuneup_merb/slicetasks.rb +18 -0
- data/lib/fiveruns_tuneup_merb/spectasks.rb +65 -0
- data/lib/fiveruns_tuneup_merb.rb +113 -0
- data/public/images/arrows.gif +0 -0
- data/public/images/dialog.png +0 -0
- data/public/images/edit.png +0 -0
- data/public/images/fade.png +0 -0
- data/public/images/fade_down.png +0 -0
- data/public/images/head.gif +0 -0
- data/public/images/logo.gif +0 -0
- data/public/images/logo_clear.png +0 -0
- data/public/images/magnify.png +0 -0
- data/public/images/pip.gif +0 -0
- data/public/images/pointer.gif +0 -0
- data/public/images/schema.png +0 -0
- data/public/images/signin.gif +0 -0
- data/public/images/spinner.gif +0 -0
- data/public/images/warning.gif +0 -0
- data/public/javascripts/init.js +12 -0
- data/public/javascripts/jquery.js +32 -0
- data/public/javascripts/sandbox.html +7 -0
- data/public/javascripts/tuneup.js +97 -0
- data/public/stylesheets/tuneup.css +226 -0
- data/spec/controllers/main_spec.rb +61 -0
- data/spec/fiveruns_tuneup_merb_spec.rb +130 -0
- data/spec/spec_helper.rb +44 -0
- data/stubs/app/controllers/application.rb +2 -0
- data/stubs/app/controllers/main.rb +2 -0
- metadata +123 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The FiveRuns License)
|
2
|
+
|
3
|
+
Copyright (c) 2008 FiveRuns Corporation
|
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.
|
data/README
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
= FiveRuns TuneUp panel for Merb
|
2
|
+
|
3
|
+
== Requirements
|
4
|
+
|
5
|
+
* fiveruns_tuneup_core gem
|
6
|
+
* merb-core >= 0.9.5
|
7
|
+
* merb-slices >= 0.9.5
|
8
|
+
|
9
|
+
== Synopsis
|
10
|
+
|
11
|
+
FiveRuns TuneUp for Merb.
|
12
|
+
|
13
|
+
See http://blog.fiveruns.com/2008/10/11/fiveruns-tuneup-for-merb for the announcement.
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
|
17
|
+
1. Install the gem:
|
18
|
+
|
19
|
+
sudo gem install fiveruns_tuneup_merb
|
20
|
+
|
21
|
+
2. Add the following to your desired environment file (eg, config/environments/development.rb):
|
22
|
+
|
23
|
+
dependency 'fiveruns_tuneup_merb'
|
24
|
+
|
25
|
+
3. Run the following in your Merb.root:
|
26
|
+
|
27
|
+
rake slices:fiveruns_tuneup_merb:install
|
28
|
+
|
29
|
+
4. Add the following to your config/router.rb:
|
30
|
+
|
31
|
+
slice FiverunsTuneupMerb
|
32
|
+
|
33
|
+
(If you're already mounting other slices with `all_slices' this step isn't necessary.)
|
34
|
+
|
35
|
+
5. Start your app!
|
36
|
+
|
37
|
+
== Sharing
|
38
|
+
|
39
|
+
To enable run sharing on the http://tuneup.fiveruns.com service, you need to configure the slice with an API key. Create an account at http://tuneup.fiveruns.com/users/new and look at your profile to find your it.
|
40
|
+
|
41
|
+
In your environment file (ie, config/environments/development.rb), add the API key:
|
42
|
+
|
43
|
+
Merb::BootLoader.before_app_loads do
|
44
|
+
Merb::Slices.config[:fiveruns_tuneup_merb][:api_key] = 'YOUR-API-KEY'
|
45
|
+
end
|
46
|
+
|
47
|
+
When you restart your application, a "Share this run" link on the TuneUp panel should appear.
|
48
|
+
|
49
|
+
== Supported Browsers
|
50
|
+
|
51
|
+
The TuneUp plugin has been tested with the following browsers:
|
52
|
+
|
53
|
+
* Firefox 2+
|
54
|
+
* Safari 3.1+
|
55
|
+
|
56
|
+
== Bugs and Feature Requests
|
57
|
+
|
58
|
+
Please let us know if you run into any problems with your application or browser. The plugin uses CSS isolation techniques that could interfere with your HTML or CSS code.
|
59
|
+
|
60
|
+
You can contact support at support@fiveruns.com
|
61
|
+
|
62
|
+
== Contributing
|
63
|
+
|
64
|
+
Help us make TuneUp better on Merb by contributing via GitHub.
|
65
|
+
http://github.com/fiveruns/fiveruns_tuneup_merb
|
66
|
+
http://github.com/fiveruns/fiveruns_tuneup_core
|
67
|
+
|
68
|
+
== License
|
69
|
+
|
70
|
+
See LICENSE
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
require 'merb-core/version'
|
5
|
+
require 'merb-core/tasks/merb_rake_helper'
|
6
|
+
require 'merb-core/test/tasks/spectasks'
|
7
|
+
|
8
|
+
NAME = "fiveruns_tuneup_merb"
|
9
|
+
AUTHOR = "FiveRuns Development Team"
|
10
|
+
EMAIL = "dev@fiveruns.com"
|
11
|
+
HOMEPAGE = "http://tuneup.fiveruns.com/"
|
12
|
+
SUMMARY = "Merb Slice that provides the FiveRuns TuneUp Panel (http://tuneup.fiveruns.com)"
|
13
|
+
GEM_VERSION = "0.5.0"
|
14
|
+
|
15
|
+
spec = Gem::Specification.new do |s|
|
16
|
+
s.rubyforge_project = 'fiveruns_tuneup_merb'
|
17
|
+
s.name = NAME
|
18
|
+
s.version = GEM_VERSION
|
19
|
+
s.platform = Gem::Platform::RUBY
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
22
|
+
s.summary = SUMMARY
|
23
|
+
s.description = s.summary
|
24
|
+
s.author = AUTHOR
|
25
|
+
s.email = EMAIL
|
26
|
+
s.homepage = HOMEPAGE
|
27
|
+
s.add_dependency('fiveruns_tuneup_core')
|
28
|
+
s.add_dependency('merb-slices', '>= 0.9.5')
|
29
|
+
s.require_path = 'lib'
|
30
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec,app,public,stubs}/**/*")
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
34
|
+
pkg.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Install FiverunsTuneupMerb as a gem"
|
38
|
+
task :install => [:package] do
|
39
|
+
sh %{gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
|
40
|
+
end
|
41
|
+
|
42
|
+
namespace :jruby do
|
43
|
+
|
44
|
+
desc "Run :package and install the resulting .gem with jruby"
|
45
|
+
task :install => :package do
|
46
|
+
sh %{jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class FiverunsTuneupMerb::Runs < FiverunsTuneupMerb::Application
|
2
|
+
|
3
|
+
provides :json
|
4
|
+
|
5
|
+
def share
|
6
|
+
run_id = Fiveruns::Tuneup::Run.share(params[:slug])
|
7
|
+
result = if run_id
|
8
|
+
{:run_id => run_id}
|
9
|
+
else
|
10
|
+
{:error => "Could not send run. Please contact support@fiveruns.com if this problem persists."}
|
11
|
+
end
|
12
|
+
render_json result.to_json
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Merb
|
2
|
+
module FiverunsTuneupMerb
|
3
|
+
module ApplicationHelper
|
4
|
+
|
5
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
6
|
+
#
|
7
|
+
# @return <String>
|
8
|
+
# A path relative to the public directory, with added segments.
|
9
|
+
def image_path(*segments)
|
10
|
+
public_path_for(:image, *segments)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
14
|
+
#
|
15
|
+
# @return <String>
|
16
|
+
# A path relative to the public directory, with added segments.
|
17
|
+
def javascript_path(*segments)
|
18
|
+
public_path_for(:javascript, *segments)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
22
|
+
#
|
23
|
+
# @return <String>
|
24
|
+
# A path relative to the public directory, with added segments.
|
25
|
+
def stylesheet_path(*segments)
|
26
|
+
public_path_for(:stylesheet, *segments)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Construct a path relative to the public directory
|
30
|
+
#
|
31
|
+
# @param <Symbol> The type of component.
|
32
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
33
|
+
#
|
34
|
+
# @return <String>
|
35
|
+
# A path relative to the public directory, with added segments.
|
36
|
+
def public_path_for(type, *segments)
|
37
|
+
::FiverunsTuneupMerb.public_path_for(type, *segments)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Construct an app-level path.
|
41
|
+
#
|
42
|
+
# @param <Symbol> The type of component.
|
43
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
44
|
+
#
|
45
|
+
# @return <String>
|
46
|
+
# A path within the host application, with added segments.
|
47
|
+
def app_path_for(type, *segments)
|
48
|
+
::FiverunsTuneupMerb.app_path_for(type, *segments)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Construct a slice-level path.
|
52
|
+
#
|
53
|
+
# @param <Symbol> The type of component.
|
54
|
+
# @param *segments<Array[#to_s]> Path segments to append.
|
55
|
+
#
|
56
|
+
# @return <String>
|
57
|
+
# A path within the slice source (Gem), with added segments.
|
58
|
+
def slice_path_for(type, *segments)
|
59
|
+
::FiverunsTuneupMerb.slice_path_for(type, *segments)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
5
|
+
<title>Fresh FiverunsTuneupMerb Slice</title>
|
6
|
+
<link href="<%= public_path_for :stylesheet, 'master.css' %>" type="text/css" charset="utf-8" rel="stylesheet" media="all" />
|
7
|
+
<script src="<%= public_path_for :javascript, 'master.js' %>" type="text/javascript" charset="utf-8"></script>
|
8
|
+
</head>
|
9
|
+
<!-- you can override this layout at slices/fiveruns_tuneup_merb/app/views/layout/fiveruns_tuneup_merb.html.erb -->
|
10
|
+
<body class="fiveruns_tuneup_merb-slice">
|
11
|
+
<div id="container">
|
12
|
+
<h1>FiverunsTuneupMerb Slice</h1>
|
13
|
+
<div id="main"><%= catch_content :for_layout %></div>
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module FiverunsTuneupMerb
|
4
|
+
|
5
|
+
module APIKey
|
6
|
+
|
7
|
+
def can_share?
|
8
|
+
Fiveruns::Tuneup::Run.api_key? && routed?
|
9
|
+
end
|
10
|
+
|
11
|
+
def log_share_status
|
12
|
+
if Fiveruns::Tuneup::Run.api_key?
|
13
|
+
Merb.logger.debug "TuneUp is configured for sharing."
|
14
|
+
else
|
15
|
+
Merb.logger.warn "TuneUp is NOT configured for sharing."
|
16
|
+
Merb.logger.warn "You must set Merb::Slices.config[:fiveruns_tuneup_merb][:api_key] to share runs."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module FiverunsTuneupMerb
|
4
|
+
|
5
|
+
module Instrumentation
|
6
|
+
|
7
|
+
def self.pretty(value)
|
8
|
+
CGI.escapeHTML(PP.pp(value, ''))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.format_filters(filters)
|
12
|
+
sets = filters.map do |filter, opts|
|
13
|
+
content = if filter.is_a?(Proc)
|
14
|
+
where = filter.inspect[/@(.+)>$/, 1]
|
15
|
+
"Proc at %s with options %s" % [Fiveruns::Tuneup.editor_link_line(where), pretty(opts)]
|
16
|
+
else
|
17
|
+
"%s with options %s" % [pretty(filter), pretty(opts)]
|
18
|
+
end
|
19
|
+
%(<li>%s</li>) % content
|
20
|
+
end
|
21
|
+
"<ul>%s</ul>" % sets.join("\n")
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.format_sql(query, statement, attributes = nil)
|
25
|
+
values = query.bind_values + (attributes ? attributes.values : [])
|
26
|
+
[statement, "<b>Values:</b> " + CGI.escapeHTML(values.inspect)].join("<br/>")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.attrs_for(query)
|
30
|
+
[
|
31
|
+
[ :repository, query.repository.name ],
|
32
|
+
[ :model, query.model ],
|
33
|
+
[ :fields, query.fields ],
|
34
|
+
[ :links, query.links ],
|
35
|
+
[ :conditions, query.conditions ],
|
36
|
+
[ :order, query.order ],
|
37
|
+
[ :limit, query.limit ],
|
38
|
+
[ :offset, query.offset ],
|
39
|
+
[ :reload, query.reload? ],
|
40
|
+
[ :unique, query.unique? ]
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.format_query(query)
|
45
|
+
rows = attrs_for(query).map do |set|
|
46
|
+
%(<tr><th>%s</th><td><pre>%s</pre></td></tr>) % set.map { |item|
|
47
|
+
pretty item
|
48
|
+
}
|
49
|
+
end
|
50
|
+
"<table>%s</table>" % rows.join
|
51
|
+
end
|
52
|
+
|
53
|
+
module Merb
|
54
|
+
|
55
|
+
module Controller
|
56
|
+
|
57
|
+
def new(*args, &block)
|
58
|
+
super.extend(Ext)
|
59
|
+
end
|
60
|
+
|
61
|
+
module Ext
|
62
|
+
|
63
|
+
def body
|
64
|
+
if content_type == :html && request.tuneup
|
65
|
+
::Merb.logger.debug "TuneUp: Saving run and inserting panel into the response"
|
66
|
+
run = Fiveruns::Tuneup::Run.new(request.uri, request.tuneup)
|
67
|
+
run.save
|
68
|
+
Fiveruns::Tuneup.insert_panel(super, run, FiverunsTuneupMerb.can_share?)
|
69
|
+
else
|
70
|
+
super
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def render(thing = nil, *args)
|
75
|
+
name = thing ? thing.inspect : nil
|
76
|
+
Fiveruns::Tuneup.step("Render #{name}", :view) { super }
|
77
|
+
end
|
78
|
+
|
79
|
+
def partial(template, *args)
|
80
|
+
Fiveruns::Tuneup.step("Partial #{template.inspect}", :view) { super }
|
81
|
+
end
|
82
|
+
|
83
|
+
def _call_filters(filters)
|
84
|
+
if filters.empty?
|
85
|
+
super
|
86
|
+
else
|
87
|
+
Fiveruns::Tuneup.step("Filters (#{filters.size})", :controller,
|
88
|
+
"Filters Called" => FiverunsTuneupMerb::Instrumentation.format_filters(filters)
|
89
|
+
) { super }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
module Request
|
98
|
+
|
99
|
+
def new(*args, &block)
|
100
|
+
request = super
|
101
|
+
request.extend(Ext)
|
102
|
+
class << request
|
103
|
+
attr_reader :tuneup
|
104
|
+
end
|
105
|
+
request
|
106
|
+
end
|
107
|
+
|
108
|
+
module Ext
|
109
|
+
|
110
|
+
def dispatch_action(klass, action, *args, &block)
|
111
|
+
controller = nil
|
112
|
+
@tuneup = Fiveruns::Tuneup.record do
|
113
|
+
controller = Fiveruns::Tuneup.step "Dispatching #{klass}##{action}", :controller do
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
117
|
+
# Don't save redirects from panel insertion
|
118
|
+
if controller && controller.headers['Location']
|
119
|
+
::Merb.logger.debug 'TuneUp: Ignoring redirect.'
|
120
|
+
@tuneup = nil
|
121
|
+
elsif xml_http_request?
|
122
|
+
::Merb.logger.debug 'TuneUp: Ignoring XHR request.'
|
123
|
+
@tuneup = nil
|
124
|
+
elsif controller.is_a?(FiverunsTuneupMerb::Application)
|
125
|
+
::Merb.logger.debug 'TuneUp: Ignoring internal request.'
|
126
|
+
@tuneup = nil
|
127
|
+
else
|
128
|
+
::Merb.logger.info 'TuneUp: Valid request.'
|
129
|
+
end
|
130
|
+
controller
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
module DataMapper
|
140
|
+
|
141
|
+
module Repository
|
142
|
+
|
143
|
+
def new(*args, &block)
|
144
|
+
super.extend(Ext)
|
145
|
+
end
|
146
|
+
|
147
|
+
module Ext
|
148
|
+
|
149
|
+
def read_many(query)
|
150
|
+
Fiveruns::Tuneup.step("DM Read Many", :model,
|
151
|
+
'Query' => [
|
152
|
+
FiverunsTuneupMerb::Instrumentation.format_sql(query, adapter.send(:read_statement, query)),
|
153
|
+
{'Raw Details' => FiverunsTuneupMerb::Instrumentation.format_query(query)}
|
154
|
+
]
|
155
|
+
) { super }
|
156
|
+
end
|
157
|
+
|
158
|
+
def read_one(query)
|
159
|
+
Fiveruns::Tuneup.step("DM Read One ", :model,
|
160
|
+
'Query' => [
|
161
|
+
FiverunsTuneupMerb::Instrumentation.format_sql(query, adapter.send(:read_statement, query)),
|
162
|
+
{'Raw Details' => FiverunsTuneupMerb::Instrumentation.format_query(query)}
|
163
|
+
]
|
164
|
+
) { super }
|
165
|
+
end
|
166
|
+
|
167
|
+
def update(attributes, query)
|
168
|
+
Fiveruns::Tuneup.step("DM Update", :model,
|
169
|
+
'Query' => [
|
170
|
+
FiverunsTuneupMerb::Instrumentation.format_sql(query, adapter.send(:update_statement, query), attributes),
|
171
|
+
{'Raw Details' => FiverunsTuneupMerb::Instrumentation.format_query(query)}
|
172
|
+
]
|
173
|
+
) { super }
|
174
|
+
end
|
175
|
+
|
176
|
+
def delete(query)
|
177
|
+
Fiveruns::Tuneup.step("DM Delete", :model,
|
178
|
+
'Query' => [
|
179
|
+
FiverunsTuneupMerb::Instrumentation.format_sql(query, adapter.send(:delete_statement, query)),
|
180
|
+
{'Raw Details' => FiverunsTuneupMerb::Instrumentation.format_query(query)}
|
181
|
+
]
|
182
|
+
) { super }
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :fiveruns_tuneup_merb do
|
3
|
+
|
4
|
+
desc "Install FiverunsTuneupMerb"
|
5
|
+
task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
|
6
|
+
|
7
|
+
desc "Test for any dependencies"
|
8
|
+
task :preflight do # see slicetasks.rb
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Setup directories"
|
12
|
+
task :setup_directories do
|
13
|
+
puts "Creating directories for host application"
|
14
|
+
FiverunsTuneupMerb.mirrored_components.each do |type|
|
15
|
+
if File.directory?(FiverunsTuneupMerb.dir_for(type))
|
16
|
+
if !File.directory?(dst_path = FiverunsTuneupMerb.app_dir_for(type))
|
17
|
+
relative_path = dst_path.relative_path_from(Merb.root)
|
18
|
+
puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
|
19
|
+
mkdir_p(dst_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Copy stub files to host application"
|
26
|
+
task :stubs do
|
27
|
+
puts "Copying stubs for FiverunsTuneupMerb - resolves any collisions"
|
28
|
+
copied, preserved = FiverunsTuneupMerb.mirror_stubs!
|
29
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
30
|
+
copied.each { |f| puts "- copied #{f}" }
|
31
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Copy stub files and views to host application"
|
35
|
+
task :patch => [ "stubs", "freeze:views" ]
|
36
|
+
|
37
|
+
desc "Copy public assets to host application"
|
38
|
+
task :copy_assets do
|
39
|
+
puts "Copying assets for FiverunsTuneupMerb - resolves any collisions"
|
40
|
+
copied, preserved = FiverunsTuneupMerb.mirror_public!
|
41
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
42
|
+
copied.each { |f| puts "- copied #{f}" }
|
43
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Migrate the database"
|
47
|
+
task :migrate do # see slicetasks.rb
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Freeze FiverunsTuneupMerb into your app (only fiveruns_tuneup_merb/app)"
|
51
|
+
task :freeze => [ "freeze:app" ]
|
52
|
+
|
53
|
+
namespace :freeze do
|
54
|
+
|
55
|
+
desc "Freezes FiverunsTuneupMerb by installing the gem into application/gems using merb-freezer"
|
56
|
+
task :gem do
|
57
|
+
begin
|
58
|
+
Object.const_get(:Freezer).freeze(ENV["GEM"] || "fiveruns_tuneup_merb", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
|
59
|
+
rescue NameError
|
60
|
+
puts "! dependency 'merb-freezer' missing"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Freezes FiverunsTuneupMerb by copying all files from fiveruns_tuneup_merb/app to your application"
|
65
|
+
task :app do
|
66
|
+
puts "Copying all fiveruns_tuneup_merb/app files to your application - resolves any collisions"
|
67
|
+
copied, preserved = FiverunsTuneupMerb.mirror_app!
|
68
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
69
|
+
copied.each { |f| puts "- copied #{f}" }
|
70
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Freeze all views into your application for easy modification"
|
74
|
+
task :views do
|
75
|
+
puts "Copying all view templates to your application - resolves any collisions"
|
76
|
+
copied, preserved = FiverunsTuneupMerb.mirror_files_for :view
|
77
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
78
|
+
copied.each { |f| puts "- copied #{f}" }
|
79
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Freeze all models into your application for easy modification"
|
83
|
+
task :models do
|
84
|
+
puts "Copying all models to your application - resolves any collisions"
|
85
|
+
copied, preserved = FiverunsTuneupMerb.mirror_files_for :model
|
86
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
87
|
+
copied.each { |f| puts "- copied #{f}" }
|
88
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Freezes FiverunsTuneupMerb as a gem and copies over fiveruns_tuneup_merb/app"
|
92
|
+
task :app_with_gem => [:gem, :app]
|
93
|
+
|
94
|
+
desc "Freezes FiverunsTuneupMerb by unpacking all files into your application"
|
95
|
+
task :unpack do
|
96
|
+
puts "Unpacking FiverunsTuneupMerb files to your application - resolves any collisions"
|
97
|
+
copied, preserved = FiverunsTuneupMerb.unpack_slice!
|
98
|
+
puts "- no files to copy" if copied.empty? && preserved.empty?
|
99
|
+
copied.each { |f| puts "- copied #{f}" }
|
100
|
+
preserved.each { |f| puts "! preserved override as #{f}" }
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :fiveruns_tuneup_merb do
|
3
|
+
|
4
|
+
# add your own fiveruns_tuneup_merb tasks here
|
5
|
+
|
6
|
+
# implement this to test for structural/code dependencies
|
7
|
+
# like certain directories or availability of other files
|
8
|
+
desc "Test for any dependencies"
|
9
|
+
task :preflight do
|
10
|
+
end
|
11
|
+
|
12
|
+
# implement this to perform any database related setup steps
|
13
|
+
desc "Migrate the database"
|
14
|
+
task :migrate do
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :fiveruns_tuneup_merb do
|
3
|
+
|
4
|
+
desc "Run slice specs within the host application context"
|
5
|
+
task :spec => [ "spec:explain", "spec:default" ]
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
|
9
|
+
slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
10
|
+
|
11
|
+
task :explain do
|
12
|
+
puts "\nNote: By running FiverunsTuneupMerb specs inside the application context any\n" +
|
13
|
+
"overrides could break existing specs. This isn't always a problem,\n" +
|
14
|
+
"especially in the case of views. Use these spec tasks to check how\n" +
|
15
|
+
"well your application conforms to the original slice implementation."
|
16
|
+
end
|
17
|
+
|
18
|
+
Spec::Rake::SpecTask.new('default') do |t|
|
19
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
20
|
+
t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
|
24
|
+
Spec::Rake::SpecTask.new('model') do |t|
|
25
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
26
|
+
if(ENV['MODEL'])
|
27
|
+
t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
|
28
|
+
else
|
29
|
+
t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
|
34
|
+
Spec::Rake::SpecTask.new('controller') do |t|
|
35
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
36
|
+
if(ENV['CONTROLLER'])
|
37
|
+
t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
|
38
|
+
else
|
39
|
+
t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
|
44
|
+
Spec::Rake::SpecTask.new('view') do |t|
|
45
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
46
|
+
if(ENV['CONTROLLER'] and ENV['VIEW'])
|
47
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
|
48
|
+
elsif(ENV['CONTROLLER'])
|
49
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
|
50
|
+
else
|
51
|
+
t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Run all specs and output the result in html"
|
56
|
+
Spec::Rake::SpecTask.new('html') do |t|
|
57
|
+
t.spec_opts = ["--format", "html"]
|
58
|
+
t.libs = ['lib', 'server/lib' ]
|
59
|
+
t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|