Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanup

  • Loading branch information...
commit bb9cb32fbb9d788870119de2123daa29797de40e 1 parent eeb21d5
Mark Percival authored
16 Rakefile
View
@@ -1,22 +1,6 @@
require 'rubygems'
require 'rake'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "divining_rod"
- gem.summary = %Q{A mobile phone web request profiler}
- gem.description = %Q{A mobile phone web request profiler using definitions that look like rails routes}
- gem.email = "mark@mpercival.com"
- gem.homepage = "http://github.com/mdp/divining_rod"
- gem.authors = ["Mark Percival"]
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
-end
-
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test' << '.'
1  VERSION
View
@@ -1 +0,0 @@
-1.0.0
78 divining_rod.gemspec
View
@@ -1,69 +1,21 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "divining_rod/version"
Gem::Specification.new do |s|
- s.name = %q{divining_rod}
- s.version = "0.4.0"
+ s.name = "divining_rod"
+ s.version = DiviningRod::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Mark Percival"]
+ s.email = ["mark@markpercival.us"]
+ s.homepage = "http://github.com/mdp/divining_rod"
+ s.summary = %q{An opinionated ruby encryption library}
+ s.description = %q{Supports OpenSSL compatible AES, HMAC, and RSA encryption}
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Mark Percival"]
- s.date = %q{2010-02-23}
- s.description = %q{A mobile phone web request profiler using definitions that look like rails routes}
- s.email = %q{mark@mpercival.com}
- s.extra_rdoc_files = [
- "LICENSE",
- "README.markdown"
- ]
- s.files = [
- ".document",
- ".gitignore",
- "LICENSE",
- "README.markdown",
- "Rakefile",
- "VERSION",
- "divining_rod.gemspec",
- "example_config.rb",
- "lib/divining_rod.rb",
- "lib/divining_rod/definition.rb",
- "lib/divining_rod/mapper.rb",
- "lib/divining_rod/mappings.rb",
- "lib/divining_rod/matchers.rb",
- "lib/divining_rod/murge.rb",
- "lib/divining_rod/profile.rb",
- "spec/definition_spec.rb",
- "spec/example_mapping_spec.rb",
- "spec/mapper_spec.rb",
- "spec/mapping_spec.rb",
- "spec/profile_spec.rb",
- "spec/spec_helper.rb"
- ]
- s.homepage = %q{http://github.com/markpercival/divining_rod}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{A mobile phone web request profiler}
- s.test_files = [
- "spec/definition_spec.rb",
- "spec/example_mapping_spec.rb",
- "spec/mapper_spec.rb",
- "spec/mapping_spec.rb",
- "spec/profile_spec.rb",
- "spec/spec_helper.rb"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.rubyforge_project = "divining_rod"
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
- else
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
- end
- else
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
- end
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
end
-
3  lib/divining_rod/version.rb
View
@@ -0,0 +1,3 @@
+module DiviningRod
+ VERSION = "0.6.0"
+end
40 spec/definition_spec.rb
View
@@ -1,40 +0,0 @@
-require 'spec_helper'
-
-describe DiviningRod::Definition do
-
- it "should work with no children not match" do
- definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request|
- request == 'iphone'
- }
- definition.evaluate('foo').should be_nil
- end
-
- it "should work with no children and match" do
- definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request|
- request == 'iphone'
- }
- definition.evaluate('iphone').should eql(definition)
- end
-
- describe "with children" do
-
- it "should work with children that match" do
- definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request|
- request.match(/iphone/)
- }
- definition.children << DiviningRod::Definition.new(:format => :ipod, :tags => [:big, :lacks_a_camera]) { |request|
- request.match(/ipod/)
- }
- definition.children << DiviningRod::Definition.new(:format => :ipad, :tags => [:big, :lacks_a_camera]) { |request|
- request.match(/ipad/)
- }
- result = definition.evaluate('iphone ipad')
- result.should_not eql(definition)
- result.format.should eql(:ipad)
- result.tags.should include(:overpriced)
- end
-
-
- end
-
-end
78 spec/mapping_spec.rb
View
@@ -1,78 +0,0 @@
-require 'spec_helper'
-
-describe DiviningRod::Mappings do
-
- before :each do
- DiviningRod::Mappings.define(:tags => :mobile) do |map|
- map.ua /Apple/, :format => :webkit, :tags => [:apple] do |apple|
-
- # iPod, iPhone, and iPad
- apple.with_options :tags => [:youtube, :geolocate, :iphone] do |advanced|
- advanced.ua /iPad/, :tags => :ipad do |ipad|
- ipad.ua /OS\s4/, :tags => :version4
- ipad.ua /OS\s3/, :tags => :version3 do |v3|
- v3.ua /Unicorns/, :tags => :omg_unicorns do |unicorns|
- unicorns.ua /eat kittens/, :tags => [:omg_they_eat_kittens]
- end
- end
- ipad.ua /OS\s2/, :tags => :version2
- end
- advanced.ua /iPod/, :tags => [:ipod, :ipod_touch]
- end
-
- # Also an apple but actualy a newton
- apple.ua /Newton/, :tags => [:apple] do |newton|
- newton.ua /OS 8/, :tags => :os8
- end
- end
- end
- end
-
- it "should match a top level user agent" do
- request = request_mock(:ua => 'Apple Mobile Safari', :format => :html)
- result = DiviningRod::Mappings.root_definition.evaluate(request)
- result.should_not be_nil
- result.tags.should include(:apple)
- result.tags.should_not include(:ipad)
- result.tags.should include(:mobile)
- end
-
- it "should match a child definition" do
- ipad_request = request_mock(:ua => 'Apple iPad', :format => :html)
- result = DiviningRod::Mappings.evaluate(ipad_request)
- result.tags.should include(:ipad)
- end
-
- it "should match a sub child definition" do
- ipad_request = request_mock(:ua => 'Apple iPad - now powered by Unicorns - OS 3.3', :format => :html)
- result = DiviningRod::Mappings.evaluate(ipad_request)
- result.tags.should include(:ipad)
- result.tags.should include(:omg_unicorns)
- result.tags.should include(:version3)
- end
-
- it "should match a really really deep child definition" do
- ipad_request = request_mock(:ua => 'Apple iPad - now powered by Unicorns who eat kittens - OS 3.3', :format => :html)
- result = DiviningRod::Mappings.evaluate(ipad_request)
- result.tags.should include(:ipad, :youtube)
- result.tags.should include(:omg_unicorns)
- result.tags.should include(:omg_they_eat_kittens)
- result.tags.should include(:version3)
- end
-
- it "should match a in order defined" do
- ipad_request = request_mock(:ua => 'Apple iPad - now powered by Unicorns who eat kittens - OS 2', :format => :html)
- result = DiviningRod::Mappings.evaluate(ipad_request)
- result.tags.should include(:ipad, :youtube)
- result.tags.should_not include(:omg_they_eat_kittens, :omg_unicorns)
- result.tags.should include(:version2)
- end
-
- it "should match a in order defined" do
- ipad_request = request_mock(:ua => 'Apple Newton - OS 8', :format => :html)
- result = DiviningRod::Mappings.evaluate(ipad_request)
- result.tags.should_not include(:omg_they_eat_kittens, :omg_unicorns)
- result.tags.should include(:os8)
- end
-
-end
118 spec/profile_spec.rb
View
@@ -1,118 +0,0 @@
-require 'spec_helper'
-
-describe DiviningRod do
-
- before :each do
- @request = request_mock(:ua => 'My iPhone which is actually an iPad')
-
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :webkit, :tags => [:iphone, :youtube, :geolocate] do |iphone|
- iphone.ua /iPad/, :tags => [:ipad]
- end
- end
- end
-
- it "should recognize an iPhone" do
- profile = DiviningRod::Profile.new(@request)
- profile.format.should eql(:webkit)
- end
-
- it "should know if it belongs to a category tag" do
- profile = DiviningRod::Profile.new(@request)
- profile.ipad?.should be_true
- end
-
- it "should know if it does not belongs to a category" do
- profile = DiviningRod::Profile.new(@request)
- profile.wap?.should be_false
- end
-
- describe "without a default route" do
-
- before :each do
- @request = request_mock(:ua => 'My Foo Fone', :format => :html)
-
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :webkit, :tags => [:iphone, :youtube, :geolocate]
- end
- end
-
- it "should use the default group for unknown phones" do
- profile = DiviningRod::Profile.new(@request)
- profile.wap?.should be_false
- profile.format.should eql(:html)
- end
-
- end
-
-
- describe "with a default route" do
-
- before :each do
- @request = request_mock(:ua => 'My Foo Fone')
-
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :webkit, :tags => [:iphone, :youtube, :geolocate]
- map.default :format => :html
- end
- end
-
- it "should use the default group for unknown phones" do
- profile = DiviningRod::Profile.new(@request)
- profile.wap?.should be_false
- profile.format.should eql(:html)
- end
-
- end
-
- describe "without a default definition" do
-
- before :each do
- @request = request_mock(:ua => 'Foo Fone', :format => :html)
-
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :webkit, :tags => [:iphone, :youtube, :geolocate]
- end
- end
-
- it "should not find a match" do
- DiviningRod::Profile.new(@request).recognized?.should be_false
- end
-
- end
-
- describe "matching a subdomain" do
-
- before :each do
- @request = request_mock(:ua => 'Foo Fone', :host => 'wap.example.com')
-
- DiviningRod::Mappings.define do |map|
- map.subdomain /wap/, :format => :wap, :tags => [:shitty]
- end
- end
-
- it "should not find a match" do
- DiviningRod::Profile.new(@request).recognized?.should be_true
- profile = DiviningRod::Profile.new(@request)
- profile.wap?
- end
-
- end
-
- describe "matching the weird requests(no user_agent passed)" do
-
- before :each do
- @request = request_mock(:ua => nil, :subdomains => [])
-
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :wap, :tags => [:shitty]
- end
- end
-
- it "should not find a match" do
- DiviningRod::Profile.new(@request).recognized?.should be_false
- end
-
- end
-
-end
27 spec/rack_spec.rb
View
@@ -1,27 +0,0 @@
-require 'spec_helper'
-require "divining_rod/rack"
-require "rack/test"
-
-describe DiviningRod do
- include Rack::Test::Methods
-
- def app
- DiviningRod::Rack.new(app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['foo']] })
- end
-
- before :each do
- DiviningRod::Mappings.define do |map|
- map.ua /iPhone/, :format => :webkit, :tags => [:iphone, :youtube, :geolocate] do |iphone|
- iphone.ua /iPad/, :tags => [:ipad]
- end
- end
- end
-
- it "should profile an incoming request" do
- header 'User-Agent', "iPhone Safari"
- get "/"
- last_request.env['divining_rod.profile'].should be_an_instance_of(DiviningRod::Profile)
- last_request.env['divining_rod.profile'].iphone?.should be_true
- end
-
-end
12 spec/spec_helper.rb
View
@@ -1,12 +0,0 @@
-require 'rubygems'
-require 'spec'
-require 'rack'
-require File.expand_path('../../lib/divining_rod', __FILE__)
-
-def request_mock(opts)
- opts = {
- :host => 'example.com'
- }.merge(opts)
- env = {'HTTP_USER_AGENT' => opts[:ua], 'SERVER_NAME' => opts[:host], 'X_WAP_PROFILE' => opts[:wap_profile]}
- mock('RailsRequest', :env => env, :format => opts[:format])
-end
Please sign in to comment.
Something went wrong with that request. Please try again.