parsr 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +10 -0
 - data/lib/parsr.rb +3 -3
 - data/lib/parsr/version.rb +1 -1
 - data/parsr.gemspec +2 -1
 - data/spec/parsr_spec.rb +3 -3
 - metadata +7 -5
 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Parsr
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Parsr aim to provide a way to safely evaluate a ruby expression composed only with literals,
         
     | 
| 
      
 4 
     | 
    
         
            +
            just as Python's [ast.literal_eval](http://docs.python.org/library/ast.html#ast.literal_eval).
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            ## Example
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 9 
     | 
    
         
            +
            Parsr.literal_eval(%q{ [1, "2", 3.4 => 5..6, foo: [7] ] })
         
     | 
| 
      
 10 
     | 
    
         
            +
            ```
         
     | 
    
        data/lib/parsr.rb
    CHANGED
    
    | 
         @@ -48,8 +48,8 @@ class Parsr 
     | 
|
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
              class << self
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                def  
     | 
| 
       52 
     | 
    
         
            -
                  @ 
     | 
| 
      
 51 
     | 
    
         
            +
                def literal_eval(string)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @literal_parser ||= self.new(
         
     | 
| 
       53 
53 
     | 
    
         
             
                    ArrayRule,
         
     | 
| 
       54 
54 
     | 
    
         
             
                    HashRule,
         
     | 
| 
       55 
55 
     | 
    
         
             
                    RangeRule,
         
     | 
| 
         @@ -60,7 +60,7 @@ class Parsr 
     | 
|
| 
       60 
60 
     | 
    
         
             
                    RawStringRule,
         
     | 
| 
       61 
61 
     | 
    
         
             
                    StringRule
         
     | 
| 
       62 
62 
     | 
    
         
             
                  )
         
     | 
| 
       63 
     | 
    
         
            -
                  @ 
     | 
| 
      
 63 
     | 
    
         
            +
                  @literal_parser.parse(string)
         
     | 
| 
       64 
64 
     | 
    
         
             
                end
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
    
        data/lib/parsr/version.rb
    CHANGED
    
    
    
        data/parsr.gemspec
    CHANGED
    
    | 
         @@ -7,8 +7,9 @@ Gem::Specification.new do |s| 
     | 
|
| 
       7 
7 
     | 
    
         
             
              s.version     = Parsr::VERSION
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.authors     = ["Jean Boussier"]
         
     | 
| 
       9 
9 
     | 
    
         
             
              s.email       = ["jean.boussier@gmail.com"]
         
     | 
| 
       10 
     | 
    
         
            -
              s.homepage    = ""
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.homepage    = "https://github.com/byroot/parsr/"
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.summary     = %q{Simple parser to safe eval ruby literals}
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.description = %q{Parsr aim to provide a way to safely evaluate a ruby expression composed only with literals, just as Python's ast.literal_eval}
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       14 
15 
     | 
    
         
             
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
    
        data/spec/parsr_spec.rb
    CHANGED
    
    | 
         @@ -36,16 +36,16 @@ describe Parsr do 
     | 
|
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
              describe '. 
     | 
| 
      
 39 
     | 
    
         
            +
              describe '.literal_eval' do
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                it 'should be able to parse some complexes literals' do
         
     | 
| 
       42 
     | 
    
         
            -
                  Parsr 
     | 
| 
      
 42 
     | 
    
         
            +
                  Parsr.literal_eval(%q{
         
     | 
| 
       43 
43 
     | 
    
         
             
                    [1, "2", foo: {egg: 'spam', 'bar,' => true}, 3 => 4.2]
         
     | 
| 
       44 
44 
     | 
    
         
             
                  }).should be == [1, "2", {:foo => {:egg => 'spam', 'bar,' => true}, 3 => 4.2}]
         
     | 
| 
       45 
45 
     | 
    
         
             
                end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                it 'should be able to parse an array included in another array' do
         
     | 
| 
       48 
     | 
    
         
            -
                  Parsr 
     | 
| 
      
 48 
     | 
    
         
            +
                  Parsr.literal_eval(%q{
         
     | 
| 
       49 
49 
     | 
    
         
             
                    [1, [2], 3]
         
     | 
| 
       50 
50 
     | 
    
         
             
                  }).should be == [1, [2], 3]
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: parsr
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -13,7 +13,7 @@ date: 2011-11-14 00:00:00.000000000Z 
     | 
|
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rspec
         
     | 
| 
       16 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &70119921863760 !ruby/object:Gem::Requirement
         
     | 
| 
       17 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       18 
18 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
19 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -21,8 +21,9 @@ dependencies: 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       22 
22 
     | 
    
         
             
              type: :development
         
     | 
| 
       23 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
       25 
     | 
    
         
            -
            description: 
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *70119921863760
         
     | 
| 
      
 25 
     | 
    
         
            +
            description: Parsr aim to provide a way to safely evaluate a ruby expression composed
         
     | 
| 
      
 26 
     | 
    
         
            +
              only with literals, just as Python's ast.literal_eval
         
     | 
| 
       26 
27 
     | 
    
         
             
            email:
         
     | 
| 
       27 
28 
     | 
    
         
             
            - jean.boussier@gmail.com
         
     | 
| 
       28 
29 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -33,6 +34,7 @@ files: 
     | 
|
| 
       33 
34 
     | 
    
         
             
            - .rspec
         
     | 
| 
       34 
35 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       35 
36 
     | 
    
         
             
            - LICENSE
         
     | 
| 
      
 37 
     | 
    
         
            +
            - README.md
         
     | 
| 
       36 
38 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       37 
39 
     | 
    
         
             
            - lib/parsr.rb
         
     | 
| 
       38 
40 
     | 
    
         
             
            - lib/parsr/array_rule.rb
         
     | 
| 
         @@ -59,7 +61,7 @@ files: 
     | 
|
| 
       59 
61 
     | 
    
         
             
            - spec/parsr_spec.rb
         
     | 
| 
       60 
62 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       61 
63 
     | 
    
         
             
            - spec/support/rule_shared_context.rb
         
     | 
| 
       62 
     | 
    
         
            -
            homepage:  
     | 
| 
      
 64 
     | 
    
         
            +
            homepage: https://github.com/byroot/parsr/
         
     | 
| 
       63 
65 
     | 
    
         
             
            licenses: []
         
     | 
| 
       64 
66 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       65 
67 
     | 
    
         
             
            rdoc_options: []
         
     |