hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Busbey (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-11686) Shell code should create a binding / irb workspace instead of polluting the root namespace
Date Wed, 06 Aug 2014 19:02:12 GMT

    [ https://issues.apache.org/jira/browse/HBASE-11686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14088049#comment-14088049

Sean Busbey commented on HBASE-11686:

an example of the complication that's just fall out of the main namespace pollution: you can't
write tests that work on the exported command unless you know to construct an object that
has a member variable '@shell'

> Shell code should create a binding / irb workspace instead of polluting the root namespace
> ------------------------------------------------------------------------------------------
>                 Key: HBASE-11686
>                 URL: https://issues.apache.org/jira/browse/HBASE-11686
>             Project: HBase
>          Issue Type: Improvement
>            Reporter: Sean Busbey
>            Priority: Minor
> Right now, the shell builds a list of commands and then injects them into the root exectution's
> bin/hirb.rb
> {code}
> # Add commands to this namespace
> @shell.export_commands(self)
> {code}
> hbase-shell/src/main/ruby/shell.rb
> {code}
>     def export_commands(where)
>       ::Shell.commands.keys.each do |cmd|
>         # here where is the IRB namespace
>         # this method just adds the call to the specified command
>         # which just references back to 'this' shell object
>         # a decently extensible way to add commands
>         where.send :instance_eval, <<-EOF
>           def #{cmd}(*args)
>             ret = @shell.command('#{cmd}', *args)
>             puts
>             return ret
>           end
>         EOF
>       end
>     end
> {code}
> This is an unclean abstraction. For one, it requires that there be an instance variable
in the main namespace called '@shell' without making that clear in the docs. Additionally,
it complicates maintenance by breaking isolation.
> We should update things so that shell can provide a binding for eval or a workspace for
IRB execution and then use it directly when we construct our IRB session.

This message was sent by Atlassian JIRA

View raw message