url 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,48 +1,14 @@
1
- require 'rubygems'
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake'
3
- include Rake::DSL
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "url"
9
- gem.summary = %Q{A URL object}
10
- gem.description = %Q{A simple url object to allow for OO based manipulation and usage of a url}
11
- gem.email = "me@tal.by"
12
- gem.homepage = "http://github.com/talby/url"
13
- gem.authors = ["Tal Atlas"]
14
- gem.add_development_dependency "rspec", "~> 2.0"
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'rspec/core/rake_task'
22
- RSpec::Core::RakeTask.new do |t|
23
- t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
24
- t.pattern = 'spec/**/*_spec.rb'
25
- end
26
-
27
- task :spec => :check_dependencies
28
-
29
- task :default => :spec
30
-
31
- require 'rake/rdoctask'
32
- Rake::RDocTask.new do |rdoc|
33
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
34
-
35
- rdoc.rdoc_dir = 'rdoc'
36
- rdoc.title = "url #{version}"
37
- rdoc.rdoc_files.include('README*')
38
- rdoc.rdoc_files.include('lib/**/*.rb')
3
+ if !defined?(sh) && defined?(Rake::DSL)
4
+ include Rake::DSL
39
5
  end
40
6
 
41
7
  begin
42
8
  require 'yard'
43
9
  YARD::Rake::YardocTask.new
44
10
  rescue LoadError
45
- task :yardoc do
11
+ task :yard do
46
12
  abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
47
13
  end
48
14
  end
@@ -49,10 +49,13 @@ class URL
49
49
 
50
50
  (200..299).include?(code)
51
51
  end
52
+ alias_method :successful?, :success?
52
53
 
54
+ # Attempt to parse the response as json
55
+ # @returns [Hash]
53
56
  def json
54
57
  raise StandardError, 'No JSON library initialized' unless URL.json_handler
55
- URL.json_handler.new(self).parse
58
+ @json ||= URL.json_handler.new(self).parse
56
59
  end
57
60
 
58
61
  end
@@ -0,0 +1,3 @@
1
+ class URL
2
+ VERSION = "0.2.2"
3
+ end
@@ -8,6 +8,13 @@ describe URL do
8
8
  it "should parse json" do
9
9
  subject.get.json.should be_a(Hash)
10
10
  end
11
+
12
+ it "should cache the json generation" do
13
+ JSON.should_receive(:parse).once.and_return({})
14
+ resp = subject.get
15
+ resp.json
16
+ resp.json
17
+ end
11
18
  end
12
19
 
13
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-29 00:00:00 -04:00
18
+ date: 2011-07-25 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,13 +26,28 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 7
30
30
  segments:
31
31
  - 2
32
- - 0
33
- version: "2.0"
32
+ version: "2"
34
33
  type: :development
35
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 1
44
+ segments:
45
+ - 0
46
+ - 7
47
+ - 1
48
+ version: 0.7.1
49
+ type: :development
50
+ version_requirements: *id002
36
51
  description: A simple url object to allow for OO based manipulation and usage of a url
37
52
  email: me@tal.by
38
53
  executables: []
@@ -43,28 +58,26 @@ extra_rdoc_files:
43
58
  - LICENSE
44
59
  - README.rdoc
45
60
  files:
46
- - .document
47
- - LICENSE
48
- - README.rdoc
49
- - Rakefile
50
- - VERSION.yml
51
- - lib/url.rb
52
61
  - lib/url/classer.rb
53
- - lib/url/handlers.rb
54
62
  - lib/url/handlers/as_json_handler.rb
55
63
  - lib/url/handlers/base_json_handler.rb
56
64
  - lib/url/handlers/net_handler.rb
57
65
  - lib/url/handlers/ty_handler.rb
58
66
  - lib/url/handlers/yajl_handler.rb
67
+ - lib/url/handlers.rb
59
68
  - lib/url/helper_classes.rb
60
69
  - lib/url/response.rb
70
+ - lib/url/version.rb
71
+ - lib/url.rb
72
+ - LICENSE
61
73
  - spec/classer_spec.rb
62
74
  - spec/handler_spec.rb
63
75
  - spec/json_spec.rb
64
76
  - spec/spec.opts
65
77
  - spec/spec_helper.rb
66
78
  - spec/url_spec.rb
67
- - url.gemspec
79
+ - README.rdoc
80
+ - Rakefile
68
81
  has_rdoc: true
69
82
  homepage: http://github.com/talby/url
70
83
  licenses: []
@@ -95,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
108
  requirements: []
96
109
 
97
110
  rubyforge_project:
98
- rubygems_version: 1.5.0
111
+ rubygems_version: 1.6.2
99
112
  signing_key:
100
113
  specification_version: 3
101
114
  summary: A URL object
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
@@ -1,5 +0,0 @@
1
- ---
2
- :build:
3
- :minor: 2
4
- :patch: 1
5
- :major: 0
@@ -1,60 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{url}
8
- s.version = "0.2.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tal Atlas"]
12
- s.date = %q{2011-05-29}
13
- s.description = %q{A simple url object to allow for OO based manipulation and usage of a url}
14
- s.email = %q{me@tal.by}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION.yml",
25
- "lib/url.rb",
26
- "lib/url/classer.rb",
27
- "lib/url/handlers.rb",
28
- "lib/url/handlers/as_json_handler.rb",
29
- "lib/url/handlers/base_json_handler.rb",
30
- "lib/url/handlers/net_handler.rb",
31
- "lib/url/handlers/ty_handler.rb",
32
- "lib/url/handlers/yajl_handler.rb",
33
- "lib/url/helper_classes.rb",
34
- "lib/url/response.rb",
35
- "spec/classer_spec.rb",
36
- "spec/handler_spec.rb",
37
- "spec/json_spec.rb",
38
- "spec/spec.opts",
39
- "spec/spec_helper.rb",
40
- "spec/url_spec.rb",
41
- "url.gemspec"
42
- ]
43
- s.homepage = %q{http://github.com/talby/url}
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.5.0}
46
- s.summary = %q{A URL object}
47
-
48
- if s.respond_to? :specification_version then
49
- s.specification_version = 3
50
-
51
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_development_dependency(%q<rspec>, ["~> 2.0"])
53
- else
54
- s.add_dependency(%q<rspec>, ["~> 2.0"])
55
- end
56
- else
57
- s.add_dependency(%q<rspec>, ["~> 2.0"])
58
- end
59
- end
60
-