Sha256: 873c4d050b6a73692537bded23741e35ea6196d3854cd1d63d7694cacd42384e

Contents?: true

Size: 724 Bytes

Versions: 90

Compression:

Stored size: 724 Bytes

Contents

import re
import subprocess
import pipes
from ansible import errors

# from bundler's implementation
# 
#       name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
# 
# https://github.com/bundler/bundler/blob/7ae072865e3fc23d9844322dde6ad0f6906e3f2c/lib/bundler/cli/gem.rb#L29
# 
def ruby_constantize(s):
    ruby = 'puts "%s".gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }' % s
    return subprocess.check_output("/usr/bin/env ruby -e %s" % pipes.quote(ruby), shell=True).rstrip()

class FilterModule(object):
    '''ruby_constantize filter'''

    def filters(self):
        return {
            'ruby_constantize': ruby_constantize,
        }

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
qb-0.3.1 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.88 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.87 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.86 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.85 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.84 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.83 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.82 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.81 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.80 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.79 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.78 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.77 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.76 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.75 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.74 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.73 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.72 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.71 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.70 roles/qb.gem/filter_plugins/ruby_constantize.py