• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

i-net-software / jlessc / 281

pending completion
281

push

travis-ci-com

volker
Handle doubled rule correctly in the compressed formatter if previous
rule ends with an block

5 of 5 new or added lines in 1 file covered. (100.0%)

3586 of 3873 relevant lines covered (92.59%)

2.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.19
/src/com/inet/lib/less/JavaScriptBindings.java
1
/**
2
 * MIT License (MIT)
3
 *
4
 * Copyright (c) 2015 Volker Berlin
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * UT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 *
24
 * @author Volker Berlin
25
 * @license: The MIT license <http://opensource.org/licenses/MIT>
26
 */
27
package com.inet.lib.less;
28

29
import javax.script.SimpleBindings;
30

31
/**
32
 * Bindings to the current less variables
33
 */
34
class JavaScriptBindings extends SimpleBindings {
35

36
    private CssFormatter formatter;
37

38
    /**
39
     * Create a new bindings
40
     * @param formatter the CCS target
41
     */
42
    JavaScriptBindings( CssFormatter formatter ) {
3✔
43
        this.formatter = formatter;
3✔
44
    }
3✔
45

46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public boolean containsKey( Object key ) {
51
        String keyStr = (String)key;
3✔
52
        if( keyStr.startsWith( "nashorn." ) ) {
3✔
53
            return super.containsKey( key );
×
54
        }
55
        Expression var = formatter.getVariable( '@' + keyStr );
3✔
56
        return var != null;
3✔
57
    }
58

59
    /**
60
     * {@inheritDoc}
61
     */
62
    @Override
63
    public Object get( Object key ) {
64
        String keyStr = (String)key;
3✔
65
        if( keyStr.startsWith( "nashorn." ) ) {
3✔
66
            return super.get( key );
3✔
67
        }
68
        Expression var = formatter.getVariable( '@' + keyStr );
3✔
69
        if( var == null ) {
3✔
70
            return null;
×
71
        }
72
        Object obj;
73
        switch( var.getDataType( formatter ) ) {
3✔
74
            case Expression.NUMBER:
75
                obj = new Double( var.doubleValue( formatter ) );
3✔
76
                break;
3✔
77
            case Expression.BOOLEAN:
78
                obj = Boolean.valueOf( var.booleanValue( formatter ) );
×
79
                break;
×
80
            case Expression.STRING:
81
            default:
82
                obj = var.stringValue( formatter );
×
83
        }
84
        return new JavaScriptObject( obj );
3✔
85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc