javy_tool 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JavyTool
2
2
 
3
- Just pack some methods that ofen used to a gem,ex:h2o,truncate etc..
3
+ Just packed some methods that used usually to a gem,ex:h2o,truncate etc..
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- JavyTool.h2o(aHash)
21
+ JavyTool.utils.h2o(aHash)
22
22
 
23
23
  ## Contributing
24
24
 
@@ -8,7 +8,7 @@ module JavyTool
8
8
  protected
9
9
 
10
10
  def set_breadcrumbs
11
- #@breadcrumbs = ["#{I18n.t("common.locate_des")}<a href='/wb/'>#{I18n.t("common.forum_home")}</a>".html_safe]
11
+ @breadcrumbs = ["#{I18n.t("common.index_icon")}<a href='/'>#{I18n.t("common.home")}</a>".html_safe]
12
12
  end
13
13
 
14
14
  def drop_breadcrumb(title=nil, url=nil)
@@ -66,7 +66,7 @@ module JavyTool
66
66
  flash.each do |type, message|
67
67
  type = :success if type == :notice
68
68
  type = :alert if type == :error
69
- text = content_tag(:div, message, :class => "alert-#{type} alert-box")
69
+ text = content_tag(:div, message, :class => "alert-box #{type}")
70
70
  flash_messages << text if message
71
71
  end
72
72
  flash_messages.join("\n").html_safe
@@ -2,6 +2,47 @@ module JavyTool
2
2
  module Utils
3
3
  require "ostruct"
4
4
  module_function
5
+
6
+ #get user agent
7
+ def which_os(req)
8
+ case req
9
+ when /(Android)\s+([\d.]+)/
10
+ "android"
11
+ when /(iPad).*OS\s([\d_]+)|iTunes-iPad/
12
+ "ipad"
13
+ when /(iPhone\sOS)\s([\d_]+)|iTunes-iPhone|iTunes-iPod/
14
+ "iphone"
15
+ when /TouchPad/
16
+ "touchpad"
17
+ when /(webOS|hpwOS)[\s\/]([\d.]+)/
18
+ "webos"
19
+ when /WebKit\/([\d.]+)/
20
+ "webkit"
21
+ end
22
+ end
23
+
24
+ #judge user agent
25
+ def webkit?(req)
26
+ !!(/WebKit\/([\d.]+)/ =~ req)
27
+ end
28
+ def android?(req)
29
+ !!(/(Android)\s+([\d.]+)/ =~ req)
30
+ end
31
+ def ipad?(req)
32
+ !!(/(iPad).*OS\s([\d_]+)/ =~ req)
33
+ end
34
+ def iphone?(req)
35
+ !ipad?(req) && !!(/(iPhone\sOS)\s([\d_]+)|iTunes-iPhone|iTunes-iPod/ =~ req)
36
+ end
37
+ def ios?(req)
38
+ ipad?(req) || iphone?(req)
39
+ end
40
+ def webos?(req)
41
+ !!(/(webOS|hpwOS)[\s\/]([\d.]+)/ =~ req)
42
+ end
43
+ def touchpad?(req)
44
+ webos?(req) && !!(/TouchPad/ =~ req)
45
+ end
5
46
  # translate a Hash object to a OpenStruct object
6
47
  # parameter:
7
48
  # ahash => Hash
@@ -1,3 +1,3 @@
1
1
  module JavyTool
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: javy_tool
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - javy_liu
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-12-20 00:00:00.000000000 Z
17
+
18
+ date: 2014-01-02 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: pack some used methods
15
- email:
22
+ email:
16
23
  - javy_liu@163.com
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - .gitignore
22
32
  - Gemfile
23
33
  - LICENSE.md
@@ -30,27 +40,37 @@ files:
30
40
  - lib/javy_tool/version.rb
31
41
  homepage: https://github.com/javyliu/javy_tool
32
42
  licenses: []
43
+
33
44
  post_install_message:
34
45
  rdoc_options: []
35
- require_paths:
46
+
47
+ require_paths:
36
48
  - lib
37
- required_ruby_version: !ruby/object:Gem::Requirement
49
+ required_ruby_version: !ruby/object:Gem::Requirement
38
50
  none: false
39
- requirements:
40
- - - ! '>='
41
- - !ruby/object:Gem::Version
42
- version: '0'
43
- required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
59
  none: false
45
- requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: '0'
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
49
67
  requirements: []
68
+
50
69
  rubyforge_project:
51
70
  rubygems_version: 1.8.24
52
71
  signing_key:
53
72
  specification_version: 3
54
73
  summary: some methods ofen used in my projects
55
74
  test_files: []
75
+
56
76
  has_rdoc: