LVS-JSONService 0.2.1 → 0.2.2

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.
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LVS-JSONService
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  require_paths:
6
6
  - lib
7
7
  platform: ruby
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{JSONService}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["LVS"]
9
- s.date = %q{2009-06-19}
9
+ s.date = %q{2009-06-24}
10
10
  s.email = %q{info@lvs.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -56,7 +56,7 @@ module LVS
56
56
 
57
57
  def site=(value)
58
58
  # value is containing AGP_LOCATION already sometimes:
59
- value.gsub!(/^#{AGP_LOCATION}/, '') if AGP_LOCATION && value.match(/#{AGP_LOCATION}/)
59
+ value.gsub!(/^#{AGP_LOCATION}/, '') if defined?(AGP_LOCATION) && value.match(/#{AGP_LOCATION}/)
60
60
  agp = @agp_location ? @agp_location : AGP_LOCATION
61
61
  agp.gsub!(/\/$/, '')
62
62
  value.gsub!(/^\//, '')
@@ -111,7 +111,7 @@ module LVS
111
111
  add_service(name)
112
112
  end
113
113
 
114
- def fake_service(name, json)
114
+ def fake_service(name, json, options = {})
115
115
  (class<<self;self;end).send :define_method, name do |*args|
116
116
  self.parse_result(JSON.parse(json))
117
117
  end
@@ -135,16 +135,27 @@ module LVS
135
135
  def initialize(values = {})
136
136
  values.each_pair do |key, value|
137
137
  key = key.underscore
138
- self.class.send(:define_method, key, proc {self.instance_variable_get("@#{key}")})
139
- self.class.send(:define_method, "#{key}=", proc {|value| self.instance_variable_set("@#{key}", value)})
138
+ new_instance_methods = "
139
+ def #{key}
140
+ @#{key}
141
+ end
142
+ def #{key}=(value)
143
+ @#{key} = value
144
+ end
145
+ "
140
146
 
141
147
  # If the key starts with has_ create alias to has_ method removing has
142
148
  # and putting ? at the end
143
149
  if key =~ /^has_/
144
150
  temp_key = "#{key.gsub(/^has_/, '')}?"
145
- self.class.send(:define_method, temp_key, proc {self.instance_variable_get("@#{key}")})
146
- self.class.send(:define_method, "#{temp_key}=", proc {|value| self.instance_variable_set("@#{key}", value)})
147
- end
151
+ new_instance_methods << "
152
+ def #{temp_key}
153
+ @#{key}
154
+ end
155
+ "
156
+ end
157
+
158
+ self.instance_eval(new_instance_methods)
148
159
 
149
160
  if value.is_a?(Hash)
150
161
  self.instance_variable_set("@#{key}", self.class.new(value))
@@ -1,9 +1,12 @@
1
+ require 'pp'
1
2
  module LVS
2
3
  module JsonService
3
4
  module Logger
4
5
  def self.debug(message)
5
- message = " \033[1;4;32mLVS::JsonService\033[0m #{message}"
6
- Rails.logger.debug(message)
6
+ if defined?(Rails) && Rails.logger
7
+ message = " \033[1;4;32mLVS::JsonService\033[0m #{message}"
8
+ Rails.logger.debug(message)
9
+ end
7
10
  end
8
11
  end
9
12
  end
@@ -1,28 +1,42 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
+
3
4
  describe LVS::JsonService::Logger do
4
5
  before :each do
5
6
  end
6
7
 
7
8
  describe "debug" do
8
- describe "with RAILS_DEFAULT_LOGGER set" do
9
+ describe "with Rails.logger set" do
9
10
  before :each do
10
11
  @mock_logger = mock()
11
- LVS::JsonService::Logger.const_set(:RAILS_DEFAULT_LOGGER, @mock_logger)
12
+
13
+ if !defined?(Rails)
14
+ class Rails
15
+ class << self
16
+ def logger=(value)
17
+ @logger = value
18
+ end
19
+ def logger
20
+ @logger
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ Rails.logger = @mock_logger
12
27
  end
13
28
 
14
- it "should pass the message to RAILS_DEFAULT_LOGGER" do
29
+ it "should pass the message to Rails.logger" do
15
30
  message = "Some debug message"
16
- @mock_logger.should_receive(:debug).with(message)
31
+ coloured_message = " \033[1;4;32mLVS::JsonService\033[0m #{message}"
32
+ @mock_logger.should_receive(:debug).with(coloured_message)
17
33
  LVS::JsonService::Logger.debug(message)
18
34
  end
19
35
  end
20
36
 
21
- describe "without RAILS_ROOT set" do
37
+ describe "without Rails defined" do
22
38
  before :each do
23
- LVS::JsonService::Logger.module_eval do
24
- remove_const(:RAILS_DEFAULT_LOGGER) if const_defined?(:RAILS_DEFAULT_LOGGER)
25
- end
39
+ Object.send(:remove_const, :Rails)
26
40
  end
27
41
 
28
42
  it "should not raise an exception" do
@@ -250,5 +250,9 @@ end
250
250
 
251
251
  class ClassWithRequest
252
252
  include LVS::JsonService::Request
253
+
254
+ def self.require_ssl?
255
+ false
256
+ end
253
257
  end
254
258
 
@@ -1,8 +1,6 @@
1
1
  require 'spec'
2
-
3
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
- require 'rubygems'
6
4
  require 'json_service'
7
5
 
8
6
  Spec::Runner.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LVS-JSONService
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LVS
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-19 00:00:00 -07:00
12
+ date: 2009-06-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15