shikiho 0.1.0 → 0.1.1
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/Gemfile +2 -2
- data/Gemfile.lock +6 -7
- data/lib/shikiho.rb +17 -8
- data/lib/shikiho/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 665d44731886a4ac12448b2c4bdb9c3a82ace3e005830a4cf9f0c8a6634cc018
         | 
| 4 | 
            +
              data.tar.gz: f37cb7b495e8e5ec545c1513c724bc856ee754a76e0b932a9a89e7ffaa4a065d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 18d1a149c5abbd34fc1f6003e0d39c54cef1463bd36e7506c4b4e7adbdff5c3d9fbe7b3bdd52c9d337094e834a01ce9592ace41cd0e257182bb2a1c280a2ef76
         | 
| 7 | 
            +
              data.tar.gz: a03f50af30e9e5d61f243592d0271144dcb09d2d1f84f544d8665bd24c52a54811e68f913d3ef17cd89aad240996bc2de25705d88d9ffc1c2fa81e08ab572c88
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -16,8 +16,7 @@ GEM | |
| 16 16 | 
             
                ast_utils (0.3.0)
         | 
| 17 17 | 
             
                  parser (~> 2.4)
         | 
| 18 18 | 
             
                  thor (>= 0.19)
         | 
| 19 | 
            -
                childprocess (0. | 
| 20 | 
            -
                  ffi (~> 1.0, >= 1.0.11)
         | 
| 19 | 
            +
                childprocess (4.0.0)
         | 
| 21 20 | 
             
                concurrent-ruby (1.1.7)
         | 
| 22 21 | 
             
                diff-lcs (1.4.4)
         | 
| 23 22 | 
             
                ffi (1.14.2)
         | 
| @@ -52,10 +51,10 @@ GEM | |
| 52 51 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 53 52 | 
             
                  rspec-support (~> 3.10.0)
         | 
| 54 53 | 
             
                rspec-support (3.10.1)
         | 
| 55 | 
            -
                rubyzip ( | 
| 56 | 
            -
                selenium-webdriver ( | 
| 57 | 
            -
                  childprocess ( | 
| 58 | 
            -
                  rubyzip ( | 
| 54 | 
            +
                rubyzip (2.3.0)
         | 
| 55 | 
            +
                selenium-webdriver (4.0.0.alpha7)
         | 
| 56 | 
            +
                  childprocess (>= 0.5, < 5.0)
         | 
| 57 | 
            +
                  rubyzip (>= 1.2.2)
         | 
| 59 58 | 
             
                  websocket (~> 1.0)
         | 
| 60 59 | 
             
                steep (0.39.0)
         | 
| 61 60 | 
             
                  activesupport (>= 5.1)
         | 
| @@ -79,7 +78,7 @@ DEPENDENCIES | |
| 79 78 | 
             
              nokogiri (= 1.11.0)
         | 
| 80 79 | 
             
              rake (= 12.3.3)
         | 
| 81 80 | 
             
              rspec (~> 3.0)
         | 
| 82 | 
            -
              selenium-webdriver (=  | 
| 81 | 
            +
              selenium-webdriver (= 4.0.0.alpha7)
         | 
| 83 82 | 
             
              shikiho!
         | 
| 84 83 | 
             
              steep (= 0.39.0)
         | 
| 85 84 |  | 
    
        data/lib/shikiho.rb
    CHANGED
    
    | @@ -8,10 +8,19 @@ module Shikiho | |
| 8 8 | 
             
              class Error < StandardError; end
         | 
| 9 9 |  | 
| 10 10 | 
             
              def self.get_stock_price_now code:
         | 
| 11 | 
            +
                i = 0
         | 
| 11 12 | 
             
                driver = self.get_selenium_driver mode: :chrome
         | 
| 12 13 | 
             
                driver.get("https://shikiho.jp/stocks/#{code.to_s}")
         | 
| 13 | 
            -
                sleep  | 
| 14 | 
            -
                 | 
| 14 | 
            +
                sleep 3
         | 
| 15 | 
            +
                begin
         | 
| 16 | 
            +
                  price = driver.find_element(:css, "div.current").text.to_s
         | 
| 17 | 
            +
                rescue
         | 
| 18 | 
            +
                  puts "Retry... wait 2 sec.."
         | 
| 19 | 
            +
                  sleep 2
         | 
| 20 | 
            +
                  i += 1
         | 
| 21 | 
            +
                  raise StandardError, "Something wrong! Make sure your code exists" if i > 5
         | 
| 22 | 
            +
                  retry
         | 
| 23 | 
            +
                end
         | 
| 15 24 | 
             
                driver.quit
         | 
| 16 25 | 
             
                { code: code, price: price, datetime: Time.now.utc }
         | 
| 17 26 | 
             
              rescue StandardError => e
         | 
| @@ -26,12 +35,12 @@ module Shikiho | |
| 26 35 | 
             
                when :firefox
         | 
| 27 36 | 
             
                  Selenium::WebDriver.for :firefox
         | 
| 28 37 | 
             
                else
         | 
| 29 | 
            -
                   | 
| 30 | 
            -
             | 
| 31 | 
            -
                   | 
| 32 | 
            -
                   | 
| 33 | 
            -
                   | 
| 34 | 
            -
                  Selenium::WebDriver.for :chrome | 
| 38 | 
            +
                  options = Selenium::WebDriver::Chrome::Options.new
         | 
| 39 | 
            +
                  options.add_argument("--headless")
         | 
| 40 | 
            +
                  options.add_argument("--ignore-certificate-errors")
         | 
| 41 | 
            +
                  options.add_argument("--disable-popup-blocking")
         | 
| 42 | 
            +
                  options.add_argument("--disable-translate")
         | 
| 43 | 
            +
                  Selenium::WebDriver.for :chrome, options: options
         | 
| 35 44 | 
             
                end
         | 
| 36 45 | 
             
              end
         | 
| 37 46 | 
             
            end
         | 
    
        data/lib/shikiho/version.rb
    CHANGED