aua-mite 0.0.1

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
+ pkg/*
2
+ *.gem
3
+ .bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2@aua-mite
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ ### dev
2
+
3
+ [full changelog](http://github.com/yolk/aua-mite/compare/v0.0.1...master)
4
+
5
+ ### 0.0.1 / 2011-01-27
6
+
7
+ * Initial version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in aua.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aua-mite (0.0.1)
5
+ aua (>= 0.1.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ aua (0.1.0)
11
+ configuration (1.2.0)
12
+ diff-lcs (1.1.2)
13
+ growl (1.0.3)
14
+ guard (0.3.0)
15
+ open_gem (~> 1.4.2)
16
+ thor (~> 0.14.6)
17
+ guard-rspec (0.1.9)
18
+ guard (>= 0.2.2)
19
+ launchy (0.3.7)
20
+ configuration (>= 0.0.5)
21
+ rake (>= 0.8.1)
22
+ open_gem (1.4.2)
23
+ launchy (~> 0.3.5)
24
+ rake (0.8.7)
25
+ rb-fsevent (0.3.9)
26
+ rspec (2.4.0)
27
+ rspec-core (~> 2.4.0)
28
+ rspec-expectations (~> 2.4.0)
29
+ rspec-mocks (~> 2.4.0)
30
+ rspec-core (2.4.0)
31
+ rspec-expectations (2.4.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.4.0)
34
+ thor (0.14.6)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ aua (>= 0.1.0)
41
+ aua-mite!
42
+ growl (>= 1.0.3)
43
+ guard-rspec (>= 0.1.9)
44
+ rb-fsevent (>= 0.3.9)
45
+ rspec (>= 2.4.0)
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(/^spec\/(.*)_spec\.rb/) { "spec" }
3
+ watch(/^lib\/(.*)\.rb/) { "spec" } # { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch(/^spec\/spec_helper\.rb/) { "spec" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Yolk Sebastian Munz & Julia Soergel GbR
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.md ADDED
@@ -0,0 +1,19 @@
1
+ aua-mite
2
+ =============
3
+
4
+ Extension for [aua](https://github.com/yolk/aua) to recognize custom mite api clients by there user agent string.
5
+
6
+ Not very useful for anyone outside of mite/yolk. But maybe handy as a example of extending aua.
7
+
8
+ Installation
9
+ -------
10
+
11
+ gem install aua-mite
12
+
13
+
14
+ BlaBla
15
+ -------
16
+
17
+ Copyright (c) 2011 Yolk Sebastian Munz & Julia Soergel GbR
18
+
19
+ Beyond that, the implementation is licensed under the MIT License.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
data/aua-mite.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "aua-mite/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "aua-mite"
7
+ s.version = AuaMite::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Sebastian Munz"]
10
+ s.email = ["sebastian@yo.lk"]
11
+ s.homepage = "https://github.com/yolk/aua-mite"
12
+ s.summary = %q{Extension for aua to recognize custom mite api clients by there user agent string.}
13
+ s.description = %q{Extension for aua (https://github.com/yolk/aua) to recognize custom mite api clients by there user agent string. Not very useful for anyone outside of mite/yolk. But maybe handy as a example of extending aua.}
14
+
15
+ s.rubyforge_project = "aua-mite"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'aua', '>= 0.1.0'
23
+
24
+ s.add_development_dependency 'rspec', '>= 2.4.0'
25
+ s.add_development_dependency 'guard-rspec', '>=0.1.9'
26
+ s.add_development_dependency 'growl', '>=1.0.3'
27
+ s.add_development_dependency 'rb-fsevent', '>=0.3.9'
28
+ end
@@ -0,0 +1,20 @@
1
+ module Aua::Agents::AllMite
2
+
3
+ PATTERN = /^All\.mite\-v([\d\.]+)/
4
+
5
+ def self.extend?(agent)
6
+ agent.app =~ PATTERN
7
+ end
8
+
9
+ def type
10
+ :ApiClient
11
+ end
12
+
13
+ def name
14
+ @name ||= :"All.mite"
15
+ end
16
+
17
+ def version
18
+ @version ||= app =~ PATTERN && $1
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Aua::Agents::Fuerst
2
+
3
+ def self.extend?(agent)
4
+ agent.app == "DynaMite" || agent.app == "GrandTotal" ||
5
+ agent.app =~ /^DynaMite/ || agent.app =~ /^GrandTotal/
6
+ end
7
+
8
+ def type
9
+ :ApiClient
10
+ end
11
+
12
+ def name
13
+ @name ||= app =~ /^GrandTotal/ ? :GrandTotal : :DynaMite
14
+ end
15
+
16
+ def version
17
+ @version ||= begin
18
+ return versions.first if app == "DynaMite" || app == "GrandTotal"
19
+ app.sub(/^DynaMite|GrandTotal/, "")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ module Aua::Agents::MiteGo
2
+
3
+ def self.extend?(agent)
4
+ agent.app == "mite.go" &&
5
+ ((agent.products.index("Darwin") && agent.products[agent.products.index("Darwin")] = "NoDarwin") || true)
6
+ end
7
+
8
+ def type
9
+ :ApiClient
10
+ end
11
+
12
+ def name
13
+ @name ||= :"mite.go"
14
+ end
15
+
16
+ def platform
17
+ @platform ||= begin
18
+ if app_comments.first =~ /^iPod/
19
+ :iPod
20
+ else
21
+ :iPhone
22
+ end
23
+ end
24
+ end
25
+
26
+ def os_version
27
+ @os_version ||= begin
28
+ if app_comments[1] =~ /iPhone OS ([\d\.]+)/
29
+ $1
30
+ end
31
+ end
32
+ end
33
+
34
+ def os_name
35
+ :iOS
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ module Aua::Agents::StandardMiteClient
2
+
3
+ KNOWN_CLIENTS = %w(mite.php mite.desk mite-rb jmite Redmine2mite Mantis2mite Billomat hearttp centralstationcrm)
4
+
5
+ def self.extend?(agent)
6
+ KNOWN_CLIENTS.include?(agent.app)
7
+ end
8
+
9
+ def type
10
+ return :HttpChecker if app == "hearttp"
11
+ :ApiClient
12
+ end
13
+
14
+ def name
15
+ @name ||= app.to_sym
16
+ end
17
+
18
+ def version
19
+ super
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ Dir["#{File.dirname(__FILE__)}/agents/*.rb"].each do |agent|
2
+ require(agent)
3
+ end
4
+
5
+ Aua::Agents.default << Aua::Agents::Fuerst << Aua::Agents::MiteGo <<
6
+ Aua::Agents::StandardMiteClient << Aua::Agents::AllMite
@@ -0,0 +1,3 @@
1
+ module AuaMite
2
+ VERSION = '0.0.1'
3
+ end
data/lib/aua-mite.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'aua'
2
+ require 'aua-mite/version'
3
+ require 'aua-mite/agents'
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe AuaMite do
4
+
5
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'aua/extensions/mite'
3
+
4
+ describe "Mite Extension" do
5
+
6
+ EXAMPLES_MITE = {
7
+ # DynaMite
8
+ "DynaMite/2.0.2 CFNetwork/454.11.5 Darwin/10.6.0 (i386) (MacBookPro4%2C1)" =>
9
+ { :type => :ApiClient, :name => :DynaMite, :version => "2.0.2", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
10
+ "DynaMite/2.0b5 CFNetwork/454.11.5 Darwin/10.6.0 (i386) (iMac10%2C1)" =>
11
+ { :type => :ApiClient, :name => :DynaMite, :version => "2.0b5", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
12
+ "DynaMite2.0.3 CFNetwork/438.14 Darwin/9.8.0 (i386) (iMac7%2C1)" =>
13
+ { :type => :ApiClient, :name => :DynaMite, :version => "2.0.3", :os_name => :MacOSX, :os_version => "10.5.8", :platform => :Macintosh },
14
+
15
+ # Billomat
16
+ "Billomat" =>
17
+ { :type => :ApiClient, :name => :Billomat, :version => nil, :os_name => nil, :os_version => nil, :platform => nil },
18
+
19
+ # All.mite
20
+ "All.mite-v1.4.0.0" =>
21
+ { :type => :ApiClient, :name => :"All.mite", :version => "1.4.0.0", :os_name => nil, :os_version => nil, :platform => nil },
22
+
23
+ # Standard mite clients
24
+ "mite.php/v1.2" =>
25
+ { :type => :ApiClient, :name => :"mite.php", :version => "v1.2", :os_name => nil, :os_version => nil, :platform => nil },
26
+ "mite.desk/1.2.14" =>
27
+ { :type => :ApiClient, :name => :"mite.desk", :version => "1.2.14", :os_name => nil, :os_version => nil, :platform => nil },
28
+ "mite-rb/0.3.0" =>
29
+ { :type => :ApiClient, :name => :"mite-rb", :version => "0.3.0", :os_name => nil, :os_version => nil, :platform => nil },
30
+ "jmite/0.1" =>
31
+ { :type => :ApiClient, :name => :"jmite", :version => "0.1", :os_name => nil, :os_version => nil, :platform => nil },
32
+ "Redmine2mite/v1.2.1" =>
33
+ { :type => :ApiClient, :name => :"Redmine2mite", :version => "v1.2.1", :os_name => nil, :os_version => nil, :platform => nil },
34
+ "Mantis2mite/v1.2.4" =>
35
+ { :type => :ApiClient, :name => :"Mantis2mite", :version => "v1.2.4", :os_name => nil, :os_version => nil, :platform => nil },
36
+ "GrandTotal/1.6.5b2 CFNetwork/454.11.5 Darwin/10.6.0 (i386) (iMac11%2C1)" =>
37
+ { :type => :ApiClient, :name => :GrandTotal, :version => "1.6.5b2", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
38
+ "GrandTotal1.6.4 CFNetwork/438.16 Darwin/9.8.0 (i386) (MacBook5%2C2)" =>
39
+ { :type => :ApiClient, :name => :GrandTotal, :version => "1.6.4", :os_name => :MacOSX, :os_version => "10.5.8", :platform => :Macintosh },
40
+ "centralstationcrm" =>
41
+ { :type => :ApiClient, :name => :centralstationcrm, :version => nil, :os_name => nil, :os_version => nil, :platform => nil },
42
+
43
+ # mite.go
44
+ "mite.go/1.0 CFNetwork/459 Darwin/10.0.0d3" =>
45
+ { :type => :ApiClient, :name => :"mite.go", :version => "1.0", :os_name => :iOS, :os_version => nil, :platform => :iPhone },
46
+ "mite.go/1.1 (iPhone1,2; iPhone OS 4.2.1; de)" =>
47
+ { :type => :ApiClient, :name => :"mite.go", :version => "1.1", :os_name => :iOS, :os_version => "4.2.1", :platform => :iPhone },
48
+
49
+ # hearttp
50
+ "hearttp/0.0.1" =>
51
+ { :type => :HttpChecker, :name => :"hearttp", :version => "0.0.1", :os_name => nil, :os_version => nil, :platform => nil}
52
+ }
53
+
54
+ EXAMPLES_MITE.each do |string, values|
55
+ context "when parsing #{string.inspect}" do
56
+ let(:user_agent) { Aua.parse(string) }
57
+ values.each do |key, value|
58
+ it "should return #{value} for #{key}" do
59
+ user_agent.send(key).should eql(value)
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ end
66
+
@@ -0,0 +1,3 @@
1
+ require 'rspec'
2
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../../aua/lib/')
3
+ require File.dirname(__FILE__) + '/../lib/aua-mite.rb'
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aua-mite
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Sebastian Munz
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-27 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: aua
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 1
31
+ - 0
32
+ version: 0.1.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 4
46
+ - 0
47
+ version: 2.4.0
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: guard-rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 1
61
+ - 9
62
+ version: 0.1.9
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: growl
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 3
77
+ version: 1.0.3
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: rb-fsevent
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ - 3
91
+ - 9
92
+ version: 0.3.9
93
+ type: :development
94
+ version_requirements: *id005
95
+ description: Extension for aua (https://github.com/yolk/aua) to recognize custom mite api clients by there user agent string. Not very useful for anyone outside of mite/yolk. But maybe handy as a example of extending aua.
96
+ email:
97
+ - sebastian@yo.lk
98
+ executables: []
99
+
100
+ extensions: []
101
+
102
+ extra_rdoc_files: []
103
+
104
+ files:
105
+ - .gitignore
106
+ - .rvmrc
107
+ - CHANGES.md
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - Guardfile
111
+ - LICENSE
112
+ - README.md
113
+ - Rakefile
114
+ - aua-mite.gemspec
115
+ - lib/aua-mite.rb
116
+ - lib/aua-mite/agents.rb
117
+ - lib/aua-mite/agents/all_mite.rb
118
+ - lib/aua-mite/agents/fuerst.rb
119
+ - lib/aua-mite/agents/mite_go.rb
120
+ - lib/aua-mite/agents/standard_mite_client.rb
121
+ - lib/aua-mite/version.rb
122
+ - spec/aua-mite_spec.rb
123
+ - spec/aua_mite_spec.rb
124
+ - spec/spec_helper.rb
125
+ has_rdoc: true
126
+ homepage: https://github.com/yolk/aua-mite
127
+ licenses: []
128
+
129
+ post_install_message:
130
+ rdoc_options: []
131
+
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ segments:
140
+ - 0
141
+ version: "0"
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ requirements: []
151
+
152
+ rubyforge_project: aua-mite
153
+ rubygems_version: 1.3.7
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: Extension for aua to recognize custom mite api clients by there user agent string.
157
+ test_files:
158
+ - spec/aua-mite_spec.rb
159
+ - spec/aua_mite_spec.rb
160
+ - spec/spec_helper.rb