idiomag 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.
- data/History +2 -0
- data/LICENSE +9 -0
- data/README.rdoc +151 -0
- data/Rakefile +54 -0
- data/VERSION.yml +4 -0
- data/lib/idiomag.rb +17 -0
- data/lib/idiomag/articles.rb +48 -0
- data/lib/idiomag/artist.rb +103 -0
- data/lib/idiomag/base.rb +9 -0
- data/lib/idiomag/helpers.rb +26 -0
- data/lib/idiomag/parser.rb +32 -0
- data/lib/idiomag/recommendation.rb +70 -0
- data/lib/idiomag/rest.rb +20 -0
- data/lib/idiomag/tag.rb +106 -0
- data/lib/idiomag/user.rb +114 -0
- data/spec/articles_spec.rb +61 -0
- data/spec/artist_spec.rb +149 -0
- data/spec/base_spec.rb +15 -0
- data/spec/fixtures/articles_featured.json +1 -0
- data/spec/fixtures/articles_latest.json +1 -0
- data/spec/fixtures/artist_articles.json +1 -0
- data/spec/fixtures/artist_info.json +1 -0
- data/spec/fixtures/artist_photos.json +1 -0
- data/spec/fixtures/artist_playlist.json +1 -0
- data/spec/fixtures/artist_tags.json +1 -0
- data/spec/fixtures/artist_videos.json +1 -0
- data/spec/fixtures/recommendation_articles.json +1 -0
- data/spec/fixtures/recommendation_artists.json +1 -0
- data/spec/fixtures/tag_articles.json +1 -0
- data/spec/fixtures/tag_artists.json +1 -0
- data/spec/fixtures/tag_list.txt +144 -0
- data/spec/fixtures/tag_photos.json +1 -0
- data/spec/fixtures/tag_playlist.json +1 -0
- data/spec/fixtures/tag_videos.json +1 -0
- data/spec/fixtures/user_articles.json +1 -0
- data/spec/fixtures/user_info.json +1 -0
- data/spec/fixtures/user_lovedarticles.json +1 -0
- data/spec/fixtures/user_photos.json +1 -0
- data/spec/fixtures/user_playlist.json +1 -0
- data/spec/fixtures/user_videos.json +1 -0
- data/spec/recommendation_spec.rb +88 -0
- data/spec/rest_spec.rb +41 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/tag_spec.rb +149 -0
- data/spec/user_spec.rb +169 -0
- metadata +112 -0
    
        data/spec/user_spec.rb
    ADDED
    
    | @@ -0,0 +1,169 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/spec_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'Idiomag::User' do
         | 
| 4 | 
            +
              before(:each) do
         | 
| 5 | 
            +
                @user = Idiomag::User.new('Titanous')
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              it 'should require an user' do
         | 
| 9 | 
            +
                lambda { Idiomag::User.new }.should raise_error(ArgumentError)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              it 'should know the username' do
         | 
| 13 | 
            +
                @user.user.should == 'Titanous'
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              it 'should respond_to the correct methods' do
         | 
| 17 | 
            +
                @user.respond_to?(:name).should == true
         | 
| 18 | 
            +
                @user.respond_to?(:user).should == true
         | 
| 19 | 
            +
                @user.respond_to?(:get).should == true
         | 
| 20 | 
            +
                @user.respond_to?(:email).should == true
         | 
| 21 | 
            +
                @user.respond_to?(:url).should == true
         | 
| 22 | 
            +
                @user.respond_to?(:tags).should == true
         | 
| 23 | 
            +
                @user.respond_to?(:artists).should == true
         | 
| 24 | 
            +
                @user.respond_to?(:articles).should == true
         | 
| 25 | 
            +
                @user.respond_to?(:loved_articles).should == true
         | 
| 26 | 
            +
                @user.respond_to?(:photos).should == true
         | 
| 27 | 
            +
                @user.respond_to?(:videos).should == true
         | 
| 28 | 
            +
                @user.respond_to?(:playlist).should == true
         | 
| 29 | 
            +
                @user.respond_to?(:tracks).should == true
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
              it 'should error on invalid get argument' do
         | 
| 33 | 
            +
                lambda { @user.get(:foo) }.should raise_error(ArgumentError)
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
              
         | 
| 36 | 
            +
              it 'should error on invalid method' do
         | 
| 37 | 
            +
                lambda { @user.foo }.should raise_error(NoMethodError)
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
              
         | 
| 40 | 
            +
              describe 'info' do
         | 
| 41 | 
            +
                before(:each) do
         | 
| 42 | 
            +
                  @data = open(Fixtures + 'user_info.json').read
         | 
| 43 | 
            +
                  Idiomag::REST.should_receive(:fetch).with('user/info',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it 'should allow prefetching' do
         | 
| 47 | 
            +
                  @user.get(:info)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                it 'should get the users name' do
         | 
| 51 | 
            +
                  @user.name.should == 'Jonathan'
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
                
         | 
| 54 | 
            +
                it 'should get the users email hash' do
         | 
| 55 | 
            +
                  @user.email.should == 'e6fbe7774a09bd85aabc4943433858e82ce71e0f'
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                it 'should get the users profile url' do
         | 
| 59 | 
            +
                  @user.url.should include('http://www.idiomag.com/user/Titanous')
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
                
         | 
| 62 | 
            +
                it 'should get the users artists' do
         | 
| 63 | 
            +
                  @user.artists['Relient K'].should == 1.0
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                it 'should get the users tags' do
         | 
| 67 | 
            +
                  @user.tags[:alternative_rock].should == 0.67
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
              
         | 
| 71 | 
            +
              describe 'articles' do
         | 
| 72 | 
            +
                before(:each) do
         | 
| 73 | 
            +
                  @data = open(Fixtures + 'user_articles.json').read
         | 
| 74 | 
            +
                  Idiomag::REST.should_receive(:fetch).with('user/articles',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
                
         | 
| 77 | 
            +
               it 'should allow prefetching' do
         | 
| 78 | 
            +
                  @user.get(:articles)
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
                
         | 
| 81 | 
            +
                it 'should get articles' do
         | 
| 82 | 
            +
                  @user.articles[0][:artist].should == 'BarlowGirl'
         | 
| 83 | 
            +
                  @user.articles[0][:description].blank?.should_not == true
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
                
         | 
| 86 | 
            +
                it 'should parse the dates' do
         | 
| 87 | 
            +
                  @user.articles[0][:date].class.should == Time
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
              
         | 
| 91 | 
            +
              describe 'loved articles' do
         | 
| 92 | 
            +
                 before(:each) do
         | 
| 93 | 
            +
                   @data = open(Fixtures + 'user_lovedarticles.json').read
         | 
| 94 | 
            +
                   Idiomag::REST.should_receive(:fetch).with('user/lovedarticles',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 95 | 
            +
                 end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                it 'should allow prefetching' do
         | 
| 98 | 
            +
                   @user.get(:loved_articles)
         | 
| 99 | 
            +
                 end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                 it 'should get articles' do
         | 
| 102 | 
            +
                   @user.loved_articles[0][:artist].should == 'The Afters'
         | 
| 103 | 
            +
                   @user.loved_articles[0][:description].blank?.should_not == true
         | 
| 104 | 
            +
                 end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                 it 'should parse the dates' do
         | 
| 107 | 
            +
                   @user.loved_articles[0][:date].class.should == Time
         | 
| 108 | 
            +
                 end
         | 
| 109 | 
            +
              end
         | 
| 110 | 
            +
              
         | 
| 111 | 
            +
              describe 'photos' do
         | 
| 112 | 
            +
                before(:each) do
         | 
| 113 | 
            +
                  @data = open(Fixtures + 'user_photos.json').read
         | 
| 114 | 
            +
                  Idiomag::REST.should_receive(:fetch).with('user/photos',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
                
         | 
| 117 | 
            +
                it 'should allow prefetching' do
         | 
| 118 | 
            +
                  @user.get(:photos)
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
                
         | 
| 121 | 
            +
                it 'should get photos' do
         | 
| 122 | 
            +
                  @user.photos[0][:title].should =~ /jpg/
         | 
| 123 | 
            +
                  @user.photos[0][:url].should =~ /jpg/
         | 
| 124 | 
            +
                  @user.photos[0][:width].class.should == Fixnum
         | 
| 125 | 
            +
                  @user.photos[0][:height].class.should == Fixnum
         | 
| 126 | 
            +
                end
         | 
| 127 | 
            +
                
         | 
| 128 | 
            +
                it 'should parse the dates' do
         | 
| 129 | 
            +
                  @user.photos[0][:date].class.should == Time
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
              end
         | 
| 132 | 
            +
              
         | 
| 133 | 
            +
              describe 'videos' do    
         | 
| 134 | 
            +
                before(:each) do
         | 
| 135 | 
            +
                  @data = open(Fixtures + 'user_videos.json').read
         | 
| 136 | 
            +
                  Idiomag::REST.should_receive(:fetch).with('user/videos',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 137 | 
            +
                end
         | 
| 138 | 
            +
                
         | 
| 139 | 
            +
                it 'should allow prefetching' do
         | 
| 140 | 
            +
                  @user.get(:videos)
         | 
| 141 | 
            +
                end
         | 
| 142 | 
            +
                
         | 
| 143 | 
            +
                it 'should get videos' do
         | 
| 144 | 
            +
                  @user.videos[0][:location].should =~ /video/
         | 
| 145 | 
            +
                  @user.videos[0][:info].should =~ /youtube/
         | 
| 146 | 
            +
                  @user.videos[0][:thumb].should =~ /jpg/
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
              end
         | 
| 149 | 
            +
              
         | 
| 150 | 
            +
              describe 'playlist' do
         | 
| 151 | 
            +
                before(:each) do
         | 
| 152 | 
            +
                  @data = open(Fixtures + 'user_playlist.json').read
         | 
| 153 | 
            +
                  Idiomag::REST.should_receive(:fetch).with('user/playlist',:user=>'Titanous').and_return(JSON.parse(@data))
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
                
         | 
| 156 | 
            +
                it 'should allow prefetching' do
         | 
| 157 | 
            +
                  @user.get(:playlist)
         | 
| 158 | 
            +
                end
         | 
| 159 | 
            +
                
         | 
| 160 | 
            +
                it 'should get playlist' do
         | 
| 161 | 
            +
                  @user.playlist[0][:location] =~ /mp3/
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
                
         | 
| 164 | 
            +
                it 'should respond to #tracks' do
         | 
| 165 | 
            +
                  @user.get(:tracks)
         | 
| 166 | 
            +
                  @user.tracks[0][:location] =~ /mp3/
         | 
| 167 | 
            +
                end
         | 
| 168 | 
            +
              end
         | 
| 169 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,112 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: idiomag
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Jonathan Rudenberg
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            date: 2008-12-19 00:00:00 -05:00
         | 
| 13 | 
            +
            default_executable: 
         | 
| 14 | 
            +
            dependencies: 
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 16 | 
            +
              name: httparty
         | 
| 17 | 
            +
              type: :runtime
         | 
| 18 | 
            +
              version_requirement: 
         | 
| 19 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 20 | 
            +
                requirements: 
         | 
| 21 | 
            +
                - - ">="
         | 
| 22 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                    version: 0.2.2
         | 
| 24 | 
            +
                version: 
         | 
| 25 | 
            +
            description: wrapper for the idiomag api
         | 
| 26 | 
            +
            email: jon335@gmail.com
         | 
| 27 | 
            +
            executables: []
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            extensions: []
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            extra_rdoc_files: 
         | 
| 32 | 
            +
            - README.rdoc
         | 
| 33 | 
            +
            files: 
         | 
| 34 | 
            +
            - lib/idiomag/articles.rb
         | 
| 35 | 
            +
            - lib/idiomag/artist.rb
         | 
| 36 | 
            +
            - lib/idiomag/base.rb
         | 
| 37 | 
            +
            - lib/idiomag/helpers.rb
         | 
| 38 | 
            +
            - lib/idiomag/parser.rb
         | 
| 39 | 
            +
            - lib/idiomag/recommendation.rb
         | 
| 40 | 
            +
            - lib/idiomag/rest.rb
         | 
| 41 | 
            +
            - lib/idiomag/tag.rb
         | 
| 42 | 
            +
            - lib/idiomag/user.rb
         | 
| 43 | 
            +
            - lib/idiomag.rb
         | 
| 44 | 
            +
            - History
         | 
| 45 | 
            +
            - LICENSE
         | 
| 46 | 
            +
            - Rakefile
         | 
| 47 | 
            +
            - README.rdoc
         | 
| 48 | 
            +
            - VERSION.yml
         | 
| 49 | 
            +
            - spec/articles_spec.rb
         | 
| 50 | 
            +
            - spec/artist_spec.rb
         | 
| 51 | 
            +
            - spec/base_spec.rb
         | 
| 52 | 
            +
            - spec/fixtures
         | 
| 53 | 
            +
            - spec/fixtures/articles_featured.json
         | 
| 54 | 
            +
            - spec/fixtures/articles_latest.json
         | 
| 55 | 
            +
            - spec/fixtures/artist_articles.json
         | 
| 56 | 
            +
            - spec/fixtures/artist_info.json
         | 
| 57 | 
            +
            - spec/fixtures/artist_photos.json
         | 
| 58 | 
            +
            - spec/fixtures/artist_playlist.json
         | 
| 59 | 
            +
            - spec/fixtures/artist_tags.json
         | 
| 60 | 
            +
            - spec/fixtures/artist_videos.json
         | 
| 61 | 
            +
            - spec/fixtures/recommendation_articles.json
         | 
| 62 | 
            +
            - spec/fixtures/recommendation_artists.json
         | 
| 63 | 
            +
            - spec/fixtures/tag_articles.json
         | 
| 64 | 
            +
            - spec/fixtures/tag_artists.json
         | 
| 65 | 
            +
            - spec/fixtures/tag_list.txt
         | 
| 66 | 
            +
            - spec/fixtures/tag_photos.json
         | 
| 67 | 
            +
            - spec/fixtures/tag_playlist.json
         | 
| 68 | 
            +
            - spec/fixtures/tag_videos.json
         | 
| 69 | 
            +
            - spec/fixtures/user_articles.json
         | 
| 70 | 
            +
            - spec/fixtures/user_info.json
         | 
| 71 | 
            +
            - spec/fixtures/user_lovedarticles.json
         | 
| 72 | 
            +
            - spec/fixtures/user_photos.json
         | 
| 73 | 
            +
            - spec/fixtures/user_playlist.json
         | 
| 74 | 
            +
            - spec/fixtures/user_videos.json
         | 
| 75 | 
            +
            - spec/recommendation_spec.rb
         | 
| 76 | 
            +
            - spec/rest_spec.rb
         | 
| 77 | 
            +
            - spec/spec_helper.rb
         | 
| 78 | 
            +
            - spec/tag_spec.rb
         | 
| 79 | 
            +
            - spec/user_spec.rb
         | 
| 80 | 
            +
            has_rdoc: true
         | 
| 81 | 
            +
            homepage: http://idiomag.rubyforge.org
         | 
| 82 | 
            +
            post_install_message: 
         | 
| 83 | 
            +
            rdoc_options: 
         | 
| 84 | 
            +
            - --line-numbers
         | 
| 85 | 
            +
            - --inline-source
         | 
| 86 | 
            +
            - --title
         | 
| 87 | 
            +
            - idiomag
         | 
| 88 | 
            +
            - --main
         | 
| 89 | 
            +
            - README.rdoc
         | 
| 90 | 
            +
            require_paths: 
         | 
| 91 | 
            +
            - lib
         | 
| 92 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 93 | 
            +
              requirements: 
         | 
| 94 | 
            +
              - - ">="
         | 
| 95 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 96 | 
            +
                  version: "0"
         | 
| 97 | 
            +
              version: 
         | 
| 98 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 99 | 
            +
              requirements: 
         | 
| 100 | 
            +
              - - ">="
         | 
| 101 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 102 | 
            +
                  version: "0"
         | 
| 103 | 
            +
              version: 
         | 
| 104 | 
            +
            requirements: []
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            rubyforge_project: idiomag
         | 
| 107 | 
            +
            rubygems_version: 1.3.1
         | 
| 108 | 
            +
            signing_key: 
         | 
| 109 | 
            +
            specification_version: 2
         | 
| 110 | 
            +
            summary: wrapper for the idiomag api
         | 
| 111 | 
            +
            test_files: []
         | 
| 112 | 
            +
             |