aloha_analyzer 0.0.9 → 0.1.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/lib/aloha_analyzer/language.rb +5 -2
- data/lib/aloha_analyzer/user.rb +26 -14
- data/lib/aloha_analyzer/version.rb +1 -1
- data/lib/aloha_analyzer/yaml/language.yml +43 -0
- data/spec/aloha_analyzer/language_spec.rb +4 -0
- data/spec/aloha_analyzer/user_spec.rb +135 -89
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f8f802d64436c198914e3ba6fd936ee1b9b5603d
         | 
| 4 | 
            +
              data.tar.gz: 8f7ad7551702b7fc56ea34ecd01eda283a17af68
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 91e770d907422d48c9b08c60c7b01362fe087568e47930523130a5421e19c2c741e8ec6ea13fe3379d9935b041a570df03de34e0cd59875d7cddeb34b1fc9b40
         | 
| 7 | 
            +
              data.tar.gz: 5ca995c0dc5e84b71e93110c9a4f73eae0f4331d36b7ebfb8e707365d107317f48dfcef42815fe1f62b75ac0990cbf987d1e535eb0d5ce64fba987e84ed18400
         | 
| @@ -4,7 +4,7 @@ module AlohaAnalyzer | |
| 4 4 | 
             
              class Language
         | 
| 5 5 |  | 
| 6 6 | 
             
                LANGUAGES        = YAML::load_file(File.join(File.dirname(__FILE__), 'yaml/language.yml'))
         | 
| 7 | 
            -
                TOTAL_POPULATION =  | 
| 7 | 
            +
                TOTAL_POPULATION = 790000000
         | 
| 8 8 |  | 
| 9 9 | 
             
                def self.all
         | 
| 10 10 | 
             
                  LANGUAGES
         | 
| @@ -19,7 +19,10 @@ module AlohaAnalyzer | |
| 19 19 | 
             
                    'en-gb' => 'en',
         | 
| 20 20 | 
             
                    'zh-cb' => 'zh',
         | 
| 21 21 | 
             
                    'zh-tw' => 'zh',
         | 
| 22 | 
            -
                    'ca'    => 'es'
         | 
| 22 | 
            +
                    'ca'    => 'es',
         | 
| 23 | 
            +
                    'xx-lc' => 'en',
         | 
| 24 | 
            +
                    'gl'    => 'es',
         | 
| 25 | 
            +
                    'eu'    => 'es'
         | 
| 23 26 | 
             
                  }
         | 
| 24 27 | 
             
                end
         | 
| 25 28 |  | 
    
        data/lib/aloha_analyzer/user.rb
    CHANGED
    
    | @@ -22,35 +22,47 @@ module AlohaAnalyzer | |
| 22 22 |  | 
| 23 23 | 
             
                def with_user_language
         | 
| 24 24 | 
             
                  @with_user_language ||= Hash.new.tap do |languages|
         | 
| 25 | 
            +
                    languages['count']     = 0
         | 
| 26 | 
            +
                    languages['languages'] = Hash.new
         | 
| 27 | 
            +
             | 
| 25 28 | 
             
                    @users.each do |user|
         | 
| 26 29 | 
             
                      abbreviation = user['lang']
         | 
| 27 | 
            -
                      if languages[abbreviation]
         | 
| 28 | 
            -
                        languages[abbreviation]['count'] += 1
         | 
| 30 | 
            +
                      if languages['languages'][abbreviation]
         | 
| 31 | 
            +
                        languages['languages'][abbreviation]['count'] += 1
         | 
| 32 | 
            +
                        languages['languages'][abbreviation]['users'].push user
         | 
| 29 33 | 
             
                      else
         | 
| 30 | 
            -
                        languages[abbreviation] = {
         | 
| 31 | 
            -
                          'count' | 
| 32 | 
            -
                          'language' | 
| 34 | 
            +
                        languages['languages'][abbreviation] = {
         | 
| 35 | 
            +
                          'count'    => 1,
         | 
| 36 | 
            +
                          'language' => Language.find_by_abbreviation(abbreviation),
         | 
| 37 | 
            +
                          'users'    => [user]
         | 
| 33 38 | 
             
                        }
         | 
| 34 39 | 
             
                      end
         | 
| 35 | 
            -
                      languages[abbreviation]['percentage'] = ((100 / @users_count.to_f) * languages[abbreviation]['count']).round
         | 
| 40 | 
            +
                      languages['languages'][abbreviation]['percentage'] = ((100 / @users_count.to_f) * languages['languages'][abbreviation]['count']).round(2)
         | 
| 41 | 
            +
                      languages['count'] += 1
         | 
| 36 42 | 
             
                    end
         | 
| 37 43 | 
             
                  end
         | 
| 38 44 | 
             
                end
         | 
| 39 45 |  | 
| 40 46 | 
             
                def without_user_language
         | 
| 41 47 | 
             
                  @without_user_language ||= Hash.new.tap do |languages|
         | 
| 48 | 
            +
                    languages['count']     = 0
         | 
| 49 | 
            +
                    languages['languages'] = Hash.new
         | 
| 50 | 
            +
             | 
| 42 51 | 
             
                    @users.each do |user|
         | 
| 43 52 | 
             
                      abbreviation = user['lang']
         | 
| 44 53 | 
             
                      if abbreviation != @language
         | 
| 45 | 
            -
                        if languages[abbreviation]
         | 
| 46 | 
            -
                          languages[abbreviation]['count'] += 1
         | 
| 54 | 
            +
                        if languages['languages'][abbreviation]
         | 
| 55 | 
            +
                          languages['languages'][abbreviation]['count'] += 1
         | 
| 56 | 
            +
                          languages['languages'][abbreviation]['users'].push user
         | 
| 47 57 | 
             
                        else
         | 
| 48 | 
            -
                          languages[abbreviation] = {
         | 
| 49 | 
            -
                            'count' | 
| 50 | 
            -
                            'language' | 
| 58 | 
            +
                          languages['languages'][abbreviation] = {
         | 
| 59 | 
            +
                            'count'    => 1,
         | 
| 60 | 
            +
                            'language' => Language.find_by_abbreviation(abbreviation),
         | 
| 61 | 
            +
                            'users'    => [user]
         | 
| 51 62 | 
             
                          }
         | 
| 52 63 | 
             
                        end
         | 
| 53 | 
            -
                        languages[abbreviation]['percentage'] = ((100 / users_total_without_user_language.to_f) * languages[abbreviation]['count']).round
         | 
| 64 | 
            +
                        languages['languages'][abbreviation]['percentage'] = ((100 / users_total_without_user_language.to_f) * languages['languages'][abbreviation]['count']).round(2)
         | 
| 65 | 
            +
                        languages['count'] += 1
         | 
| 54 66 | 
             
                      end
         | 
| 55 67 | 
             
                    end
         | 
| 56 68 | 
             
                  end
         | 
| @@ -61,8 +73,8 @@ module AlohaAnalyzer | |
| 61 73 | 
             
                end
         | 
| 62 74 |  | 
| 63 75 | 
             
                def user_language_count
         | 
| 64 | 
            -
                  @user_language_count ||= if with_user_language[@language]
         | 
| 65 | 
            -
                    with_user_language[@language]['count']
         | 
| 76 | 
            +
                  @user_language_count ||= if with_user_language['languages'][@language]
         | 
| 77 | 
            +
                    with_user_language['languages'][@language]['count']
         | 
| 66 78 | 
             
                  else
         | 
| 67 79 | 
             
                    0
         | 
| 68 80 | 
             
                  end
         | 
| @@ -1,81 +1,124 @@ | |
| 1 1 | 
             
            - abbreviation: fr
         | 
| 2 2 | 
             
              name:       French
         | 
| 3 3 | 
             
              population: 14_000_000
         | 
| 4 | 
            +
              countries: 'France, Canada, Belgium, Switzerland'
         | 
| 4 5 | 
             
            - abbreviation: en
         | 
| 5 6 | 
             
              name:       English
         | 
| 6 7 | 
             
              population: 238_000_000
         | 
| 8 | 
            +
              countries: 'USA, Canada, UK, Ireland, Australia'
         | 
| 7 9 | 
             
            - abbreviation: ar
         | 
| 8 10 | 
             
              name:       Arabic
         | 
| 9 11 | 
             
              population: 42_000_000
         | 
| 12 | 
            +
              countries: 'Egypt, Tunisia, Lebanon, United Arab Emirates'
         | 
| 10 13 | 
             
            - abbreviation: ja
         | 
| 11 14 | 
             
              name:       Japanese
         | 
| 12 15 | 
             
              population: 106_580_000
         | 
| 16 | 
            +
              countries: 'Japan, Brazil'
         | 
| 13 17 | 
             
            - abbreviation: es
         | 
| 14 18 | 
             
              name:       Spanish
         | 
| 15 19 | 
             
              population: 95_000_000
         | 
| 20 | 
            +
              countries: 'Spain, Mexico, Argentina, Chile'
         | 
| 16 21 | 
             
            - abbreviation: de
         | 
| 17 22 | 
             
              name:       German
         | 
| 18 23 | 
             
              population: 5_000_000
         | 
| 24 | 
            +
              countries: 'Germany, Austria, Switzerland, Belgium'
         | 
| 19 25 | 
             
            - abbreviation: it
         | 
| 20 26 | 
             
              name:       Italian
         | 
| 21 27 | 
             
              population: 8_000_000
         | 
| 28 | 
            +
              countries: 'Italy, Switzerland, Malta'
         | 
| 22 29 | 
             
            - abbreviation: id
         | 
| 23 30 | 
             
              name:       Indonesian
         | 
| 24 31 | 
             
              population: 20_000_000
         | 
| 32 | 
            +
              countries: 'Indonesia'
         | 
| 25 33 | 
             
            - abbreviation: pt
         | 
| 26 34 | 
             
              name:       Portuguese
         | 
| 27 35 | 
             
              population: 42_000_000
         | 
| 36 | 
            +
              countries: 'Portugal, Brazil, Macau'
         | 
| 28 37 | 
             
            - abbreviation: ko
         | 
| 29 38 | 
             
              name:       Korean
         | 
| 30 39 | 
             
              population: 7_000_000
         | 
| 40 | 
            +
              countries: 'South Korea'
         | 
| 31 41 | 
             
            - abbreviation: tr
         | 
| 32 42 | 
             
              name:       Turkish
         | 
| 33 43 | 
             
              population: 14_000_000
         | 
| 44 | 
            +
              countries: 'Turkey'
         | 
| 34 45 | 
             
            - abbreviation: ru
         | 
| 35 46 | 
             
              name:       Russian
         | 
| 36 47 | 
             
              population: 5_000_000
         | 
| 48 | 
            +
              countries: 'Russia, Belarus, Kazakhstan, Kyrgyzstan'
         | 
| 37 49 | 
             
            - abbreviation: nl
         | 
| 38 50 | 
             
              name:       Dutch
         | 
| 39 51 | 
             
              population: 8_000_000
         | 
| 52 | 
            +
              countries: 'Netherlands, Belgium'
         | 
| 40 53 | 
             
            - abbreviation: fil
         | 
| 41 54 | 
             
              name:       Tagalog
         | 
| 55 | 
            +
              countries: 'Philippines'
         | 
| 42 56 | 
             
              population: 8_000_000
         | 
| 43 57 | 
             
            - abbreviation: msa
         | 
| 44 58 | 
             
              name:       Malay
         | 
| 45 59 | 
             
              population: 50_000_000
         | 
| 60 | 
            +
              countries: 'Malaysia, Singapore, Brunei'
         | 
| 46 61 | 
             
            - abbreviation: zh
         | 
| 47 62 | 
             
              name:       Chinese
         | 
| 48 63 | 
             
              population: 20_000
         | 
| 64 | 
            +
              countries: 'China, Hong-Kong, Macau'
         | 
| 49 65 | 
             
            - abbreviation: hi
         | 
| 50 66 | 
             
              name:       Hindi
         | 
| 51 67 | 
             
              population: 12_000_000
         | 
| 68 | 
            +
              countries: 'India, Pakistan, Fiji'
         | 
| 52 69 | 
             
            - abbreviation: 'no'
         | 
| 53 70 | 
             
              name:       Norwegian
         | 
| 54 71 | 
             
              population: 300_000
         | 
| 72 | 
            +
              countries: 'Norway'
         | 
| 55 73 | 
             
            - abbreviation: sv
         | 
| 56 74 | 
             
              name:       Swedish
         | 
| 57 75 | 
             
              population: 500_000
         | 
| 76 | 
            +
              countries: 'Sweden'
         | 
| 58 77 | 
             
            - abbreviation: fi
         | 
| 59 78 | 
             
              name:       Finnish
         | 
| 60 79 | 
             
              population: 100_000
         | 
| 80 | 
            +
              countries: 'Finnish'
         | 
| 61 81 | 
             
            - abbreviation: da
         | 
| 62 82 | 
             
              name:       Danish
         | 
| 63 83 | 
             
              population: 200_000
         | 
| 84 | 
            +
              countries: 'Danish'
         | 
| 64 85 | 
             
            - abbreviation: pl
         | 
| 65 86 | 
             
              name:       Polish
         | 
| 66 87 | 
             
              population: 300_000
         | 
| 88 | 
            +
              countries: 'Poland'
         | 
| 67 89 | 
             
            - abbreviation: hu
         | 
| 68 90 | 
             
              name:       Hungarian
         | 
| 69 91 | 
             
              population: 1_000_000
         | 
| 92 | 
            +
              countries: 'Hungary'
         | 
| 70 93 | 
             
            - abbreviation: fa
         | 
| 71 94 | 
             
              name:       Farsi
         | 
| 72 95 | 
             
              population: 1_000_000
         | 
| 96 | 
            +
              countries: 'Iran, Afghanistan, Tajikistan'
         | 
| 73 97 | 
             
            - abbreviation: he
         | 
| 74 98 | 
             
              name:       Hebrew
         | 
| 75 99 | 
             
              population: 1_000_000
         | 
| 100 | 
            +
              countries: 'Israel'
         | 
| 76 101 | 
             
            - abbreviation: ur
         | 
| 77 102 | 
             
              name:       Urdu
         | 
| 78 103 | 
             
              population: 1_000_000
         | 
| 104 | 
            +
              countries: 'India, Pakistan, Fiji'
         | 
| 79 105 | 
             
            - abbreviation: th
         | 
| 80 106 | 
             
              name:       Thai
         | 
| 81 107 | 
             
              population: 7_0000_000
         | 
| 108 | 
            +
              countries: 'Thailand'
         | 
| 109 | 
            +
            - abbreviation: uk
         | 
| 110 | 
            +
              name:       Ukranian
         | 
| 111 | 
            +
              population: 1_0000_000
         | 
| 112 | 
            +
              countries: 'Ukraine'
         | 
| 113 | 
            +
            - abbreviation: el
         | 
| 114 | 
            +
              name:       Greek
         | 
| 115 | 
            +
              population: 1_0000_000
         | 
| 116 | 
            +
              countries: 'Greece, Cyprus'
         | 
| 117 | 
            +
            - abbreviation: el
         | 
| 118 | 
            +
              name:       Czech
         | 
| 119 | 
            +
              population: 1_0000_000
         | 
| 120 | 
            +
              countries: 'Czech Republic'
         | 
| 121 | 
            +
            - abbreviation: ro
         | 
| 122 | 
            +
              name:       Romanian
         | 
| 123 | 
            +
              population: 1_0000_000
         | 
| 124 | 
            +
              countries: 'Romania, Serbia, Moldova'
         | 
| @@ -41,6 +41,10 @@ describe AlohaAnalyzer::Language do | |
| 41 41 | 
             
                  it 'includes the language abbreviation' do
         | 
| 42 42 | 
             
                    subject['abbreviation'].should eq 'fr'
         | 
| 43 43 | 
             
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  it 'includes the languages coutnries' do
         | 
| 46 | 
            +
                    subject['countries'].should eq 'France, Canada, Belgium, Switzerland'
         | 
| 47 | 
            +
                  end
         | 
| 44 48 | 
             
                end
         | 
| 45 49 |  | 
| 46 50 | 
             
                context 'when it does not exist' do
         | 
| @@ -49,11 +49,13 @@ describe AlohaAnalyzer::User do | |
| 49 49 | 
             
                  end
         | 
| 50 50 |  | 
| 51 51 | 
             
                  it 'has no results with the user language' do
         | 
| 52 | 
            -
                    subject[:with_user_language].should eq({})
         | 
| 52 | 
            +
                    subject[:with_user_language]['languages'].should eq({})
         | 
| 53 | 
            +
                    subject[:with_user_language]['count'].should eq 0
         | 
| 53 54 | 
             
                  end
         | 
| 54 55 |  | 
| 55 56 | 
             
                  it 'has no results without the user language' do
         | 
| 56 | 
            -
                    subject[:without_user_language].should eq({})
         | 
| 57 | 
            +
                    subject[:without_user_language]['languages'].should eq({})
         | 
| 58 | 
            +
                    subject[:without_user_language]['count'].should eq 0
         | 
| 57 59 | 
             
                  end
         | 
| 58 60 | 
             
                end
         | 
| 59 61 |  | 
| @@ -61,10 +63,10 @@ describe AlohaAnalyzer::User do | |
| 61 63 | 
             
                  context 'and no aliases' do
         | 
| 62 64 | 
             
                    let(:users) {
         | 
| 63 65 | 
             
                      [
         | 
| 64 | 
            -
                        {'lang' => 'en'},
         | 
| 65 | 
            -
                        {'lang' => 'fr'},
         | 
| 66 | 
            -
                        {'lang' => 'en'},
         | 
| 67 | 
            -
                        {'lang' => 'de'}
         | 
| 66 | 
            +
                        {'id' => '1', 'lang' => 'en'},
         | 
| 67 | 
            +
                        {'id' => '2', 'lang' => 'fr'},
         | 
| 68 | 
            +
                        {'id' => '3', 'lang' => 'en'},
         | 
| 69 | 
            +
                        {'id' => '4', 'lang' => 'de'}
         | 
| 68 70 | 
             
                      ]
         | 
| 69 71 | 
             
                    }
         | 
| 70 72 |  | 
| @@ -74,35 +76,46 @@ describe AlohaAnalyzer::User do | |
| 74 76 |  | 
| 75 77 | 
             
                    it 'returns results based on the user language' do
         | 
| 76 78 | 
             
                      subject[:with_user_language].should == {
         | 
| 77 | 
            -
                        ' | 
| 78 | 
            -
             | 
| 79 | 
            -
                          ' | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
                           | 
| 85 | 
            -
                          ' | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
                           | 
| 79 | 
            +
                        'count' => 4,
         | 
| 80 | 
            +
                        'languages' => {
         | 
| 81 | 
            +
                          'en' => {
         | 
| 82 | 
            +
                            'percentage' => 50,
         | 
| 83 | 
            +
                            'count'      => 2,
         | 
| 84 | 
            +
                            'language'   => {'abbreviation'=>'en', 'name'=>'English', 'population'=>238000000, "countries"=>"USA, Canada, UK, Ireland, Australia"},
         | 
| 85 | 
            +
                            'users'      => [{'id' => '1', 'lang' => 'en'}, {'id' => '3', 'lang' => 'en'}]
         | 
| 86 | 
            +
                          },
         | 
| 87 | 
            +
                          'fr' => {
         | 
| 88 | 
            +
                            'percentage' => 25,
         | 
| 89 | 
            +
                            'count'      => 1,
         | 
| 90 | 
            +
                            'language' => {'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, "countries"=>"France, Canada, Belgium, Switzerland"},
         | 
| 91 | 
            +
                            'users'      => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 92 | 
            +
                          },
         | 
| 93 | 
            +
                          'de' => {
         | 
| 94 | 
            +
                            'percentage' => 25,
         | 
| 95 | 
            +
                            'count'      => 1,
         | 
| 96 | 
            +
                            'language' => {'abbreviation'=>'de', 'name'=>'German', 'population'=>5000000, "countries"=>"Germany, Austria, Switzerland, Belgium"},
         | 
| 97 | 
            +
                            'users'      => [{'id' => '4', 'lang' => 'de'}]
         | 
| 98 | 
            +
                          }
         | 
| 91 99 | 
             
                        }
         | 
| 92 100 | 
             
                      }
         | 
| 93 101 | 
             
                    end
         | 
| 94 102 |  | 
| 95 103 | 
             
                    it 'returns results results based on the non user language' do
         | 
| 96 104 | 
             
                      subject[:without_user_language].should eq(
         | 
| 97 | 
            -
                        ' | 
| 98 | 
            -
             | 
| 99 | 
            -
                          ' | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
                           | 
| 105 | 
            -
                          ' | 
| 105 | 
            +
                        'count' => 2,
         | 
| 106 | 
            +
                        'languages' => {
         | 
| 107 | 
            +
                          'fr' => {
         | 
| 108 | 
            +
                            'percentage' => 50,
         | 
| 109 | 
            +
                            'count'      => 1,
         | 
| 110 | 
            +
                            'language'   => {'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, 'countries' => 'France, Canada, Belgium, Switzerland'},
         | 
| 111 | 
            +
                            'users'      => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 112 | 
            +
                          },
         | 
| 113 | 
            +
                          'de' => {
         | 
| 114 | 
            +
                            'percentage' => 50,
         | 
| 115 | 
            +
                            'count'      => 1,
         | 
| 116 | 
            +
                            'language'   => {'abbreviation'=>'de', 'name'=>'German', 'population'=>5000000, 'countries' => 'Germany, Austria, Switzerland, Belgium'},
         | 
| 117 | 
            +
                            'users'      => [{'id' => '4', 'lang' => 'de'}]
         | 
| 118 | 
            +
                          }
         | 
| 106 119 | 
             
                        }
         | 
| 107 120 | 
             
                      )
         | 
| 108 121 | 
             
                    end
         | 
| @@ -111,8 +124,8 @@ describe AlohaAnalyzer::User do | |
| 111 124 | 
             
                  context 'when only user langugages users' do
         | 
| 112 125 | 
             
                    let(:users) {
         | 
| 113 126 | 
             
                      [
         | 
| 114 | 
            -
                        {'lang' => 'en'},
         | 
| 115 | 
            -
                        {'lang' => 'en'}
         | 
| 127 | 
            +
                        {'id' => '1', 'lang' => 'en'},
         | 
| 128 | 
            +
                        {'id' => '2', 'lang' => 'en'}
         | 
| 116 129 | 
             
                      ]
         | 
| 117 130 | 
             
                    }
         | 
| 118 131 |  | 
| @@ -122,24 +135,29 @@ describe AlohaAnalyzer::User do | |
| 122 135 |  | 
| 123 136 | 
             
                    it 'returns results based on the user language' do
         | 
| 124 137 | 
             
                      subject[:with_user_language].should == {
         | 
| 125 | 
            -
                        ' | 
| 126 | 
            -
             | 
| 127 | 
            -
                          ' | 
| 128 | 
            -
             | 
| 138 | 
            +
                        'count' => 2,
         | 
| 139 | 
            +
                        'languages' => {
         | 
| 140 | 
            +
                          'en' => {
         | 
| 141 | 
            +
                            'percentage' => 100,
         | 
| 142 | 
            +
                            'count'      => 2,
         | 
| 143 | 
            +
                            'language'   => {'abbreviation'=>'en', 'name'=>'English', 'population'=>238000000, 'countries' => 'USA, Canada, UK, Ireland, Australia'},
         | 
| 144 | 
            +
                            'users'      => [{'id' => '1', 'lang' => 'en'}, {'id' => '2', 'lang' => 'en'}]
         | 
| 145 | 
            +
                          }
         | 
| 129 146 | 
             
                        }
         | 
| 130 147 | 
             
                      }
         | 
| 131 148 | 
             
                    end
         | 
| 132 149 |  | 
| 133 150 | 
             
                    it 'returns results results based on the non user language' do
         | 
| 134 | 
            -
                      subject[:without_user_language].should == {}
         | 
| 151 | 
            +
                      subject[:without_user_language]['languages'].should == {}
         | 
| 152 | 
            +
                      subject[:without_user_language]['count'].should eq 0
         | 
| 135 153 | 
             
                    end
         | 
| 136 154 | 
             
                  end
         | 
| 137 155 |  | 
| 138 156 | 
             
                  context 'when no users language users' do
         | 
| 139 157 | 
             
                    let(:users) {
         | 
| 140 158 | 
             
                      [
         | 
| 141 | 
            -
                        {'lang' => 'de'},
         | 
| 142 | 
            -
                        {'lang' => 'fr'}
         | 
| 159 | 
            +
                        {'id' => '1', 'lang' => 'de'},
         | 
| 160 | 
            +
                        {'id' => '2', 'lang' => 'fr'}
         | 
| 143 161 | 
             
                      ]
         | 
| 144 162 | 
             
                    }
         | 
| 145 163 |  | 
| @@ -149,30 +167,40 @@ describe AlohaAnalyzer::User do | |
| 149 167 |  | 
| 150 168 | 
             
                    it 'returns results based on the user language' do
         | 
| 151 169 | 
             
                      subject[:with_user_language].should == {
         | 
| 152 | 
            -
                        ' | 
| 153 | 
            -
             | 
| 154 | 
            -
                          ' | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
                           | 
| 160 | 
            -
                          ' | 
| 170 | 
            +
                        'count' => 2,
         | 
| 171 | 
            +
                        'languages' => {
         | 
| 172 | 
            +
                          'fr' => {
         | 
| 173 | 
            +
                            'percentage' => 50,
         | 
| 174 | 
            +
                            'count'      => 1,
         | 
| 175 | 
            +
                            'language' => {'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, 'countries' => 'France, Canada, Belgium, Switzerland'},
         | 
| 176 | 
            +
                            'users' => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 177 | 
            +
                          },
         | 
| 178 | 
            +
                          'de' => {
         | 
| 179 | 
            +
                            'percentage' => 50,
         | 
| 180 | 
            +
                            'count'      => 1,
         | 
| 181 | 
            +
                            'language'   => {'abbreviation'=>'de', 'name'=>'German', 'population'=>5000000, 'countries' => 'Germany, Austria, Switzerland, Belgium'},
         | 
| 182 | 
            +
                            'users'      => [{'id' => '1', 'lang' => 'de'}]
         | 
| 183 | 
            +
                          }
         | 
| 161 184 | 
             
                        }
         | 
| 162 185 | 
             
                      }
         | 
| 163 186 | 
             
                    end
         | 
| 164 187 |  | 
| 165 188 | 
             
                    it 'returns results results based on the non user language' do
         | 
| 166 189 | 
             
                      subject[:without_user_language].should eq(
         | 
| 167 | 
            -
                        ' | 
| 168 | 
            -
             | 
| 169 | 
            -
                          ' | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
                           | 
| 175 | 
            -
                          ' | 
| 190 | 
            +
                        'count'     => 2,
         | 
| 191 | 
            +
                        'languages' => {
         | 
| 192 | 
            +
                          'fr' => {
         | 
| 193 | 
            +
                            'percentage' => 50,
         | 
| 194 | 
            +
                            'count'      => 1,
         | 
| 195 | 
            +
                            'language' => { 'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, 'countries' => 'France, Canada, Belgium, Switzerland' },
         | 
| 196 | 
            +
                            'users' => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 197 | 
            +
                          },
         | 
| 198 | 
            +
                          'de' => {
         | 
| 199 | 
            +
                            'percentage' => 50,
         | 
| 200 | 
            +
                            'count'      => 1,
         | 
| 201 | 
            +
                            'language' => {'abbreviation'=>'de', 'name'=>'German', 'population'=>5000000, 'countries' => 'Germany, Austria, Switzerland, Belgium' },
         | 
| 202 | 
            +
                            'users'      => [{'id' => '1', 'lang' => 'de'}]
         | 
| 203 | 
            +
                          }
         | 
| 176 204 | 
             
                        }
         | 
| 177 205 | 
             
                      )
         | 
| 178 206 | 
             
                    end
         | 
| @@ -182,31 +210,40 @@ describe AlohaAnalyzer::User do | |
| 182 210 | 
             
                    context 'and some users british' do
         | 
| 183 211 | 
             
                      let(:users) {
         | 
| 184 212 | 
             
                        [
         | 
| 185 | 
            -
                          {'lang' => 'en'},
         | 
| 186 | 
            -
                          {'lang' => 'fr'},
         | 
| 187 | 
            -
                          {'lang' => 'en-GB'}
         | 
| 213 | 
            +
                          {'id' => '1', 'lang' => 'en'},
         | 
| 214 | 
            +
                          {'id' => '2', 'lang' => 'fr'},
         | 
| 215 | 
            +
                          {'id' => '3', 'lang' => 'en-GB'}
         | 
| 188 216 | 
             
                        ]
         | 
| 189 217 | 
             
                      }
         | 
| 190 218 |  | 
| 191 219 | 
             
                      it 'merges english and british' do
         | 
| 192 220 | 
             
                        subject[:with_user_language].should == {
         | 
| 193 | 
            -
                          ' | 
| 194 | 
            -
             | 
| 195 | 
            -
                            ' | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
                             | 
| 201 | 
            -
                            ' | 
| 221 | 
            +
                          'count' => 3,
         | 
| 222 | 
            +
                          'languages' => {
         | 
| 223 | 
            +
                            'en' => {
         | 
| 224 | 
            +
                              'percentage' => 66.67,
         | 
| 225 | 
            +
                              'count'      => 2,
         | 
| 226 | 
            +
                              'language'   => {'abbreviation'=>'en', 'name'=>'English', 'population'=>238000000, 'countries' => 'USA, Canada, UK, Ireland, Australia' },
         | 
| 227 | 
            +
                              'users'      => [{'id' => '1', 'lang' => 'en'}, {'id' => '3', 'lang' => 'en'}]
         | 
| 228 | 
            +
                            },
         | 
| 229 | 
            +
                            'fr' => {
         | 
| 230 | 
            +
                              'percentage' => 33.33,
         | 
| 231 | 
            +
                              'count'      => 1,
         | 
| 232 | 
            +
                              'language' => {'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, 'countries' => 'France, Canada, Belgium, Switzerland'},
         | 
| 233 | 
            +
                              'users'      => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 234 | 
            +
                            }
         | 
| 202 235 | 
             
                          }
         | 
| 203 236 | 
             
                        }
         | 
| 204 237 |  | 
| 205 238 | 
             
                        subject[:without_user_language].should eq(
         | 
| 206 | 
            -
                          ' | 
| 207 | 
            -
             | 
| 208 | 
            -
                            ' | 
| 209 | 
            -
             | 
| 239 | 
            +
                          'count' => 1,
         | 
| 240 | 
            +
                          'languages' => {
         | 
| 241 | 
            +
                            'fr' => {
         | 
| 242 | 
            +
                              'percentage' => 100,
         | 
| 243 | 
            +
                              'count'      => 1,
         | 
| 244 | 
            +
                              'language'   => {'abbreviation'=>'fr', 'name'=>'French', 'population'=>14000000, 'countries' => 'France, Canada, Belgium, Switzerland'},
         | 
| 245 | 
            +
                              'users'      => [{'id' => '2', 'lang' => 'fr'}]
         | 
| 246 | 
            +
                            }
         | 
| 210 247 | 
             
                          }
         | 
| 211 248 | 
             
                        )
         | 
| 212 249 | 
             
                      end
         | 
| @@ -215,32 +252,41 @@ describe AlohaAnalyzer::User do | |
| 215 252 | 
             
                    context 'and some users are chinese' do
         | 
| 216 253 | 
             
                      let(:users) {
         | 
| 217 254 | 
             
                        [
         | 
| 218 | 
            -
                          {'lang' => 'zh-cb'},
         | 
| 219 | 
            -
                          {'lang' => 'zh-cb'},
         | 
| 220 | 
            -
                          {'lang' => 'en'},
         | 
| 221 | 
            -
                          {'lang' => 'zh-tw'}
         | 
| 255 | 
            +
                          {'id' => '1', 'lang' => 'zh-cb'},
         | 
| 256 | 
            +
                          {'id' => '2', 'lang' => 'zh-cb'},
         | 
| 257 | 
            +
                          {'id' => '3', 'lang' => 'en'},
         | 
| 258 | 
            +
                          {'id' => '4', 'lang' => 'zh-tw'}
         | 
| 222 259 | 
             
                        ]
         | 
| 223 260 | 
             
                      }
         | 
| 224 261 |  | 
| 225 262 | 
             
                      it 'merges chinese' do
         | 
| 226 263 | 
             
                        subject[:with_user_language].should == {
         | 
| 227 | 
            -
                          ' | 
| 228 | 
            -
             | 
| 229 | 
            -
                            ' | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
                             | 
| 235 | 
            -
                            ' | 
| 264 | 
            +
                          'count' => 4,
         | 
| 265 | 
            +
                          'languages' => {
         | 
| 266 | 
            +
                            'zh' => {
         | 
| 267 | 
            +
                              'percentage' => 75,
         | 
| 268 | 
            +
                              'count'      => 3,
         | 
| 269 | 
            +
                              'language'   => {'abbreviation'=>'zh', 'name'=>'Chinese', 'population'=>20000, 'countries' => 'China, Hong-Kong, Macau' },
         | 
| 270 | 
            +
                              'users'      => [{'id' => '1', 'lang' => 'zh'}, {'id' => '2', 'lang' => 'zh'}, {'id' => '4', 'lang' => 'zh'}]
         | 
| 271 | 
            +
                            },
         | 
| 272 | 
            +
                            'en' => {
         | 
| 273 | 
            +
                              'percentage' => 25,
         | 
| 274 | 
            +
                              'count'      => 1,
         | 
| 275 | 
            +
                              'language'=>{'abbreviation'=>'en', 'name'=>'English', 'population'=>238000000, 'countries' => 'USA, Canada, UK, Ireland, Australia' },
         | 
| 276 | 
            +
                              'users' => [{'id' => '3', 'lang' => 'en'},]
         | 
| 277 | 
            +
                            }
         | 
| 236 278 | 
             
                          }
         | 
| 237 279 | 
             
                        }
         | 
| 238 280 |  | 
| 239 281 | 
             
                        subject[:without_user_language].should eq(
         | 
| 240 | 
            -
                          ' | 
| 241 | 
            -
             | 
| 242 | 
            -
                            ' | 
| 243 | 
            -
             | 
| 282 | 
            +
                          'count' => 3,
         | 
| 283 | 
            +
                          'languages' => {
         | 
| 284 | 
            +
                            'zh' => {
         | 
| 285 | 
            +
                              'percentage' => 100,
         | 
| 286 | 
            +
                              'count'      => 3,
         | 
| 287 | 
            +
                              'language'=>{'abbreviation'=>'zh', 'name'=>'Chinese', 'population'=>20000, 'countries' => 'China, Hong-Kong, Macau' },
         | 
| 288 | 
            +
                              'users' => [{'id' => '1', 'lang' => 'zh'}, {'id' => '2', 'lang' => 'zh'}, {'id' => '4', 'lang' => 'zh'}]
         | 
| 289 | 
            +
                            }
         | 
| 244 290 | 
             
                          }
         | 
| 245 291 | 
             
                        )
         | 
| 246 292 | 
             
                      end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: aloha_analyzer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0 | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Matthieu Aussaguel
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-05- | 
| 11 | 
            +
            date: 2014-05-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |