appoxy_rails 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/api/client.rb CHANGED
@@ -7,7 +7,7 @@ module Appoxy
7
7
  # host: endpoint url for service
8
8
  class Client
9
9
 
10
- attr_accessor :host, :access_key, :secret_key
10
+ attr_accessor :host, :access_key, :secret_key, :version
11
11
 
12
12
 
13
13
  def initialize(host, access_key, secret_key, options={})
@@ -66,25 +66,21 @@ module Appoxy
66
66
  end
67
67
 
68
68
 
69
- # old way
70
- def add_params(command_path, hash)
69
+ def add_params(command_path, hash)
70
+ v = version||"0.1"
71
71
  ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
72
72
  # puts 'timestamp = ' + ts
73
- sig = Appoxy::Api::Signatures.generate_signature(command_path, ts, secret_key)
73
+ sig = case v
74
+ when "0.2"
75
+ Appoxy::Api::Signatures.generate_signature(command_path + Appoxy::Api::Signatures.hash_to_s(hash), ts, secret_key)
76
+ when "0.1"
77
+ Appoxy::Api::Signatures.generate_signature(command_path, ts, secret_key)
78
+ end
74
79
 
75
- extra_params = {'sigv'=>"0.1", 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
80
+ extra_params = {'sigv'=>v, 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
76
81
  hash.merge!(extra_params)
77
82
 
78
- end
79
-
80
- # def add_params(command_path, hash)
81
- # ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
82
- # #p "hash_to s" + command_path + Appoxy::Api::Signatures.hash_to_s(hash)
83
- # sig = Appoxy::Api::Signatures.generate_signature(command_path + Appoxy::Api::Signatures.hash_to_s(hash), ts, secret_key)
84
- # extra_params = {'sigv'=>"0.2", 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
85
- # hash.merge!(extra_params)
86
- #
87
- # end
83
+ end
88
84
 
89
85
 
90
86
  def append_params(host, params)
@@ -16,8 +16,8 @@ module Appoxy
16
16
 
17
17
 
18
18
  def self.hash_to_s(hash)
19
- str = ""
20
- hash.each_pair {|key, value| str+= "#{key}#{value}" }
19
+ str = ""
20
+ hash.sort.each{|a| str+= "#{a[0]}#{a[1]}" }
21
21
  #removing all characters that could differ after parsing with rails
22
22
  return str.delete "\"\/:{}[]\' T"
23
23
  end
data/lib/ui/time_zoner.rb CHANGED
@@ -1,47 +1,47 @@
1
- # adds a to_pst method to Time
2
- module TimePluginizer # ActiveSupport::CoreExtensions::Time::Conversions
3
-
4
- def self.included(base) #:nodoc:
5
- base.class_eval do
6
- #puts 'TP mixing'
7
- # If we want to_s to ALWAYS be local, uncomment the below line
8
- #alias_method :to_s, :to_local_s #
9
- end
10
- end
11
-
12
- def to_pst
13
- return in_time_zone('Pacific Time (US & Canada)')
14
- end
15
-
16
- def to_user_time(user = nil)
17
- local = nil
18
- if user && user.time_zone
19
- local = in_time_zone(user.time_zone)
20
- else
21
- local = to_pst
22
- end
23
- local
24
- end
25
-
26
- def to_local_s(format = :default, user = nil)
27
- #puts 'calling to_local_s on ' + self.class.name
28
- zone = to_user_time(user)
29
- return zone.to_formatted_s(format)
30
- end
31
-
32
- end
33
-
34
- module StringTimezoner
35
- def to_user_time(user)
36
- tz = ActiveSupport::TimeZone.new(user.time_zone || 'Pacific Time (US & Canada)')
37
- # puts 'tz=' + tz.inspect
38
- t = tz.parse(self)
39
- return t
40
- end
41
- end
42
-
43
- Time.send :include, TimePluginizer
44
- DateTime.send :include, TimePluginizer
45
- #Date.send :include, TimePluginizer
46
-
47
- String.send :include, StringTimezoner
1
+ # adds a to_pst method to Time
2
+ module TimePluginizer # ActiveSupport::CoreExtensions::Time::Conversions
3
+
4
+ def self.included(base) #:nodoc:
5
+ base.class_eval do
6
+ #puts 'TP mixing'
7
+ # If we want to_s to ALWAYS be local, uncomment the below line
8
+ #alias_method :to_s, :to_local_s #
9
+ end
10
+ end
11
+
12
+ def to_pst
13
+ return in_time_zone('Pacific Time (US & Canada)')
14
+ end
15
+
16
+ def to_user_time(user = nil)
17
+ local = nil
18
+ if user && user.time_zone
19
+ local = in_time_zone(user.time_zone)
20
+ else
21
+ local = to_pst
22
+ end
23
+ local
24
+ end
25
+
26
+ def to_local_s(format = :default, user = nil)
27
+ #puts 'calling to_local_s on ' + self.class.name
28
+ zone = to_user_time(user)
29
+ return zone.to_formatted_s(format)
30
+ end
31
+
32
+ end
33
+
34
+ module StringTimezoner
35
+ def to_user_time(user)
36
+ tz = ActiveSupport::TimeZone.new(user.time_zone || 'Pacific Time (US & Canada)')
37
+ # puts 'tz=' + tz.inspect
38
+ t = tz.parse(self)
39
+ return t
40
+ end
41
+ end
42
+
43
+ Time.send :include, TimePluginizer
44
+ DateTime.send :include, TimePluginizer
45
+ #Date.send :include, TimePluginizer
46
+
47
+ String.send :include, StringTimezoner
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-29 00:00:00 -08:00
17
+ date: 2011-01-15 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency