text_helpers 0.5.3 → 0.6.0
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.
- checksums.yaml +4 -4
 - data/.travis.yml +3 -0
 - data/lib/text_helpers/translation.rb +17 -1
 - data/lib/text_helpers/version.rb +1 -1
 - data/test/lib/text_helpers/translation_test.rb +10 -0
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 49b35b498f0e54737019e94b1de125ae9e7319a1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c05d609d512fcd23f83c9e86d3ff25020d5ce794
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 209bd9aec92f16e3cbdc2789e4a5dff9983bb9a08ddc1f2481ec21900a260efcfa6688d04e1c466d0929d3dd5e1093a0359cb234a070a3fdf575c7ef43aa79ae
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 01e934de93f63e04425313d09736ee11e880a828639162e8625ab0f9c725e9c01719fd881f1283fd0cc28dc6b64d1b82817b0df63894e1750fcbe1451163f9bb
         
     | 
    
        data/.travis.yml
    ADDED
    
    
| 
         @@ -4,6 +4,22 @@ require "redcarpet" 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            module TextHelpers
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
              class ExternalLinks < Redcarpet::Render::HTML
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                PROTOCOL_MATCHER = /\Ahttp/.freeze
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def link(link, title, content)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  attributes = [
         
     | 
| 
      
 13 
     | 
    
         
            +
                    ("href=\"#{link}\"" if link),
         
     | 
| 
      
 14 
     | 
    
         
            +
                    ("title=\"#{title}\"" if title),
         
     | 
| 
      
 15 
     | 
    
         
            +
                    ("target=\"_blank\"" if link =~ PROTOCOL_MATCHER),
         
     | 
| 
      
 16 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  "<a #{attributes.compact.join(" ")}>#{content}</a>"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       7 
23 
     | 
    
         
             
              module Translation
         
     | 
| 
       8 
24 
     | 
    
         | 
| 
       9 
25 
     | 
    
         
             
                ORPHAN_MATCHER = /\s(?![^<]*>)(\S+\s*<\/(?:p|li)>)/.freeze
         
     | 
| 
         @@ -62,7 +78,7 @@ module TextHelpers 
     | 
|
| 
       62 
78 
     | 
    
         
             
                #
         
     | 
| 
       63 
79 
     | 
    
         
             
                # Returns a String.
         
     | 
| 
       64 
80 
     | 
    
         
             
                def markdown(text)
         
     | 
| 
       65 
     | 
    
         
            -
                  @renderer ||= Redcarpet::Markdown.new( 
     | 
| 
      
 81 
     | 
    
         
            +
                  @renderer ||= Redcarpet::Markdown.new(ExternalLinks, no_intra_emphasis: true)
         
     | 
| 
       66 
82 
     | 
    
         
             
                  smartify(@renderer.render(text))
         
     | 
| 
       67 
83 
     | 
    
         
             
                end
         
     | 
| 
       68 
84 
     | 
    
         | 
    
        data/lib/text_helpers/version.rb
    CHANGED
    
    
| 
         @@ -24,6 +24,8 @@ describe TextHelpers::Translation do 
     | 
|
| 
       24 
24 
     | 
    
         
             
                    test_key: @global_text,
         
     | 
| 
       25 
25 
     | 
    
         
             
                    multiline_key: @multiline_text,
         
     | 
| 
       26 
26 
     | 
    
         
             
                    interpolated_key: "%{interpolate_with}",
         
     | 
| 
      
 27 
     | 
    
         
            +
                    internal_link: "[Internal link](/internal/path)",
         
     | 
| 
      
 28 
     | 
    
         
            +
                    external_link: "[External link](http://external.com)",
         
     | 
| 
       27 
29 
     | 
    
         
             
                    test: {
         
     | 
| 
       28 
30 
     | 
    
         
             
                      email_key:               "<#{@email_address}>",
         
     | 
| 
       29 
31 
     | 
    
         
             
                      test_key:                "*#{@scoped_text}*",
         
     | 
| 
         @@ -98,6 +100,14 @@ describe TextHelpers::Translation do 
     | 
|
| 
       98 
100 
     | 
    
         
             
                    assert_equal "<em>#{@scoped_text}</em>\n", @helper.html(:test_key, inline: true, orphans: true)
         
     | 
| 
       99 
101 
     | 
    
         
             
                  end
         
     | 
| 
       100 
102 
     | 
    
         | 
| 
      
 103 
     | 
    
         
            +
                  it "renders internal links without a target" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                    assert_equal "<a href=\"/internal/path\">Internal link</a>\n", @helper.html(:internal_link, inline: true)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                  it "renders external links with target='_blank'" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                    assert_equal "<a href=\"http://external.com\" target=\"_blank\">External link</a>\n", @helper.html(:external_link, inline: true)
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
       101 
111 
     | 
    
         
             
                  it "interpolates values wrapped in !!" do
         
     | 
| 
       102 
112 
     | 
    
         
             
                    assert_equal "Global? (#{@global_text})", @helper.text(:interpolated_key)
         
     | 
| 
       103 
113 
     | 
    
         
             
                  end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: text_helpers
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Horner
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-06-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -88,6 +88,7 @@ extensions: [] 
     | 
|
| 
       88 
88 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       89 
89 
     | 
    
         
             
            files:
         
     | 
| 
       90 
90 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
      
 91 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
       91 
92 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       92 
93 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       93 
94 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       123 
124 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       124 
125 
     | 
    
         
             
            requirements: []
         
     | 
| 
       125 
126 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       126 
     | 
    
         
            -
            rubygems_version: 2.4. 
     | 
| 
      
 127 
     | 
    
         
            +
            rubygems_version: 2.4.7
         
     | 
| 
       127 
128 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       128 
129 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       129 
130 
     | 
    
         
             
            summary: TextHelpers is a gem which supplies some basic utilities for text localization
         
     |