contao 0.4.2 → 0.5.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/contao.gemspec +2 -8
- data/lib/contao.rb +1 -54
- data/lib/contao/application.rb +13 -23
- data/lib/contao/commands/help.rb +1 -1
- data/lib/contao/generators/base.rb +1 -3
- data/lib/contao/notifier.rb +3 -3
- data/lib/contao/railtie.rb +11 -0
- data/lib/contao/ui.rb +219 -0
- data/lib/contao/version.rb +1 -1
- data/lib/{contao/tasks → tasks}/contao.rake +18 -19
- data/lib/{contao/tasks → tasks}/whitespace.rake +0 -0
- data/spec/lib/contao/application_spec.rb +6 -8
- data/spec/lib/contao/notifier_spec.rb +15 -15
- data/spec/spec_helper.rb +6 -14
- data/spec/support/filesystem_mock.rb +40 -11
- data/spec/support/stub_rails.rb +29 -0
- metadata +12 -128
- data/lib/contao/coffeescript_compiler.rb +0 -58
- data/lib/contao/compiler.rb +0 -128
- data/lib/contao/javascript_compiler.rb +0 -77
- data/lib/contao/stylesheet_compiler.rb +0 -56
- data/lib/contao/tasks/assets.rake +0 -22
- data/lib/contao/tasks/jasmine.rake +0 -8
- data/lib/guard/assets.rb +0 -117
- data/lib/monkey_patches.rb +0 -1
- data/lib/monkey_patches/compass/urls.rb +0 -81
- data/spec/lib/contao/coffeescript_compiler_spec.rb +0 -85
- data/spec/lib/contao/javascript_compiler_spec.rb +0 -91
- data/spec/lib/contao/stylesheet_compiler_spec.rb +0 -117
- data/spec/lib/contao_spec.rb +0 -62
- data/spec/lib/guard/assets_spec.rb +0 -220
- data/spec/support/compiler_shared_examples.rb +0 -292
- data/spec/support/config_shared_examples.rb +0 -29
data/contao.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/contao/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ['Wael Nasreddine']
|
6
6
|
gem.email = ['wael.nasreddine@gmail.com']
|
7
|
-
gem.description = %q{Contao Integration with
|
7
|
+
gem.description = %q{Contao Integration with Rails.}
|
8
8
|
gem.summary = <<-EOS
|
9
9
|
This gem will help you to quickly generate an application using Contao
|
10
10
|
CMS which has pre-built support for Sass, Compass, CoffeeScript, Jasmine
|
@@ -18,7 +18,7 @@ The integration with Capistrano allows you to quickly deploy, copy
|
|
18
18
|
assets, import database and even upload media such as images and PDFs
|
19
19
|
all from the command line using Capistrano.
|
20
20
|
EOS
|
21
|
-
gem.homepage =
|
21
|
+
gem.homepage = 'http://technogate.github.com/contao'
|
22
22
|
gem.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
|
23
23
|
|
24
24
|
gem.files = `git ls-files`.split($\)
|
@@ -31,15 +31,9 @@ all from the command line using Capistrano.
|
|
31
31
|
|
32
32
|
# Runtime dependencies
|
33
33
|
gem.add_dependency 'rake'
|
34
|
-
gem.add_dependency 'compass'
|
35
|
-
gem.add_dependency 'oily_png'
|
36
|
-
gem.add_dependency 'uglifier'
|
37
34
|
gem.add_dependency 'activesupport'
|
38
|
-
gem.add_dependency 'guard', '>= 1.1.1'
|
39
|
-
gem.add_dependency 'json'
|
40
35
|
gem.add_dependency 'parseconfig'
|
41
36
|
gem.add_dependency 'highline'
|
42
|
-
gem.add_dependency 'coffee-script'
|
43
37
|
|
44
38
|
# Development dependencies
|
45
39
|
gem.add_development_dependency 'rspec'
|
data/lib/contao.rb
CHANGED
@@ -5,63 +5,10 @@ require 'ostruct'
|
|
5
5
|
|
6
6
|
module TechnoGate
|
7
7
|
module Contao
|
8
|
-
|
9
|
-
class RootNotSet < RuntimeError; end
|
10
|
-
|
11
|
-
# Get the currently running environment
|
12
|
-
#
|
13
|
-
# @return [Symbol] Currently running environment
|
14
|
-
def self.env
|
15
|
-
@@env
|
16
|
-
end
|
17
|
-
|
18
|
-
# Set the environment
|
19
|
-
#
|
20
|
-
# @param [Symbol] Environment
|
21
|
-
def self.env=(env)
|
22
|
-
@@env = env
|
23
|
-
end
|
24
|
-
|
25
|
-
# Get the currently running rootironment
|
26
|
-
#
|
27
|
-
# @return [Symbol] Currently running rootironment
|
28
|
-
def self.root
|
29
|
-
@@root
|
30
|
-
end
|
31
|
-
|
32
|
-
# Set the rootironment
|
33
|
-
#
|
34
|
-
# @param [Symbol] rootironment
|
35
|
-
def self.root=(root)
|
36
|
-
@@root = Pathname.new(root).expand_path
|
37
|
-
end
|
38
|
-
|
39
|
-
# Expandify a path
|
40
|
-
#
|
41
|
-
# @param [String] Path
|
42
|
-
# @return [Pathname] Path converted to absolute path
|
43
|
-
# raises RootNotSet
|
44
|
-
def self.expandify(path)
|
45
|
-
raise RootNotSet unless root
|
46
|
-
|
47
|
-
if path.to_s.start_with? "/"
|
48
|
-
Pathname(path).expand_path
|
49
|
-
else
|
50
|
-
root.join(path)
|
51
|
-
end
|
52
|
-
end
|
53
8
|
end
|
54
9
|
end
|
55
10
|
|
56
11
|
# Contao
|
57
12
|
require 'contao/application'
|
58
13
|
require 'contao/notifier'
|
59
|
-
require 'contao/
|
60
|
-
require 'contao/javascript_compiler'
|
61
|
-
require 'contao/stylesheet_compiler'
|
62
|
-
|
63
|
-
# Guard
|
64
|
-
require 'guard/assets'
|
65
|
-
|
66
|
-
# Monkey patches
|
67
|
-
require 'monkey_patches'
|
14
|
+
require 'contao/railtie' if defined?(Rails)
|
data/lib/contao/application.rb
CHANGED
@@ -9,24 +9,15 @@ module TechnoGate
|
|
9
9
|
include Singleton
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
super
|
13
|
-
|
14
|
-
init_config
|
15
12
|
parse_global_config
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.configure(&block)
|
19
|
-
instance.instance_eval(&block)
|
20
|
-
end
|
21
13
|
|
22
|
-
|
23
|
-
instance.config
|
14
|
+
super
|
24
15
|
end
|
25
16
|
|
26
17
|
def linkify
|
27
18
|
exhaustive_list_of_files_to_link(
|
28
|
-
|
29
|
-
|
19
|
+
Rails.root.join(config.contao_path),
|
20
|
+
Rails.public_path
|
30
21
|
).each do |list|
|
31
22
|
FileUtils.ln_s list[0], list[1]
|
32
23
|
end
|
@@ -36,18 +27,22 @@ module TechnoGate
|
|
36
27
|
instance.linkify
|
37
28
|
end
|
38
29
|
|
39
|
-
def self.load_tasks
|
40
|
-
Dir["#{File.expand_path '../tasks', __FILE__}/**/*.rake"].each {|f| load f}
|
41
|
-
end
|
42
|
-
|
43
30
|
def name
|
44
|
-
|
31
|
+
config.application_name || File.basename(Rails.root)
|
45
32
|
end
|
46
33
|
|
47
34
|
def self.name
|
48
35
|
instance.name
|
49
36
|
end
|
50
37
|
|
38
|
+
def config
|
39
|
+
Rails.application.config
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.config
|
43
|
+
instance.config
|
44
|
+
end
|
45
|
+
|
51
46
|
def self.default_global_config(options = {})
|
52
47
|
{
|
53
48
|
'install_password' => '',
|
@@ -77,15 +72,10 @@ module TechnoGate
|
|
77
72
|
|
78
73
|
protected
|
79
74
|
|
80
|
-
# Initialize the config
|
81
|
-
def init_config
|
82
|
-
self.config = OpenStruct.new
|
83
|
-
end
|
84
|
-
|
85
75
|
# Parse the global yaml configuration file
|
86
76
|
def parse_global_config
|
87
77
|
if File.exists? global_config_path
|
88
|
-
|
78
|
+
config.contao_global_config = YAML.load(File.read(global_config_path)).to_openstruct
|
89
79
|
end
|
90
80
|
end
|
91
81
|
|
data/lib/contao/commands/help.rb
CHANGED
@@ -16,7 +16,7 @@ def print_help
|
|
16
16
|
|
17
17
|
To generate a new project, use the following command:
|
18
18
|
|
19
|
-
|
19
|
+
$ contao new /path/to/application
|
20
20
|
|
21
21
|
The generated application will be created at /path/to/application and the
|
22
22
|
application name would be set to the last component in the path, in this
|
data/lib/contao/notifier.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'contao/ui'
|
2
2
|
|
3
3
|
module TechnoGate
|
4
4
|
module Contao
|
@@ -22,13 +22,13 @@ module TechnoGate
|
|
22
22
|
def say(message, options = {})
|
23
23
|
color = options.delete(:color)
|
24
24
|
|
25
|
-
if
|
25
|
+
if UI.send(:color_enabled?)
|
26
26
|
message = "\e[0;34mContao>>\e[0m \e[0;#{color}m#{message}\e[0m"
|
27
27
|
else
|
28
28
|
message = "Contao>> #{message}"
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
UI.info(message, options)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/contao/ui.rb
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
module TechnoGate
|
2
|
+
module Contao
|
3
|
+
# The UI class helps to format messages for the user. Everything that is logged
|
4
|
+
# through this class is considered either as an error message or a diagnostic
|
5
|
+
# message and is written to standard error (STDERR).
|
6
|
+
#
|
7
|
+
# If your Guard does some output that is piped into another process for further
|
8
|
+
# processing, please just write it to STDOUT with `puts`.
|
9
|
+
#
|
10
|
+
module UI
|
11
|
+
class << self
|
12
|
+
|
13
|
+
color_enabled = nil
|
14
|
+
|
15
|
+
# Show an info message.
|
16
|
+
#
|
17
|
+
# @param [String] message the message to show
|
18
|
+
# @option options [Boolean] reset whether to clean the output before
|
19
|
+
#
|
20
|
+
def info(message, options = { })
|
21
|
+
unless ENV['RAILS_ENV'] == 'test'
|
22
|
+
reset_line if options[:reset]
|
23
|
+
STDERR.puts color(message) if message != ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Show a yellow warning message that is prefixed with WARNING.
|
28
|
+
#
|
29
|
+
# @param [String] message the message to show
|
30
|
+
# @option options [Boolean] reset whether to clean the output before
|
31
|
+
#
|
32
|
+
def warning(message, options = { })
|
33
|
+
unless ENV['RAILS_ENV'] == 'test'
|
34
|
+
reset_line if options[:reset]
|
35
|
+
STDERR.puts color('WARNING: ', :yellow) + message
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Show a red error message that is prefixed with ERROR.
|
40
|
+
#
|
41
|
+
# @param [String] message the message to show
|
42
|
+
# @option options [Boolean] reset whether to clean the output before
|
43
|
+
#
|
44
|
+
def error(message, options = { })
|
45
|
+
unless ENV['RAILS_ENV'] == 'test'
|
46
|
+
reset_line if options[:reset]
|
47
|
+
STDERR.puts color('ERROR: ', :red) + message
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Show a red deprecation message that is prefixed with DEPRECATION.
|
52
|
+
#
|
53
|
+
# @param [String] message the message to show
|
54
|
+
# @option options [Boolean] reset whether to clean the output before
|
55
|
+
#
|
56
|
+
def deprecation(message, options = { })
|
57
|
+
unless ENV['RAILS_ENV'] == 'test'
|
58
|
+
reset_line if options[:reset]
|
59
|
+
STDERR.puts color('DEPRECATION: ', :red) + message
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Show a debug message that is prefixed with DEBUG and a timestamp.
|
64
|
+
#
|
65
|
+
# @param [String] message the message to show
|
66
|
+
# @option options [Boolean] reset whether to clean the output before
|
67
|
+
#
|
68
|
+
def debug(message, options = { })
|
69
|
+
unless ENV['RAILS_ENV'] == 'test'
|
70
|
+
reset_line if options[:reset]
|
71
|
+
STDERR.puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:debug]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Reset a line.
|
76
|
+
#
|
77
|
+
def reset_line
|
78
|
+
STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
# Clear the output.
|
82
|
+
#
|
83
|
+
def clear
|
84
|
+
system('clear;')
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show a scoped action message.
|
88
|
+
#
|
89
|
+
# @param [String] action the action to show
|
90
|
+
# @param [Hash] scopes an hash with a guard or a group scope
|
91
|
+
#
|
92
|
+
def action_with_scopes(action, scopes)
|
93
|
+
scope_message ||= scopes[:contao]
|
94
|
+
scope_message ||= scopes[:group]
|
95
|
+
scope_message ||= 'all'
|
96
|
+
|
97
|
+
info "#{action} #{scope_message}"
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
# Reset a color sequence.
|
103
|
+
#
|
104
|
+
# @deprecated
|
105
|
+
# @param [String] text the text
|
106
|
+
#
|
107
|
+
def reset_color(text)
|
108
|
+
deprecation('UI.reset_color(text) is deprecated, please use color(text, ' ') instead.')
|
109
|
+
color(text, '')
|
110
|
+
end
|
111
|
+
|
112
|
+
# Checks if color output can be enabled.
|
113
|
+
#
|
114
|
+
# @return [Boolean] whether color is enabled or not
|
115
|
+
#
|
116
|
+
def color_enabled?
|
117
|
+
if @color_enabled.nil?
|
118
|
+
if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
119
|
+
if ENV['ANSICON']
|
120
|
+
@color_enabled = true
|
121
|
+
else
|
122
|
+
begin
|
123
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
124
|
+
require 'Win32/Console/ANSI'
|
125
|
+
@color_enabled = true
|
126
|
+
rescue LoadError
|
127
|
+
@color_enabled = false
|
128
|
+
info "You must 'gem install win32console' to use color on Windows"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
else
|
132
|
+
@color_enabled = true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
@color_enabled
|
137
|
+
end
|
138
|
+
|
139
|
+
# Colorizes a text message. See the constant in the UI class for possible
|
140
|
+
# color_options parameters. You can pass optionally :bright, a foreground
|
141
|
+
# color and a background color.
|
142
|
+
#
|
143
|
+
# @example
|
144
|
+
#
|
145
|
+
# color('Hello World', :red, :bright)
|
146
|
+
#
|
147
|
+
# @param [String] text the text to colorize
|
148
|
+
# @param [Array] color_options the color options
|
149
|
+
#
|
150
|
+
def color(text, *color_options)
|
151
|
+
color_code = ''
|
152
|
+
color_options.each do |color_option|
|
153
|
+
color_option = color_option.to_s
|
154
|
+
if color_option != ''
|
155
|
+
if !(color_option =~ /\d+/)
|
156
|
+
color_option = const_get("ANSI_ESCAPE_#{ color_option.upcase }")
|
157
|
+
end
|
158
|
+
color_code += ';' + color_option
|
159
|
+
end
|
160
|
+
end
|
161
|
+
color_enabled? ? "\e[0#{ color_code }m#{ text }\e[0m" : text
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
# Brighten the color
|
167
|
+
ANSI_ESCAPE_BRIGHT = '1'
|
168
|
+
|
169
|
+
# Black foreground color
|
170
|
+
ANSI_ESCAPE_BLACK = '30'
|
171
|
+
|
172
|
+
# Red foreground color
|
173
|
+
ANSI_ESCAPE_RED = '31'
|
174
|
+
|
175
|
+
# Green foreground color
|
176
|
+
ANSI_ESCAPE_GREEN = '32'
|
177
|
+
|
178
|
+
# Yellow foreground color
|
179
|
+
ANSI_ESCAPE_YELLOW = '33'
|
180
|
+
|
181
|
+
# Blue foreground color
|
182
|
+
ANSI_ESCAPE_BLUE = '34'
|
183
|
+
|
184
|
+
# Magenta foreground color
|
185
|
+
ANSI_ESCAPE_MAGENTA = '35'
|
186
|
+
|
187
|
+
# Cyan foreground color
|
188
|
+
ANSI_ESCAPE_CYAN = '36'
|
189
|
+
|
190
|
+
# White foreground color
|
191
|
+
ANSI_ESCAPE_WHITE = '37'
|
192
|
+
|
193
|
+
# Black background color
|
194
|
+
ANSI_ESCAPE_BGBLACK = '40'
|
195
|
+
|
196
|
+
# Red background color
|
197
|
+
ANSI_ESCAPE_BGRED = '41'
|
198
|
+
|
199
|
+
# Green background color
|
200
|
+
ANSI_ESCAPE_BGGREEN = '42'
|
201
|
+
|
202
|
+
# Yellow background color
|
203
|
+
ANSI_ESCAPE_BGYELLOW = '43'
|
204
|
+
|
205
|
+
# Blue background color
|
206
|
+
ANSI_ESCAPE_BGBLUE = '44'
|
207
|
+
|
208
|
+
# Magenta background color
|
209
|
+
ANSI_ESCAPE_BGMAGENTA = '45'
|
210
|
+
|
211
|
+
# Cyan background color
|
212
|
+
ANSI_ESCAPE_BGCYAN = '46'
|
213
|
+
|
214
|
+
# White background color
|
215
|
+
ANSI_ESCAPE_BGWHITE = '47'
|
216
|
+
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|