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.1.29 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.28 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.27 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.26 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.25 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.24 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.23 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.22 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.21 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.20 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.19 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.18 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.17 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.16 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.15 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.14 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.13 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.12 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.11 roles/qb.gem/filter_plugins/ruby_constantize.py
qb-0.1.10 roles/qb.gem/filter_plugins/ruby_constantize.py