Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3338

ConfigSlurper to support node key with hyphen

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.6-rc-2
    • 1.6-rc-2
    • None
    • None

    Description

      not sure if it is technically doable. but allowing parameter name with hyphen will help a lot to Grails Config.groovy

      for one of my use cases, i have a Grails PHP Plugin that allow user to specify some servlet init-param. Ideally, the parameter name shall be identical to the original parameter name used by the underlying PHP Servlet. one of the name that i have failed to use is 'ini-file'.

      for ConfigSlurperTest

        public void testNodeKeyWithHyphen(){
          println "testNodeKeyWithHyphen"
          def slurper = new ConfigSlurper()
      
          def config = slurper.parse('''
      init-param{
        param-name = 'foo'
        param-value = 'bar'
      }
      ''')
      
          assert config
          assertNotNull config.'init-param'
          assertFalse config.'init-param' instanceof ConfigObject
          assertEquals 'foo',config.'init-param'.'param-name'
        }
      
      

      also refer to:
      http://www.nabble.com/get-a-closure-from-ConfigObject-tp21738767p21823548.html

      Attachments

        Activity

          People

            graemerocher Graeme Rocher
            mingfai Mingfai Ma
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: