cassiopeia 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ PKG_FILES = FileList[ '[a-zA-Z]*', 'lib/**/*' ]
10
10
 
11
11
  spec = Gem::Specification.new do |s|
12
12
  s.name = "cassiopeia"
13
- s.version = "0.1.5"
13
+ s.version = "0.1.6"
14
14
  s.author = "smecsia"
15
15
  s.email = "smecsia@gmail.com"
16
16
  #s.homepage = ""
@@ -75,7 +75,7 @@ module Cassiopeia
75
75
  ticket_hash = ticket_hash.merge({:user => user_hash}) if cas_current_ticket.user
76
76
  logger.debug "\n Rendering ticket: \n"
77
77
  logger.debug ticket_hash.to_json + "\n" + "="*50
78
- simple_rest ticket_hash, {:status => :ok}
78
+ cas_respond ticket_hash, {:status => :ok}
79
79
  end
80
80
 
81
81
  def cas_process_request
@@ -83,7 +83,7 @@ module Cassiopeia
83
83
  cas_respond_current_ticket
84
84
  else
85
85
  @res = {:error => "Ticket not found"}
86
- simple_rest @res, {:status => :error}
86
+ cas_respond @res, {:status => :error}
87
87
  end
88
88
  end
89
89
 
@@ -121,6 +121,15 @@ module Cassiopeia
121
121
  Cassiopeia::CONFIG[:ticketClass].delete_all(:conditions => ["expired_at <= '?'", Time.now.utc])
122
122
  end
123
123
 
124
+ def cas_respond(data, opts)
125
+ status= opts[:status] || :ok
126
+ respond_to do |format|
127
+ format.js { render :json => data.to_json({}),:status=>status}
128
+ format.yaml { render :partial=> 'shared/inspect',:content_type =>'text/html',:locals => { :data => data } ,:status=>status }
129
+ format.xml { render :xml => data.to_xml({}),:status=>status}
130
+ end
131
+ end
132
+
124
133
  public
125
134
 
126
135
  def create
@@ -137,7 +146,7 @@ module Cassiopeia
137
146
 
138
147
  def detroy(params)
139
148
  cas_current_ticket.destroy if cas_current_ticket_exists?
140
- simple_rest nil, {:status => :ok}
149
+ cas_respond nil, {:status => :ok}
141
150
  end
142
151
  end
143
152
  def acts_as_cas_controller
@@ -54,6 +54,8 @@ module Cassiopeia
54
54
  when Net::HTTPSuccess
55
55
  begin
56
56
  return ActiveSupport::JSON.decode(res.body).symbolize_keys if Cassiopeia::CONFIG[:format] == "js"
57
+ return YAML::load(res.body).symbolize_keys if Cassiopeia::CONFIG[:format] == "yaml"
58
+ return Hash.from_xml(res.body).symbolize_keys if Cassiopeia::CONFIG[:format] == "xml"
57
59
  rescue
58
60
  end
59
61
  end
data/lib/cassiopeia.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
  module Cassiopeia
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.6'
5
5
  autoload :User, 'cassiopeia/user'
6
6
  autoload :Base, 'cassiopeia/base'
7
7
  autoload :Exception, 'cassiopeia/base'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassiopeia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - smecsia
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-27 00:00:00 +04:00
12
+ date: 2010-08-16 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency