Skip to content

Commit

Permalink
Issue #100: Minor fixes to the nice /Users/lakshmivyas/.environments/…
Browse files Browse the repository at this point in the history
…hyde/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin based exec discovery by @nud
  • Loading branch information
navilan committed Nov 9, 2011
1 parent a736691 commit b39464a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 38 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.rst
Expand Up @@ -3,8 +3,7 @@ Version 0.8.4c16

Thanks to @nud

* Bug Fix: Fix class name of `test_stylus` (Issue #97)

* Bug Fix: Fix class name of `test_stylus` (Issue #97)

Version 0.8.4c15
============================================================
Expand Down
6 changes: 4 additions & 2 deletions hyde/ext/plugins/less.py
Expand Up @@ -15,11 +15,13 @@ class LessCSSPlugin(CLTransformer):
The plugin class for less css
"""

default_app_path = "lessc"

def __init__(self, site):
super(LessCSSPlugin, self).__init__(site)

@property
def executable_name(self):
return "lessc"

def begin_site(self):
"""
Find all the less css files and set their relative deploy path.
Expand Down
6 changes: 4 additions & 2 deletions hyde/ext/plugins/uglify.py
Expand Up @@ -11,11 +11,13 @@ class UglifyPlugin(CLTransformer):
The plugin class for Uglify JS
"""

default_app_path = "uglifyjs"

def __init__(self, site):
super(UglifyPlugin, self).__init__(site)

@property
def executable_name(self):
return "uglifyjs"

@property
def plugin_name(self):
"""
Expand Down
20 changes: 14 additions & 6 deletions hyde/plugin.py
Expand Up @@ -18,7 +18,6 @@
import subprocess
import traceback


logger = getLoggerWithNullHandler('hyde.engine')

class PluginProxy(object):
Expand Down Expand Up @@ -207,6 +206,8 @@ class CLTransformer(Plugin):
def plugin_name(self):
"""
The name of the plugin. Makes an intelligent guess.
This is used to lookup the settings for the plugin.
"""

return self.__class__.__name__.replace('Plugin', '').lower()
Expand All @@ -221,10 +222,11 @@ def defaults(self):
return {}

@property
def default_app_path(self):
def executable_name(self):
"""
Default command line application path. Can be overridden
by specifying it in config.
The executable name for the plugin. This can be overridden in the
config. If a configuration option is not provided, this is used
to guess the complete path of the executable.
"""
return self.plugin_name

Expand All @@ -237,7 +239,10 @@ def executable_not_found_message(self):

return ("%(name)s executable path not configured properly. "
"This plugin expects `%(name)s.app` to point "
"to the `%(name)s` executable." % {"name": self.plugin_name})
"to the full path of the `%(exec)s` executable." %
{
"name":self.plugin_name, "exec": self.executable_name
})

@property
def settings(self):
Expand All @@ -256,12 +261,15 @@ def settings(self):
def app(self):
"""
Gets the application path from the site configuration.
If the path is not configured, attempts to guess the path
from the sytem path environment variable.
"""

try:
app_path = getattr(self.settings, 'app')
except AttributeError:
app_path = self.default_app_path
app_path = self.executable_name

# Honour the PATH environment variable.
if app_path is not None and not os.path.isabs(app_path):
Expand Down
4 changes: 0 additions & 4 deletions hyde/tests/ext/test_less.py
Expand Up @@ -29,10 +29,6 @@ def tearDown(self):
def test_can_execute_less(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.less.LessCSSPlugin']
paths = ['/usr/local/share/npm/bin/lessc']
for path in paths:
if File(path).exists:
s.config.less = Expando(dict(app=path))
source = TEST_SITE.child('content/media/css/site.less')
target = File(Folder(s.config.deploy_root_path).child('media/css/site.css'))
gen = Generator(s)
Expand Down
23 changes: 2 additions & 21 deletions hyde/tests/ext/test_uglify.py
Expand Up @@ -22,7 +22,7 @@ def setUp(self):
JS = TEST_SITE.child_folder('content/media/js')
JS.make()
UGLIFY_SOURCE.copy_contents_to(JS)


def tearDown(self):
TEST_SITE.delete()
Expand All @@ -31,10 +31,6 @@ def test_can_uglify(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "production"
paths = ['/usr/local/share/npm/bin/uglifyjs']
for path in paths:
if File(path).exists:
s.config.uglify = Expando(dict(app=path))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
Expand All @@ -49,14 +45,7 @@ def test_uglify_with_extra_options(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "production"
paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs',
'/usr/bin/uglifyjs', '~/bin/uglifyjs']
uglify = [path for path in paths if File(path).exists]
if not uglify:
assert False, "Cannot find the uglify executable"

uglify = uglify[0]
s.config.uglify = Expando(dict(app=uglify, args={"nc":""}))
s.config.uglify = Expando(dict(args={"nc":""}))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
Expand All @@ -72,14 +61,6 @@ def test_no_uglify_in_dev_mode(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "dev"
paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs',
'/usr/bin/uglifyjs', '~/bin/uglifyjs']
uglify = [path for path in paths if File(path).exists]
if not uglify:
assert False, "Cannot find the uglify executable"

uglify = uglify[0]
s.config.uglify = Expando(dict(app=path))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
Expand Down
2 changes: 1 addition & 1 deletion hyde/util.py
Expand Up @@ -133,4 +133,4 @@ def discover_executable(name):
full_name = os.path.join(path, name)
if os.path.exists(full_name):
return full_name
return None
return None

0 comments on commit b39464a

Please sign in to comment.