Sha256: ebffd8a285ffc87065efcd876bd4ab370d5aa1854eb8a65262b0a823f6871000

Contents?: true

Size: 890 Bytes

Versions: 37

Compression:

Stored size: 890 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"
          result[:price] = "Free"
        end
        result
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
onebox-1.8.61 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.60 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.59 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.58 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.57 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.55 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.54 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.53 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.52 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.51 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.50 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.49 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.48 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.47 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.46 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.45 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.44 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.43 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.42 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.8.41 lib/onebox/engine/google_play_app_onebox.rb