hocus_pocus 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/hocus_pocus.gemspec +3 -3
- data/lib/hocus_pocus/filter.rb +1 -1
- data/lib/hocus_pocus/version.rb +1 -1
- metadata +8 -9
- data/lib/hocus_pocus/content_appender.rb +0 -76
data/CHANGELOG
CHANGED
data/hocus_pocus.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ['Akira Matsuda']
|
10
10
|
s.email = ['ronnie@dio.jp']
|
11
|
-
s.homepage = '
|
12
|
-
s.summary = '
|
13
|
-
s.description = '
|
11
|
+
s.homepage = 'https://github.com/amatsuda/hocus_pocus'
|
12
|
+
s.summary = 'A magical Engine that casts a spell on your Rails 3.1 app'
|
13
|
+
s.description = 'A magical Engine that casts a spell on your Rails 3.1 app'
|
14
14
|
|
15
15
|
s.rubyforge_project = 'hocus_pocus'
|
16
16
|
|
data/lib/hocus_pocus/filter.rb
CHANGED
@@ -33,7 +33,7 @@ module HocusPocus
|
|
33
33
|
$('form').live('submit', function() {
|
34
34
|
var scenario = [" scenario '#{@controller.action_name.humanize} #{@controller.controller_name.humanize}' do"];
|
35
35
|
scenario.push(" visit '" + window.location.href + "'");
|
36
|
-
$(this).find('input[type=text],textarea').each(function() {
|
36
|
+
$(this).find('input[type=text],input[type=email],input[type=url],input[type=number],input[type=search],textarea').each(function() {
|
37
37
|
scenario.push(" fill_in '" + $(this).attr('id') + "', :with => '" + $(this).val() + "'");
|
38
38
|
});
|
39
39
|
$(this).find('select').each(function() {
|
data/lib/hocus_pocus/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hocus_pocus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: nested_scaffold
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
|
-
description:
|
36
|
+
description: A magical Engine that casts a spell on your Rails 3.1 app
|
37
37
|
email:
|
38
38
|
- ronnie@dio.jp
|
39
39
|
executables: []
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- lib/generators/hocus_pocus/templates/hocus_pocus_config.rb
|
70
70
|
- lib/hocus_pocus.rb
|
71
71
|
- lib/hocus_pocus/config.rb
|
72
|
-
- lib/hocus_pocus/content_appender.rb
|
73
72
|
- lib/hocus_pocus/engine.rb
|
74
73
|
- lib/hocus_pocus/filter.rb
|
75
74
|
- lib/hocus_pocus/railtie.rb
|
@@ -78,7 +77,7 @@ files:
|
|
78
77
|
- test/helper.rb
|
79
78
|
- test/test_hocus_pocus.rb
|
80
79
|
- vendor/assets/javascripts/jquery_ujs.js
|
81
|
-
homepage:
|
80
|
+
homepage: https://github.com/amatsuda/hocus_pocus
|
82
81
|
licenses:
|
83
82
|
- MIT
|
84
83
|
post_install_message:
|
@@ -107,10 +106,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
106
|
requirements: []
|
108
107
|
|
109
108
|
rubyforge_project: hocus_pocus
|
110
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.9
|
111
110
|
signing_key:
|
112
111
|
specification_version: 3
|
113
|
-
summary:
|
112
|
+
summary: A magical Engine that casts a spell on your Rails 3.1 app
|
114
113
|
test_files:
|
115
114
|
- test/helper.rb
|
116
115
|
- test/test_hocus_pocus.rb
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module HocusPocus
|
2
|
-
class ContentAppender
|
3
|
-
def initialize(app)
|
4
|
-
@app = app
|
5
|
-
end
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
# controller.flash[HocusPocus::SPEC] = controller.params[HocusPocus::SPEC] if controller.params[HocusPocus::SPEC]
|
9
|
-
# controller.flash.keep(HocusPocus::SPEC)
|
10
|
-
|
11
|
-
@app.call(env).tap do |status, headers, body|
|
12
|
-
if body.respond_to? :body
|
13
|
-
@body = body.body
|
14
|
-
@controller_name = env['action_dispatch.request.path_parameters'][:controller]
|
15
|
-
@action_name = env['action_dispatch.request.path_parameters'][:action]
|
16
|
-
unless headers['Content-Type'].starts_with?('text/html')
|
17
|
-
#FIXME avoid loading jquery twice
|
18
|
-
# add_jquery
|
19
|
-
add_steak_recorder
|
20
|
-
# add_js
|
21
|
-
unless controller.start_with? 'hocus_pocus/'
|
22
|
-
add_buttons
|
23
|
-
end
|
24
|
-
# add_command_line
|
25
|
-
body.body = @body
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
def add_steak_recorder
|
32
|
-
#TODO exclude EDITOR and GENERATOR
|
33
|
-
insert_text :before, /<\/body>/i, <<-TEPPAN
|
34
|
-
<script type="text/javascript">
|
35
|
-
$('form').live('submit', function() {
|
36
|
-
var scenario = [" scenario '#{@action_name.humanize} #{@controller_name.humanize}' do"];
|
37
|
-
scenario.push(" visit '" + window.location.href + "'");
|
38
|
-
$(this).find('input[type=text]').each(function() {
|
39
|
-
scenario.push(" fill_in '" + $(this).attr('id') + "', :with => '" + $(this).val() + "'");
|
40
|
-
});
|
41
|
-
scenario.push(" click_button '" + $(this).find('input[type=submit]').val() + "'");
|
42
|
-
$(this).append('<textarea id="#{HocusPocus::SPEC}" name="#{HocusPocus::SPEC}" style="height: 0px; width: 0px;" />');
|
43
|
-
$('##{HocusPocus::SPEC}').val(scenario.join('\\n'));
|
44
|
-
})
|
45
|
-
</script>
|
46
|
-
TEPPAN
|
47
|
-
end
|
48
|
-
|
49
|
-
def add_buttons
|
50
|
-
#FIXME path
|
51
|
-
#FIXME use @template somehow?
|
52
|
-
edit_link = %Q[<a href="/editor?template=#{@controller.controller_name}/#{@controller.action_name}" data-remote="true" onclick="$(this).closest('div').find('div.partials').toggle()">edit</a>]
|
53
|
-
spec_link = %Q[<a href="#" onclick="$(this).closest('div').find('div.spec').toggle();">spec</a>]
|
54
|
-
partials = %Q[<div class="partials" style="display:none">#{(Thread.current[HocusPocus::VIEW_FILENAMES] || []).map(&:virtual_path).map {|v| '<a href="/editor?template=' + v + '" data-remote="true">' + v + '</a>'}.join('<br>')}</div>]
|
55
|
-
#FIXME more assertions
|
56
|
-
spec = %Q[<div class="spec" style="display:none"><pre>#{CGI.unescape(@controller.flash[HocusPocus::SPEC]) + "\n end" if @controller.flash[HocusPocus::SPEC]}</pre></div>]
|
57
|
-
|
58
|
-
insert_text :before, /<\/body>/i, %Q[<div style="position:absolute; top:0; right: 0;">#{edit_link} | #{spec_link}<br>#{partials}<br>#{spec}</div>]
|
59
|
-
Thread.current[HocusPocus::VIEW_FILENAMES] = nil
|
60
|
-
end
|
61
|
-
|
62
|
-
def insert_text(position, pattern, new_text)
|
63
|
-
index = case pattern
|
64
|
-
when Regexp
|
65
|
-
if match = @body.match(pattern)
|
66
|
-
match.offset(0)[position == :before ? 0 : 1]
|
67
|
-
else
|
68
|
-
@body.size
|
69
|
-
end
|
70
|
-
else
|
71
|
-
pattern
|
72
|
-
end
|
73
|
-
@body.insert index, new_text
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|