zedkit 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.5
@@ -39,7 +39,7 @@ module Zedkit
39
39
  def verify(username, password)
40
40
  submit_request(:verify, 'users/verify', nil, {}, { :user => username, :password => password })
41
41
  end
42
- def get(resource, user_key, params = {})
42
+ def get(resource, user_key = nil, params = {})
43
43
  submit_request(:get, resource, user_key, params)
44
44
  end
45
45
 
@@ -23,14 +23,15 @@ module Zedkit
23
23
  set_last_seen if session[:last_seen].nil?
24
24
  return true if session[:last_seen] > (Time.now.to_i - options[:idle_maximum_in_seconds])
25
25
  Rails.logger.info "Session has EXPIRED [#{options[:idle_maximum_in_seconds]}]"
26
+ end_session
26
27
  false
27
28
  end
28
29
  def session_fresh_with_redirect?(options = {})
29
30
  options[:idle_maximum_in_seconds] = 900 unless options.has_key? :idle_maximum_in_seconds
30
31
  options[:url] = new_session_url unless options.has_key? :url
31
32
  return true if session_fresh?(options)
32
- end_session
33
33
  redirect_to options[:url]
34
+ end_session
34
35
  false
35
36
  end
36
37
 
@@ -63,15 +64,19 @@ module Zedkit
63
64
 
64
65
  Rails.logger.info "User Verification Request via Zedkit [#{login.downcase}]"
65
66
  Zedkit::Users.verify(:username => login.downcase, :password => password) do |json|
66
- @user = json
67
- session[:user_json] = @user ## This does not contain the user's password.
68
- cookies[:user_login] = { :value => login.downcase, :expires => 365.days.from_now }
67
+ Rails.logger.info "User VERIFIED [#{json['uuid']}]"
68
+ set_session(json, login.downcase)
69
69
  return true
70
70
  end
71
71
 
72
72
  else set_user_login end
73
73
  false
74
74
  end
75
+ def set_session(json, login)
76
+ @user = json
77
+ session[:user_json] = @user ## This does not contain the user's password.
78
+ cookies[:user_login] = { :value => login.downcase, :expires => 365.days.from_now }
79
+ end
75
80
  def end_session
76
81
  session[:user_json] = nil
77
82
  end
@@ -0,0 +1,38 @@
1
+ ##
2
+ # Copyright (c) Zedkit.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
15
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ module Zedkit
19
+ class EmailSettings
20
+ class << self
21
+ def get(zks = {}, &block)
22
+ Zedkit::Client.crud(:get, "emails/settings/#{zks[:uuid]}", zks, [], &block)
23
+ end
24
+
25
+ def create(zks = {}, &block)
26
+ Zedkit::Client.crud(:create, 'emails/settings', zks, [], &block)
27
+ end
28
+
29
+ def update(zks = {}, &block)
30
+ Zedkit::Client.crud(:update, "emails/settings/#{zks[:uuid]}", zks, [], &block)
31
+ end
32
+
33
+ def delete(zks = {}, &block)
34
+ Zedkit::Client.crud(:delete, "emails/settings/#{zks[:uuid]}", zks, [], &block)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ ##
2
+ # Copyright (c) Zedkit.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
15
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ module Zedkit
19
+ class Emails
20
+ class << self
21
+ def get(zks = {}, &block)
22
+ Zedkit::Client.crud(:get, "emails/#{zks[:uuid]}", zks, [], &block)
23
+ end
24
+
25
+ def create(zks = {}, &block)
26
+ Zedkit::Client.crud(:create, 'emails', zks, [], &block)
27
+ end
28
+
29
+ def update(zks = {}, &block)
30
+ Zedkit::Client.crud(:update, "emails/#{zks[:uuid]}", zks, [], &block)
31
+ end
32
+
33
+ def delete(zks = {}, &block)
34
+ Zedkit::Client.crud(:delete, "emails/#{zks[:uuid]}", zks, [], &block)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -36,12 +36,15 @@ module Zedkit
36
36
  end
37
37
 
38
38
  def create(zks = {}, &block)
39
+ Zedkit::Client.crud(:create, 'projects', zks, [], &block)
39
40
  end
40
41
 
41
42
  def update(zks = {}, &block)
43
+ Zedkit::Client.crud(:update, "projects/#{zks[:uuid]}", zks, [], &block)
42
44
  end
43
45
 
44
46
  def delete(zks = {}, &block)
47
+ Zedkit::Client.crud(:delete, "projects/#{zks[:uuid]}", zks, [], &block)
45
48
  end
46
49
  end
47
50
 
@@ -73,5 +76,12 @@ module Zedkit
73
76
  end
74
77
  end
75
78
  end
79
+ class EmailSettings
80
+ class << self
81
+ def get(zks = {}, &block)
82
+ Zedkit::Client.crud(:get, 'emails/settings', zks, [], &block)
83
+ end
84
+ end
85
+ end
76
86
  end
77
87
  end
@@ -31,6 +31,9 @@ module Zedkit
31
31
  def create(zks = {}, &block)
32
32
  Zedkit::Client.crud(:create, 'users', zks, [], &block)
33
33
  end
34
+
35
+ def update(zks = {}, &block)
36
+ end
34
37
  end
35
38
 
36
39
  class Projects
data/lib/zedkit.rb CHANGED
@@ -23,23 +23,23 @@ require 'zedkit/ext/hash.rb'
23
23
 
24
24
  module Zedkit
25
25
  class << self
26
- def countries(user_key)
27
- rs = Zedkit::Client.get('entities/countries', user_key)
26
+ def countries
27
+ rs = Zedkit::Client.get('entities/countries')
28
28
  if rs && block_given?
29
29
  rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs)
30
30
  end
31
31
  rs
32
32
  end
33
- def regions(user_key, zks = {})
34
- rs = Zedkit::Client.get('entities/regions', user_key, zks)
33
+ def regions(zks = {})
34
+ rs = Zedkit::Client.get('entities/regions', nil, zks)
35
35
  if rs && block_given?
36
36
  rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs)
37
37
  end
38
38
  rs
39
39
  end
40
40
 
41
- def entities(user_key)
42
- rs = Zedkit::Client.get('entities/zedkit', user_key)
41
+ def entities
42
+ rs = Zedkit::Client.get('entities/zedkit')
43
43
  if rs && block_given?
44
44
  rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs)
45
45
  end
@@ -80,5 +80,7 @@ require 'zedkit/instances/project.rb'
80
80
 
81
81
  require 'zedkit/resources/projects.rb'
82
82
  require 'zedkit/resources/users.rb'
83
+ require 'zedkit/resources/emails.rb'
84
+ require 'zedkit/resources/email_settings.rb'
83
85
 
84
86
  require 'zedkit/rails/sessions' if defined?(Rails::Railtie)
@@ -0,0 +1,38 @@
1
+ ##
2
+ # Copyright (c) Zedkit.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6
+ # modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7
+ # Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10
+ # Software.
11
+ #
12
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
15
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ ##
17
+
18
+ require 'helper'
19
+
20
+ class TestEmailSettings < Test::Unit::TestCase
21
+ def test_get
22
+ end
23
+ def test_get_with_block
24
+ end
25
+
26
+ def test_create
27
+ end
28
+ def test_create_with_block
29
+ end
30
+
31
+ def test_update
32
+ end
33
+ def test_update_with_block
34
+ end
35
+
36
+ def test_delete
37
+ end
38
+ end
data/test/test_emails.rb CHANGED
@@ -18,4 +18,21 @@
18
18
  require 'helper'
19
19
 
20
20
  class TestEmails < Test::Unit::TestCase
21
+ def test_get
22
+ end
23
+ def test_get_with_block
24
+ end
25
+
26
+ def test_create
27
+ end
28
+ def test_create_with_block
29
+ end
30
+
31
+ def test_update
32
+ end
33
+ def test_update_with_block
34
+ end
35
+
36
+ def test_delete
37
+ end
21
38
  end
@@ -19,20 +19,26 @@ require 'helper'
19
19
 
20
20
  class TestEntities < Test::Unit::TestCase
21
21
  def test_entities
22
- zkes = Zedkit.entities(@uu['user_key'])
22
+ zkes = Zedkit.entities
23
+ assert_not_nil zkes['languages']
24
+ assert_not_nil zkes['locales']
25
+ assert_not_nil zkes['timezones']
23
26
  end
24
27
  def test_entities_with_block
25
- Zedkit.entities(@uu['user_key']) do |zkes|
28
+ Zedkit.entities do |zkes|
29
+ assert_not_nil zkes['languages']
30
+ assert_not_nil zkes['locales']
31
+ assert_not_nil zkes['timezones']
26
32
  end
27
33
  end
28
34
 
29
35
  def test_countries
30
- cnts = Zedkit.countries(@uu['user_key'])
36
+ cnts = Zedkit.countries
31
37
  assert cnts.is_a? Array
32
38
  assert cnts.length >= 2
33
39
  end
34
40
  def test_countries_with_block
35
- Zedkit.countries(@uu['user_key']) do |cnts|
41
+ Zedkit.countries do |cnts|
36
42
  assert_not_nil cnts['code']
37
43
  assert_not_nil cnts['name']
38
44
  assert_not_nil cnts['locale']
@@ -40,24 +46,24 @@ class TestEntities < Test::Unit::TestCase
40
46
  end
41
47
 
42
48
  def test_regions
43
- rgss = Zedkit.regions(@uu['user_key'])
49
+ rgss = Zedkit.regions
44
50
  assert rgss.is_a? Array
45
51
  assert_not_nil rgss.detect {|region| region['code'] == 'WA' }
46
52
  assert_not_nil rgss.detect {|region| region['code'] == 'BC' }
47
53
  end
48
54
  def test_regions_with_block
49
- Zedkit.regions(@uu['user_key']) do |rgss|
55
+ Zedkit.regions do |rgss|
50
56
  assert_not_nil rgss['code']
51
57
  assert_not_nil rgss['name']
52
58
  end
53
59
  end
54
60
  def test_states_for_usa
55
- rgss = Zedkit.regions(@uu['user_key'], :country => { :code => 'US' })
61
+ rgss = Zedkit.regions(:country => { :code => 'US' })
56
62
  assert rgss.is_a? Array
57
63
  assert_nil rgss.detect {|region| region['code'] == 'BC' }
58
64
  end
59
65
  def test_provinces_for_canada
60
- rgss = Zedkit.regions(@uu['user_key'], :country => { :code => 'CA' })
66
+ rgss = Zedkit.regions(:country => { :code => 'CA' })
61
67
  assert rgss.is_a? Array
62
68
  assert_nil rgss.detect {|region| region['code'] == 'WA' }
63
69
  end
@@ -61,18 +61,36 @@ class TestProjects < Test::Unit::TestCase
61
61
  end
62
62
 
63
63
  def test_create
64
+ pp = Zedkit::Projects.create(:user_key => @uu['user_key'], :project => { :name => "new_project" })
65
+ assert_not_nil pp['location']
66
+ assert_equal 'new_project', pp['name']
64
67
  end
65
68
  def test_create_with_block
69
+ Zedkit::Projects.create(:user_key => @uu['user_key'], :project => { :name => "new_project" }) do |pp|
70
+ assert_not_nil pp['location']
71
+ assert_equal 'new_project', pp['name']
72
+ end
66
73
  end
67
74
 
68
75
  def test_update
76
+ pp = Zedkit::Projects.get(:user_key => @uu['user_key'], :uuid => @uu['projects'][0])
77
+ uu = Zedkit::Projects.update(:user_key => @uu['user_key'], :uuid => pp['uuid'],
78
+ :project => { :location => "new_location" })
79
+ assert_equal 'http://new_location.zedapi.com', uu['location']
80
+ assert_equal pp['uuid'], uu['uuid']
69
81
  end
70
82
  def test_update_with_block
83
+ Zedkit::Projects.get(:user_key => @uu['user_key'], :uuid => @uu['projects'][0]) do |pp|
84
+ Zedkit::Projects.update(:user_key => @uu['user_key'], :uuid => pp['uuid'],
85
+ :project => { :location => "new_location" }) do |uu|
86
+ assert_equal 'http://new_location.zedapi.com', uu['location']
87
+ assert_equal pp['uuid'], uu['uuid']
88
+ end
89
+ end
71
90
  end
72
91
 
73
92
  def test_delete
74
- end
75
- def test_delete_with_block
93
+ assert_nil Zedkit::Projects.delete(:user_key => @uu['user_key'], :uuid => @uu['projects'][0])
76
94
  end
77
95
 
78
96
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 4
9
- version: 1.1.4
8
+ - 5
9
+ version: 1.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Zedkit
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-20 00:00:00 -08:00
17
+ date: 2011-01-06 00:00:00 -08:00
18
18
  default_executable: zedkit
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -74,9 +74,12 @@ files:
74
74
  - lib/zedkit/instances/instance.rb
75
75
  - lib/zedkit/instances/project.rb
76
76
  - lib/zedkit/rails/sessions.rb
77
+ - lib/zedkit/resources/email_settings.rb
78
+ - lib/zedkit/resources/emails.rb
77
79
  - lib/zedkit/resources/projects.rb
78
80
  - lib/zedkit/resources/users.rb
79
81
  - test/helper.rb
82
+ - test/test_email_settings.rb
80
83
  - test/test_emails.rb
81
84
  - test/test_entities.rb
82
85
  - test/test_projects.rb
@@ -115,6 +118,7 @@ specification_version: 3
115
118
  summary: gem for Zedkit
116
119
  test_files:
117
120
  - test/helper.rb
121
+ - test/test_email_settings.rb
118
122
  - test/test_emails.rb
119
123
  - test/test_entities.rb
120
124
  - test/test_projects.rb