devel 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/INSTALL.txt +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/devel.gemspec +29 -0
- data/lib/devel.rb +2 -0
- data/lib/devel/action_controller/view_renderer.rb +26 -0
- data/lib/devel/action_view/view_formatter.rb +31 -0
- data/lib/devel/action_view/view_logger.rb +27 -0
- data/lib/devel/engine.rb +14 -0
- data/lib/devel/version.rb +3 -0
- metadata +126 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/INSTALL.txt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
To have Rails open sent emails in a browser,
|
2
|
+
add the following to your development.rb file:
|
3
|
+
##################################################################
|
4
|
+
config.action_mailer.delivery_method = :letter_opener
|
5
|
+
##################################################################
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Omar Abdel-Wahab
|
2
|
+
|
3
|
+
MIT License
|
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.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Devel
|
2
|
+
|
3
|
+
Devel is a set of tools for Rails Developers.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'devel'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
To enable Letter Opener, just add the following to your `development.rb`:
|
18
|
+
|
19
|
+
config.action_mailer.delivery_method = :letter_opener
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/devel.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devel"
|
8
|
+
spec.version = Devel::VERSION
|
9
|
+
spec.authors = ["Omar Abdel-Wahab"]
|
10
|
+
spec.email = ["owahab@gmail.com"]
|
11
|
+
spec.description = %q{UI Developer Essential Gem}
|
12
|
+
spec.summary = %q{UI Developer Essential Gem}
|
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.post_install_message = File.read("INSTALL.txt")
|
22
|
+
|
23
|
+
spec.required_ruby_version = '>= 1.9.2'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_dependency "rails", ">= 3.2"
|
28
|
+
spec.add_dependency "letter_opener"
|
29
|
+
end
|
data/lib/devel.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Devel
|
2
|
+
module ActionController
|
3
|
+
module ViewRenderer
|
4
|
+
def render(options = {}, locals = {}, &block)
|
5
|
+
output = ''.html_safe
|
6
|
+
case options
|
7
|
+
when Hash
|
8
|
+
if block_given?
|
9
|
+
output << "\n<!-- BEGIN: #{options[:partial]} -->\n".html_safe
|
10
|
+
output << view_renderer.render_partial(self, options.merge(:partial => options[:layout]), &block)
|
11
|
+
output << "\n<!-- END: #{options[:partial]} -->".html_safe
|
12
|
+
else
|
13
|
+
output << "\n<!-- BEGIN: #{options[:partial]} -->\n".html_safe
|
14
|
+
output << view_renderer.render(self, options)
|
15
|
+
output << "\n<!-- END: #{options[:partial]} -->".html_safe
|
16
|
+
end
|
17
|
+
else
|
18
|
+
output << "\n<!-- BEGIN: #{options} -->\n".html_safe
|
19
|
+
output << view_renderer.render_partial(self, :partial => options, :locals => locals)
|
20
|
+
output << "\n<!-- END: #{options} -->".html_safe
|
21
|
+
end
|
22
|
+
output
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Devel
|
2
|
+
module ActionView
|
3
|
+
module ViewFormatter
|
4
|
+
module ClassMethods
|
5
|
+
# def render(*args, &block)
|
6
|
+
# puts "UI Dev Render method fired #1"
|
7
|
+
# end
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
def render
|
12
|
+
puts '$$$$$$$$$$$$'
|
13
|
+
end
|
14
|
+
|
15
|
+
# def render(context, options)
|
16
|
+
# super(context, options)
|
17
|
+
# puts '##########################################'
|
18
|
+
# # pp self
|
19
|
+
# # debugger
|
20
|
+
# # self.view_flow.content[:layout] = "<!-- BEGIN: #{args[0][:partial]} -->\n #{self.view_flow.content[:layout]}\n<!-- END: #{args[0][:partial]} -->"
|
21
|
+
# # puts args
|
22
|
+
# end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.included(base)
|
26
|
+
base.extend ClassMethods
|
27
|
+
base.send :include, InstanceMethods
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Devel
|
2
|
+
module ActionView
|
3
|
+
class ViewLogger < ::ActiveSupport::LogSubscriber
|
4
|
+
VIEWS_PATTERN = /^app\/views\//.freeze
|
5
|
+
|
6
|
+
def render_template(event)
|
7
|
+
return unless logger.info?
|
8
|
+
# message = " ** Rendered #{from_rails_root(event.payload[:identifier])}"
|
9
|
+
# message << " *** within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
|
10
|
+
# message << " *** (#{event.duration.round(1)}ms)"
|
11
|
+
# info(message)
|
12
|
+
end
|
13
|
+
alias :render_partial :render_template
|
14
|
+
alias :render_collection :render_template
|
15
|
+
|
16
|
+
def logger
|
17
|
+
::ActionView::Base.logger
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def from_rails_root(string)
|
23
|
+
string.sub("#{Rails.root}/", "").sub(VIEWS_PATTERN, "")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/devel/engine.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'devel/action_view/view_logger'
|
2
|
+
require 'devel/action_view/view_formatter'
|
3
|
+
require 'devel/action_controller/view_renderer'
|
4
|
+
|
5
|
+
module Devel
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
initializer 'devel.initialize' do |app|
|
8
|
+
# Register our view renderer
|
9
|
+
app.config.to_prepare do
|
10
|
+
::ActionController::Base.send :helper, Devel::ActionController::ViewRenderer
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Omar Abdel-Wahab
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: letter_opener
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: UI Developer Essential Gem
|
79
|
+
email:
|
80
|
+
- owahab@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- INSTALL.txt
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- devel.gemspec
|
92
|
+
- lib/devel.rb
|
93
|
+
- lib/devel/action_controller/view_renderer.rb
|
94
|
+
- lib/devel/action_view/view_formatter.rb
|
95
|
+
- lib/devel/action_view/view_logger.rb
|
96
|
+
- lib/devel/engine.rb
|
97
|
+
- lib/devel/version.rb
|
98
|
+
homepage: ''
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message: ! "To have Rails open sent emails in a browser,\nadd the following
|
102
|
+
to your development.rb file:\n##################################################################\n
|
103
|
+
\ config.action_mailer.delivery_method = :letter_opener\n##################################################################"
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.9.2
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 1.8.23
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: UI Developer Essential Gem
|
125
|
+
test_files: []
|
126
|
+
has_rdoc:
|