Sha256: 194ec07e9b25ea328e0a9b34db6d6c095ce2a8ef01bdf19f87441c50565f9b50

Contents?: true

Size: 898 Bytes

Versions: 75

Compression:

Stored size: 898 Bytes

Contents

module Onebox
  module Engine
    class GooglePlayAppOnebox
      include Engine
      include LayoutSupport
      include HTML

      DEFAULTS = {
        MAX_DESCRIPTION_CHARS: 500
      }


      matches_regexp Regexp.new("^https?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
      always_https

      private

      def data
        result = {
          link: link,
          title: raw.css(".document-title div").inner_text,
          developer: raw.css(".document-subtitle.primary").inner_text,
          image: raw.css(".cover-image").first["src"],
          description: raw.css(".text-body div").inner_text[0..DEFAULTS[:MAX_DESCRIPTION_CHARS]].chop + "...",
          price: raw.css(".price.buy meta[itemprop=price]").first["content"]
        }
        if result[:price] == "0" then
            result[:price] = "Free"
        end
        result
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
onebox-1.8.2 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.1 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.0 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.9 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.8 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.7 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.6 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.5 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.4 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.3 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.2 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.1 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.7.0 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.9 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.8 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.7 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.6 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.5 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.4 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.6.3 lib/onebox/engine/google_play_app_onebox.rb