contentfree-is_it_mobile 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Dave Myron
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,45 @@
1
+ = is_it_mobile
2
+ * http://rubyforge.org/projects/contentfree/
3
+
4
+ == DESCRIPTION:
5
+
6
+ Simply determines if a user agent is for a mobile device.
7
+
8
+ Comes ready with a module for Rails 2.0 to enable multiviews (respond_to with a custom mimetype) for mobile devices (see Synopsis).
9
+
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * Fast & Lightweight (doesn't use anything like WURFL, which would be overkill for a quick check)
14
+
15
+
16
+ == SYNOPSIS:
17
+
18
+ The lightweight tests used in IsItMobile are almost completely based on the work of Andy Moore in an
19
+ article at http://www.andymoore.info/php-to-detect-mobile-phones/. I added a couple more
20
+ user agents to the mix and obviously Rubified it.
21
+
22
+ It recognizes 99% of the mobile user agents from http://www.zytrax.com/tech/web/mobile_ids.html
23
+ It has nearly no false positives using the user agents from http://www.zytrax.com/tech/web/browser_ids.htm
24
+ The ones that don't quite pass are very rare (and some are even questionable appearing in their respective lists)
25
+
26
+
27
+ == INSTALL:
28
+
29
+ sudo gem install contentfree-is_it_mobile --source http://gems.github.com
30
+
31
+
32
+ == USAGE:
33
+
34
+ With Rails 2.0, simply add this to config/environment.rb:
35
+ config.gem 'contentfree-is_it_mobile', :lib => 'is_it_mobile/rails', :source => "http://gems.github.com"
36
+
37
+ Then, just create your views using suffixes of mobile.erb instead of html.erb
38
+
39
+ You can also just use IsItMobile directly:
40
+ IsItMobile.mobile?( 'NokiaN90-1/3.0545.5.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1' ) # => true
41
+
42
+
43
+ == REQUIREMENTS:
44
+
45
+ If using Rails, version must be >= 2.0 for multiview capability
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |s|
6
+ s.name = "is_it_mobile"
7
+ s.summary = %Q{TODO}
8
+ s.email = "dave.myron@contentfree.com"
9
+ s.homepage = "http://github.com/contentfree/is_it_mobile"
10
+ s.description = "TODO"
11
+ s.authors = ["Dave Myron"]
12
+ end
13
+ rescue LoadError
14
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
15
+ end
16
+
17
+ require 'rake/rdoctask'
18
+ Rake::RDocTask.new do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = 'is_it_mobile'
21
+ rdoc.options << '--line-numbers' << '--inline-source'
22
+ rdoc.rdoc_files.include('README*')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ require 'spec/rake/spectask'
27
+ Spec::Rake::SpecTask.new(:spec) do |t|
28
+ t.libs << 'lib' << 'spec'
29
+ t.spec_files = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+ Spec::Rake::SpecTask.new(:rcov) do |t|
33
+ t.libs << 'lib' << 'spec'
34
+ t.spec_files = FileList['spec/**/*_spec.rb']
35
+ t.rcov = true
36
+ end
37
+
38
+ begin
39
+ require 'cucumber/rake/task'
40
+ Cucumber::Rake::Task.new(:features)
41
+ rescue LoadError
42
+ puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
43
+ end
44
+
45
+ task :default => :spec
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 1
4
2
  :major: 1
3
+ :minor: 2
4
+ :patch: 0
@@ -0,0 +1,9 @@
1
+ Feature: something something
2
+ In order to something something
3
+ A user something something
4
+ something something something
5
+
6
+ Scenario: something something
7
+ Given inspiration
8
+ When I create a sweet new gem
9
+ Then everyone should see how awesome I am
File without changes
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'is_it_mobile'
3
+
4
+ require 'spec/expectations'
5
+
6
+ require 'test/unit/assertions'
7
+
8
+ World do |world|
9
+
10
+ world
11
+ end
@@ -0,0 +1,50 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{is_it_mobile}
5
+ s.version = "1.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Dave Myron"]
9
+ s.date = %q{2009-07-06}
10
+ s.description = %q{TODO}
11
+ s.email = %q{dave.myron@contentfree.com}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README"
15
+ ]
16
+ s.files = [
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README",
20
+ "Rakefile",
21
+ "VERSION.yml",
22
+ "features/is_it_mobile.feature",
23
+ "features/steps/is_it_mobile_steps.rb",
24
+ "features/support/env.rb",
25
+ "is_it_mobile.gemspec",
26
+ "lib/is_it_mobile.rb",
27
+ "lib/rails/init.rb",
28
+ "spec/is_it_mobile_spec.rb",
29
+ "spec/spec_helper.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/contentfree/is_it_mobile}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.3}
35
+ s.summary = %q{TODO}
36
+ s.test_files = [
37
+ "spec/is_it_mobile_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
+ else
47
+ end
48
+ else
49
+ end
50
+ end
data/lib/is_it_mobile.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class IsItMobile
2
- POPULAR_MOBILE_USER_AGENT_BEGINNINGS = %w(
2
+ POPULAR_MOBILE_USER_AGENT_PIECES = /(#{%w(
3
3
  w3c acs- alav alca amoi audi avan benq bird blac blaz
4
4
  brew cell cldc cmd- dang doco eric hipt inno ipaq java
5
5
  jigs kddi keji leno lg-c lg-d lg-g lge- maui maxo midp
@@ -7,8 +7,8 @@ class IsItMobile
7
7
  pana pant phil play port prox qwap sage sams sany sch-
8
8
  sec- send seri sgh- shar sie- siem smal smar sony sph-
9
9
  symb t-mo teli tim- tosh tsm- upg1 upsi vk-v voda wap-
10
- wapa wapi wapp wapr webc winw winw xda xda-
11
- )
10
+ wapa wapi wapp wapr webc webo winw winw xda xda-
11
+ ).join('|')})/i
12
12
 
13
13
  POPULAR_MOBILE_USER_AGENT_REGEX = /(mobile|up.browser|up.link|mmp|symbian|phone|midp|wap|mini|ppc;|playstation|palm|wii|nitro)/i
14
14
 
@@ -16,7 +16,7 @@ class IsItMobile
16
16
  def self.mobile?( user_agent, accepts = '' )
17
17
  !!( user_agent =~ POPULAR_MOBILE_USER_AGENT_REGEX ||
18
18
  accepts.index('application/vnd.wap.xhtml+xml') ||
19
- POPULAR_MOBILE_USER_AGENT_BEGINNINGS.include?(user_agent[0,4]))
19
+ user_agent =~ POPULAR_MOBILE_USER_AGENT_PIECES )
20
20
  end
21
21
 
22
22
  # Some checks for some specific, popular mobile devices
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentfree-is_it_mobile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Myron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-04 00:00:00 -07:00
12
+ date: 2009-07-06 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -19,20 +19,27 @@ executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files: []
23
-
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README
24
25
  files:
26
+ - .gitignore
27
+ - LICENSE
28
+ - README
29
+ - Rakefile
25
30
  - VERSION.yml
26
- - lib/is_it_mobile
27
- - lib/is_it_mobile/rails.rb
31
+ - features/is_it_mobile.feature
32
+ - features/steps/is_it_mobile_steps.rb
33
+ - features/support/env.rb
34
+ - is_it_mobile.gemspec
28
35
  - lib/is_it_mobile.rb
36
+ - lib/rails/init.rb
29
37
  - spec/is_it_mobile_spec.rb
30
38
  - spec/spec_helper.rb
31
- has_rdoc: true
39
+ has_rdoc: false
32
40
  homepage: http://github.com/contentfree/is_it_mobile
33
41
  post_install_message:
34
42
  rdoc_options:
35
- - --inline-source
36
43
  - --charset=UTF-8
37
44
  require_paths:
38
45
  - lib
@@ -53,7 +60,8 @@ requirements: []
53
60
  rubyforge_project:
54
61
  rubygems_version: 1.2.0
55
62
  signing_key:
56
- specification_version: 2
63
+ specification_version: 3
57
64
  summary: TODO
58
- test_files: []
59
-
65
+ test_files:
66
+ - spec/is_it_mobile_spec.rb
67
+ - spec/spec_helper.rb