Sha256: 405c81dcfc671e8366ddce0d52e3694898755f5239aebf019918440f6e6f26e2

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'bundler/gem_tasks'
require 'rake/testtask'
require 'json'
require 'httparty'

MOBILE_DETECT_JSON = 'https://raw.github.com/serbanghita/Mobile-Detect/master/Mobile_Detect.json'
TABLET_FILE        = 'lib/mobile-fu/tablet.rb'

task :default => [:test]

Rake::TestTask.new do |t|
  t.libs.push 'lib'
  t.test_files = FileList['spec/*_spec.rb', 'spec/mobile-fu/*_spec.rb']
  t.verbose = true
end

desc "Pull in data from Mobile Detect"
task :pull_mobile_detect_data do
  
  # call out to Mobile Detect to get the data
  content = HTTParty.get(MOBILE_DETECT_JSON).body

  # build a new tablet regex
  data      = JSON.parse content
  regexes   = data['uaMatch']['tablets'].each.map { |_, v| v }
  new_regex = regexes.join('|').downcase

  # rewrite the tablet regex in our file
  new_content = File.read(TABLET_FILE).gsub!(/TABLET_USER_AGENTS = \/.*\//, "TABLET_USER_AGENTS = \/#{new_regex}\/")
  File.open(TABLET_FILE, 'w') { |f| f.write new_content }

end

# desc 'Generate documentation for the mobile_fu plugin.'
# Rake::RDocTask.new(:rdoc) do |rdoc|
#   rdoc.rdoc_dir = 'rdoc'
#   rdoc.title    = 'MobileFu'
#   rdoc.options << '--line-numbers' << '--inline-source'
#   rdoc.rdoc_files.include('README')
#   rdoc.rdoc_files.include('lib/**/*.rb')
# end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
mobile-fu-1.4.0 Rakefile
mobile_fu-1.4.0 Rakefile
mobile-fu-uncommon-1.3.4 Rakefile
mobile-fu-uncommon-1.3.3 Rakefile
mobile-fu-uncommon-1.3.2 Rakefile
mobile-fu-uncommon-1.3.1 Rakefile
mobile-fu-1.3.1 Rakefile