top-headlines 0.1.5 → 0.1.6
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/README.md +1 -1
- data/lib/top-headlines/cli.rb +14 -13
- data/lib/top-headlines/source.rb +14 -1
- data/lib/top-headlines/version.rb +1 -1
- data/top-headlines.gemspec +1 -1
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0c88668ec85c6c26dff66038f0f954c04eb10bfa
         | 
| 4 | 
            +
              data.tar.gz: 0cd78d10749f7bf9d911a43be3f234461a5a0869
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 87138d600b6568d5534924a0a33ab2733dea4d425f89eb9c83dd933c5c0ba7a93b86a3d048cd68b018e31529113a285f2d8a341accb95ceff30288af66595432
         | 
| 7 | 
            +
              data.tar.gz: 7749ecadb7de1f85a57eb0a31be441ed9f4170012410f37b8bfb7c4eabf3b659591761c0a167759a56707e558ef1cc86e7b17cceb9d7e6d0261112ae267e85a7
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # TopHeadlines
         | 
| 2 2 |  | 
| 3 | 
            -
            This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line. Functionality includes: BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.
         | 
| 3 | 
            +
            This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line. Functionality includes: AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.
         | 
| 4 4 |  | 
| 5 5 | 
             
            ## Installation
         | 
| 6 6 |  | 
    
        data/lib/top-headlines/cli.rb
    CHANGED
    
    | @@ -16,6 +16,7 @@ class TopHeadlines::CLI | |
| 16 16 | 
             
                  if @input == "ALL"
         | 
| 17 17 | 
             
                    list_all_headlines_banner
         | 
| 18 18 | 
             
                    list_all_headlines
         | 
| 19 | 
            +
                    # open_headline_in_browser
         | 
| 19 20 | 
             
                    puts request_input_full_menu
         | 
| 20 21 | 
             
                    print "YOUR SELECTION: "
         | 
| 21 22 | 
             
                  elsif @input == "SOURCES"
         | 
| @@ -87,19 +88,19 @@ class TopHeadlines::CLI | |
| 87 88 | 
             
                print "YOUR SELECTION: "
         | 
| 88 89 | 
             
                @num = gets.strip.upcase
         | 
| 89 90 | 
             
                  while @num.to_i.between?(1,5)
         | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 91 | 
            +
                      headline = TopHeadlines::Source.scrape_headlines(@input)[@num.to_i-1]
         | 
| 92 | 
            +
                      puts "\n=> You selected the #{@num.to_i.ordinalize} headline: '#{headline}'."
         | 
| 93 | 
            +
                      puts "=> Opening..."
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                      sleep(2)
         | 
| 96 | 
            +
                      url = TopHeadlines::Source.scrape_urls(@input)[@num.to_i-1]
         | 
| 97 | 
            +
                      system("open", url)
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                      sleep(1)
         | 
| 100 | 
            +
                      puts "\nSelect another headline number to open full article in the browser."
         | 
| 101 | 
            +
                      print "YOUR SELECTION: "
         | 
| 102 | 
            +
                      @num = gets.strip.upcase
         | 
| 103 | 
            +
                      @input = @num if @num == "EXIT"
         | 
| 103 104 | 
             
                  end
         | 
| 104 105 | 
             
                invalid_entry unless @input == "EXIT"
         | 
| 105 106 | 
             
              end
         | 
    
        data/lib/top-headlines/source.rb
    CHANGED
    
    | @@ -91,6 +91,18 @@ class TopHeadlines::Source | |
| 91 91 | 
             
                  urls_selector: "div#mrt-node-Col1-1-WideHero",
         | 
| 92 92 | 
             
                  child_selector: "a[class*='D(b)']"
         | 
| 93 93 | 
             
                },  
         | 
| 94 | 
            +
                "AP" => {
         | 
| 95 | 
            +
                  url: "http://bigstory.ap.org",
         | 
| 96 | 
            +
                  headlines_selector: "h5.entry-title.node-title.title",
         | 
| 97 | 
            +
                  urls_selector: "h5.entry-title.node-title.title",
         | 
| 98 | 
            +
                  child_selector: "a:first-child"
         | 
| 99 | 
            +
                }, 
         | 
| 100 | 
            +
                # "REUTERS" => {
         | 
| 101 | 
            +
                #   url: "http://www.reuters.com/news",
         | 
| 102 | 
            +
                #   headlines_selector: "div.column1.gridPanel.grid8 div.moduleBody :not(div.photo) a", # NEED TO ACCOUNT FOR :not(span a) at same level as a
         | 
| 103 | 
            +
                #   urls_selector: "div.column1.gridPanel.grid8 div.moduleBody :not(div.photo)",
         | 
| 104 | 
            +
                #   child_selector: "a"
         | 
| 105 | 
            +
                # }, 
         | 
| 94 106 | 
             
                # "REDDIT" => { ## 429 Error
         | 
| 95 107 | 
             
                #   url: "https://www.reddit.com/r/news/",
         | 
| 96 108 | 
             
                #   headlines_selector: "p.title a.title.may-blank",
         | 
| @@ -110,9 +122,10 @@ class TopHeadlines::Source | |
| 110 122 | 
             
              end
         | 
| 111 123 |  | 
| 112 124 | 
             
              def self.list_all_headlines
         | 
| 125 | 
            +
                article_sum = 0  
         | 
| 113 126 | 
             
                SOURCES.keys.sort.each do |source|
         | 
| 114 127 | 
             
                  puts "*** #{source} ***"
         | 
| 115 | 
            -
                  scrape_headlines(source)[0,5]. | 
| 128 | 
            +
                  scrape_headlines(source)[0,5].each {|headline| puts "#{article_sum+1}. #{headline}"; article_sum += 1}
         | 
| 116 129 | 
             
                  puts "\n"
         | 
| 117 130 | 
             
                end
         | 
| 118 131 | 
             
              end
         | 
    
        data/top-headlines.gemspec
    CHANGED
    
    | @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| | |
| 9 9 | 
             
              spec.authors       = ["zachnewburgh"]
         | 
| 10 10 | 
             
              spec.email         = ["zach.newburgh@gmail.com"]
         | 
| 11 11 |  | 
| 12 | 
            -
              spec.summary       = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line for articles from BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.}
         | 
| 12 | 
            +
              spec.summary       = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line for articles from AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.}
         | 
| 13 13 | 
             
              spec.homepage      = "https://github.com/zachnewburgh/top-headlines-cli-gem"
         | 
| 14 14 | 
             
              spec.license       = "MIT"
         | 
| 15 15 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: top-headlines
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - zachnewburgh
         | 
| @@ -131,8 +131,8 @@ rubygems_version: 2.4.5.1 | |
| 131 131 | 
             
            signing_key: 
         | 
| 132 132 | 
             
            specification_version: 4
         | 
| 133 133 | 
             
            summary: This gem allows users to view the top headlines from major news sources.
         | 
| 134 | 
            -
              Users can open the headlines directly from the command line for articles | 
| 135 | 
            -
              Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, | 
| 136 | 
            -
              Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, | 
| 137 | 
            -
              Post, and Yahoo.
         | 
| 134 | 
            +
              Users can open the headlines in the browser directly from the command line for articles
         | 
| 135 | 
            +
              from AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News,
         | 
| 136 | 
            +
              The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal,
         | 
| 137 | 
            +
              Washington Post, and Yahoo.
         | 
| 138 138 | 
             
            test_files: []
         |