mite-rb 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -30,6 +30,16 @@ or
30
30
 
31
31
  Mite.authenticate('rick@techno-weenie.net', 'spacemonkey')
32
32
 
33
+ ### User-Agent
34
+
35
+ mite-rb sets the User-Agent HTTP-header to 'mite-rb/0.2.5' by default. You can (and should) customize it to a more specific one:
36
+
37
+ Mite.user_agent = 'my-funky-mite-addon/1.2.3'
38
+
39
+ You can combine your custom string with the default one:
40
+
41
+ Mite.user_agent = "my-funky-mite-addon/1.2.3;#{Mite.user_agent}"
42
+
33
43
  ### Validate connection
34
44
 
35
45
  You can validate the connection/authentication with
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :build:
3
- :patch: 4
2
+ :patch: 0
4
3
  :major: 0
5
- :minor: 2
4
+ :build:
5
+ :minor: 3
data/lib/mite-rb.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_support'
2
2
  require 'active_resource'
3
+ require 'yaml'
3
4
 
4
5
  # The official ruby library for interacting with the RESTful API of mite,
5
6
  # a sleek time tracking webapp.
@@ -7,7 +8,7 @@ require 'active_resource'
7
8
  module Mite
8
9
 
9
10
  class << self
10
- attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port
11
+ attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port, :user_agent
11
12
  attr_reader :account, :key
12
13
 
13
14
  # Sets the account name, and updates all resources with the new domain.
@@ -36,6 +37,14 @@ module Mite
36
37
  end
37
38
  @key = value
38
39
  end
40
+
41
+ # Sets the mite.user_agent for all resources.
42
+ def user_agent=(user_agent)
43
+ resources.each do |klass|
44
+ klass.headers['User-Agent'] = user_agent
45
+ end
46
+ @user_agent = user_agent
47
+ end
39
48
 
40
49
  def resources
41
50
  @resources ||= []
@@ -52,12 +61,22 @@ module Mite
52
61
  def validate!
53
62
  !!Mite::Account.find
54
63
  end
64
+
65
+ def version
66
+ @version ||= begin
67
+ config = YAML.load(File.read(File.join(File.dirname(__FILE__), "..", "VERSION.yml")))
68
+ "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
69
+ rescue
70
+ "0.0.0"
71
+ end
72
+ end
55
73
  end
56
74
 
57
75
  self.host_format = '%s://%s%s'
58
76
  self.domain_format = '%s.mite.yo.lk'
59
77
  self.protocol = 'http'
60
78
  self.port = ''
79
+ self.user_agent = "mite-rb/#{Mite.version}"
61
80
 
62
81
  class MethodNotAvaible < StandardError; end
63
82
 
@@ -100,6 +119,7 @@ module Mite
100
119
  class << base
101
120
  attr_accessor :site_format
102
121
  end
122
+ base.headers['User-Agent'] = Mite.user_agent
103
123
  base.site_format = '%s'
104
124
  base.timeout = 20
105
125
  end
data/mite-rb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mite-rb}
8
- s.version = "0.2.4"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sebastian Munz"]
12
- s.date = %q{2010-01-13}
12
+ s.date = %q{2010-05-31}
13
13
  s.description = %q{The official ruby library for interacting with the RESTful mite.api.}
14
14
  s.email = %q{sebastian@yo.lk}
15
15
  s.extra_rdoc_files = [
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
  s.homepage = %q{http://github.com/yolk/mite-rb}
40
40
  s.rdoc_options = ["--charset=UTF-8"]
41
41
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.3.5}
42
+ s.rubygems_version = %q{1.3.6}
43
43
  s.summary = %q{The official ruby library for interacting with the RESTful API of mite, a sleek time tracking webapp.}
44
44
 
45
45
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mite-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Sebastian Munz
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-13 00:00:00 +01:00
17
+ date: 2010-05-31 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 2
23
31
  version: 2.3.2
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: activeresource
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 2
33
45
  version: 2.3.2
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description: The official ruby library for interacting with the RESTful mite.api.
36
49
  email: sebastian@yo.lk
37
50
  executables: []
@@ -73,18 +86,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ">="
75
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
76
91
  version: "0"
77
- version:
78
92
  required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
82
98
  version: "0"
83
- version:
84
99
  requirements: []
85
100
 
86
101
  rubyforge_project:
87
- rubygems_version: 1.3.5
102
+ rubygems_version: 1.3.6
88
103
  signing_key:
89
104
  specification_version: 3
90
105
  summary: The official ruby library for interacting with the RESTful API of mite, a sleek time tracking webapp.