httparty 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

@@ -1,3 +1,10 @@
1
+ == 0.1.8 2008-11-30
2
+ * 3 major enhancements
3
+ * Moved base_uri normalization into request class and out of httparty module, fixing
4
+ the problem where base_uri was not always being normalized.
5
+ * Stupid simple support for HTTParty.get/post/put/delete. (jqr)
6
+ * Switched gem management to Echoe from newgem.
7
+
1
8
  == 0.1.7 2008-11-30
2
9
  * 1 major enhancement
3
10
  * fixed multiple class definitions overriding each others options
File without changes
@@ -1,32 +1,23 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- PostInstall.txt
5
- README.txt
6
- Rakefile
7
- config/hoe.rb
8
- config/requirements.rb
9
1
  examples/aaws.rb
2
+ examples/basic.rb
10
3
  examples/delicious.rb
11
4
  examples/google.rb
12
5
  examples/rubyurl.rb
13
6
  examples/twitter.rb
14
7
  examples/whoismyrep.rb
8
+ History
15
9
  httparty.gemspec
16
- lib/httparty.rb
17
10
  lib/httparty/request.rb
18
11
  lib/httparty/version.rb
19
- script/console
20
- script/destroy
21
- script/generate
22
- script/txt2html
12
+ lib/httparty.rb
13
+ Manifest
14
+ MIT-LICENSE
15
+ Rakefile
16
+ README
23
17
  setup.rb
24
18
  spec/httparty/request_spec.rb
25
19
  spec/httparty_spec.rb
26
20
  spec/spec.opts
27
21
  spec/spec_helper.rb
28
- tasks/deployment.rake
29
- tasks/environment.rake
30
- tasks/website.rake
31
22
  website/css/common.css
32
23
  website/index.html
data/README ADDED
@@ -0,0 +1,24 @@
1
+ = httparty
2
+
3
+ == DESCRIPTION:
4
+
5
+ Makes http fun again!
6
+
7
+ == FEATURES:
8
+
9
+ * Easy get, post, put, delete requests
10
+ * Basic http authentication
11
+ * Default request query string parameters (ie: for api keys that are needed on each request)
12
+ * Automatic parsing of JSON and XML into ruby hashes based on response content-type
13
+
14
+ == EXAMPLES:
15
+
16
+ See http://github.com/jnunemaker/httparty/tree/master/examples
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * Active Support >= 2.1
21
+
22
+ == INSTALL:
23
+
24
+ * sudo gem install httparty
data/Rakefile CHANGED
@@ -1,11 +1,43 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
3
- require "spec/rake/spectask"
1
+ ProjectName = 'httparty'
2
+ WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}"
4
3
 
5
- Dir['tasks/**/*.rake'].each { |rake| load rake }
4
+ require 'rubygems'
5
+ require 'rake'
6
+ require 'echoe'
7
+ require 'spec/rake/spectask'
8
+ require "lib/#{ProjectName}/version"
6
9
 
7
- task :default => :spec
10
+ Echoe.new(ProjectName, HTTParty::Version) do |p|
11
+ p.description = "Makes http fun! Also, makes consuming restful web services dead easy."
12
+ p.install_message = "When you HTTParty, you must party hard!"
13
+ p.url = "http://#{ProjectName}.rubyforge.org"
14
+ p.author = "John Nunemaker"
15
+ p.email = "nunemaker@gmail.com"
16
+ p.extra_deps = [['activesupport', '>= 2.1']]
17
+ p.need_tar_gz = false
18
+ p.docs_host = WebsitePath
19
+ end
20
+
21
+ desc 'Upload website files to rubyforge'
22
+ task :website do
23
+ sh %{rsync -av website/ #{WebsitePath}}
24
+ Rake::Task['website_docs'].invoke
25
+ end
26
+
27
+ task :website_docs do
28
+ Rake::Task['redocs'].invoke
29
+ sh %{rsync -av doc/ #{WebsitePath}/docs}
30
+ end
8
31
 
32
+ desc 'Preps the gem for a new release'
33
+ task :prepare do
34
+ %w[manifest build_gemspec].each do |task|
35
+ Rake::Task[task].invoke
36
+ end
37
+ end
38
+
39
+ Rake::Task[:default].prerequisites.clear
40
+ task :default => :spec
9
41
  Spec::Rake::SpecTask.new do |t|
10
42
  t.spec_files = FileList["spec/**/*_spec.rb"]
11
43
  end
@@ -0,0 +1,6 @@
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require File.join(dir, 'httparty')
3
+ require 'pp'
4
+
5
+ # You can also use post, put, delete in the same fashion
6
+ pp HTTParty.get('http://twitter.com/statuses/public_timeline.json')
@@ -33,5 +33,4 @@ end
33
33
 
34
34
  delicious = Delicious.new(config['username'], config['password'])
35
35
  pp delicious.posts(:query => {:tag => 'ruby'})
36
- pp delicious.recent
37
36
 
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{httparty}
5
- s.version = "0.1.7"
5
+ s.version = "0.1.8"
6
6
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Nunemaker"]
9
- s.date = %q{2008-11-30}
9
+ s.date = %q{2008-12-05}
10
10
  s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
11
- s.email = ["nunemaker@gmail.com"]
12
- s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt"]
13
- s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "examples/aaws.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "httparty.gemspec", "lib/httparty.rb", "lib/httparty/request.rb", "lib/httparty/version.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
11
+ s.email = %q{nunemaker@gmail.com}
12
+ s.extra_rdoc_files = ["lib/httparty/request.rb", "lib/httparty/version.rb", "lib/httparty.rb", "README"]
13
+ s.files = ["examples/aaws.rb", "examples/basic.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "History", "httparty.gemspec", "lib/httparty/request.rb", "lib/httparty/version.rb", "lib/httparty.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README", "setup.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://httparty.rubyforge.org}
16
16
  s.post_install_message = %q{When you HTTParty, you must party hard!}
17
- s.rdoc_options = ["--main", "README.txt"]
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Httparty", "--main", "README"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubyforge_project = %q{httparty}
20
20
  s.rubygems_version = %q{1.3.1}
@@ -26,13 +26,13 @@ Gem::Specification.new do |s|
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
28
  s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
29
- s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
29
+ s.add_development_dependency(%q<echoe>, [">= 0"])
30
30
  else
31
31
  s.add_dependency(%q<activesupport>, [">= 2.1"])
32
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
32
+ s.add_dependency(%q<echoe>, [">= 0"])
33
33
  end
34
34
  else
35
35
  s.add_dependency(%q<activesupport>, [">= 2.1"])
36
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
36
+ s.add_dependency(%q<echoe>, [">= 0"])
37
37
  end
38
- end
38
+ end
@@ -1,12 +1,11 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
3
  require 'uri'
4
- require 'ostruct'
5
4
  require 'rubygems'
6
5
  require 'active_support'
7
6
 
8
- directory = File.dirname(__FILE__)
9
- $:.unshift(directory) unless $:.include?(directory) || $:.include?(File.expand_path(directory))
7
+ dir = File.dirname(__FILE__)
8
+ $:.unshift(dir) unless $:.include?(dir) || $:.include?(File.expand_path(dir))
10
9
 
11
10
  require 'httparty/request'
12
11
 
@@ -68,7 +67,7 @@ module HTTParty
68
67
 
69
68
  def base_uri(uri=nil)
70
69
  return default_options[:base_uri] unless uri
71
- default_options[:base_uri] = normalize_base_uri(uri)
70
+ default_options[:base_uri] = uri
72
71
  end
73
72
 
74
73
  def basic_auth(u, p)
@@ -112,13 +111,26 @@ module HTTParty
112
111
  def perform_request(http_method, path, options) #:nodoc:
113
112
  Request.new(http_method, path, default_options.merge(options)).perform
114
113
  end
115
-
116
- # Makes it so uri is sure to parse stuff like google.com without the http
117
- def normalize_base_uri(url) #:nodoc:
118
- use_ssl = (url =~ /^https/) || url.include?(':443')
119
- url.chop! if url.ends_with?('/')
120
- url.gsub!(/^https?:\/\//i, '')
121
- "http#{'s' if use_ssl}://#{url}"
122
- end
123
114
  end
115
+
116
+ class Basement
117
+ include HTTParty
118
+ end
119
+
120
+ def self.get(*args)
121
+ Basement.get(*args)
122
+ end
123
+
124
+ def self.post(*args)
125
+ Basement.post(*args)
126
+ end
127
+
128
+ def self.put(*args)
129
+ Basement.put(*args)
130
+ end
131
+
132
+ def self.delete(*args)
133
+ Basement.delete(*args)
134
+ end
135
+
124
136
  end
@@ -1,7 +1,15 @@
1
1
  module HTTParty
2
2
  class Request
3
+ # Makes it so uri is sure to parse stuff like google.com without the http
4
+ def self.normalize_base_uri(url) #:nodoc:
5
+ use_ssl = (url =~ /^https/) || url.include?(':443')
6
+ url.chop! if url.ends_with?('/')
7
+ url.gsub!(/^https?:\/\//i, '')
8
+ "http#{'s' if use_ssl}://#{url}"
9
+ end
10
+
3
11
  SupportedHTTPMethods = [Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete]
4
-
12
+
5
13
  attr_accessor :http_method, :path, :options
6
14
 
7
15
  def initialize(http_method, path, options={})
@@ -18,6 +26,7 @@ module HTTParty
18
26
  end
19
27
 
20
28
  def uri
29
+ options[:base_uri] = self.class.normalize_base_uri(options[:base_uri]) unless options[:base_uri].nil?
21
30
  uri = path.relative? ? URI.parse("#{options[:base_uri]}#{path}") : path
22
31
  uri.query = query_string(uri)
23
32
  uri
@@ -1,9 +1,3 @@
1
1
  module HTTParty
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 7
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
2
+ Version = '0.1.8'
3
+ end
@@ -4,6 +4,30 @@ describe HTTParty::Request do
4
4
  before do
5
5
  @request = HTTParty::Request.new(Net::HTTP::Get, 'http://api.foo.com/v1', :format => :xml)
6
6
  end
7
+
8
+ describe "#normalize_base_uri" do
9
+ it "should add http if not present for non ssl requests" do
10
+ uri = HTTParty::Request.normalize_base_uri('api.foobar.com')
11
+ uri.should == 'http://api.foobar.com'
12
+ end
13
+
14
+ it "should add https if not present for ssl requests" do
15
+ uri = HTTParty::Request.normalize_base_uri('api.foo.com/v1:443')
16
+ uri.should == 'https://api.foo.com/v1:443'
17
+ end
18
+
19
+ it "should not remove https for ssl requests" do
20
+ uri = HTTParty::Request.normalize_base_uri('https://api.foo.com/v1:443')
21
+ uri.should == 'https://api.foo.com/v1:443'
22
+ end
23
+ end
24
+
25
+ describe "uri" do
26
+ it "should be normalized" do
27
+ request = HTTParty::Request.new(Net::HTTP::Get, '', :base_uri => 'api.foo.com')
28
+ request.uri.to_s.should == 'http://api.foo.com'
29
+ end
30
+ end
7
31
 
8
32
  describe 'http' do
9
33
  it "should use ssl for port 443" do
@@ -25,28 +25,13 @@ describe HTTParty do
25
25
  end
26
26
 
27
27
  it "should have reader" do
28
- Foo.base_uri.should == 'http://api.foo.com/v1'
28
+ Foo.base_uri.should == 'api.foo.com/v1'
29
29
  end
30
30
 
31
31
  it 'should have writer' do
32
32
  Foo.base_uri('http://api.foobar.com')
33
33
  Foo.base_uri.should == 'http://api.foobar.com'
34
34
  end
35
-
36
- it "should add http if not present for non ssl requests" do
37
- Foo.base_uri('api.foobar.com')
38
- Foo.base_uri.should == 'http://api.foobar.com'
39
- end
40
-
41
- it "should add https if not present for ssl requests" do
42
- Foo.base_uri('api.foo.com/v1:443')
43
- Foo.base_uri.should == 'https://api.foo.com/v1:443'
44
- end
45
-
46
- it "should not remove https for ssl requests" do
47
- Foo.base_uri('https://api.foo.com/v1:443')
48
- Foo.base_uri.should == 'https://api.foo.com/v1:443'
49
- end
50
35
  end
51
36
 
52
37
  describe "headers" do
@@ -127,8 +112,8 @@ describe HTTParty do
127
112
 
128
113
  describe "with multiple class definitions" do
129
114
  it "should not run over each others options" do
130
- HRest.default_options.should == {:base_uri => 'http://hrest.com', :default_params => {:two => 'three'}}
131
- GRest.default_options.should == {:base_uri => 'http://grest.com', :default_params => {:one => 'two'}}
115
+ HRest.default_options.should == {:base_uri => 'hrest.com', :default_params => {:two => 'three'}}
116
+ GRest.default_options.should == {:base_uri => 'grest.com', :default_params => {:one => 'two'}}
132
117
  end
133
118
  end
134
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-01 00:00:00 -05:00
12
+ date: 2008-12-05 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -23,67 +23,60 @@ dependencies:
23
23
  version: "2.1"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: hoe
26
+ name: echoe
27
27
  type: :development
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.0
33
+ version: "0"
34
34
  version:
35
35
  description: Makes http fun! Also, makes consuming restful web services dead easy.
36
- email:
37
- - nunemaker@gmail.com
36
+ email: nunemaker@gmail.com
38
37
  executables: []
39
38
 
40
39
  extensions: []
41
40
 
42
41
  extra_rdoc_files:
43
- - History.txt
44
- - License.txt
45
- - Manifest.txt
46
- - PostInstall.txt
47
- - README.txt
42
+ - lib/httparty/request.rb
43
+ - lib/httparty/version.rb
44
+ - lib/httparty.rb
45
+ - README
48
46
  files:
49
- - History.txt
50
- - License.txt
51
- - Manifest.txt
52
- - PostInstall.txt
53
- - README.txt
54
- - Rakefile
55
- - config/hoe.rb
56
- - config/requirements.rb
57
47
  - examples/aaws.rb
48
+ - examples/basic.rb
58
49
  - examples/delicious.rb
59
50
  - examples/google.rb
60
51
  - examples/rubyurl.rb
61
52
  - examples/twitter.rb
62
53
  - examples/whoismyrep.rb
54
+ - History
63
55
  - httparty.gemspec
64
- - lib/httparty.rb
65
56
  - lib/httparty/request.rb
66
57
  - lib/httparty/version.rb
67
- - script/console
68
- - script/destroy
69
- - script/generate
70
- - script/txt2html
58
+ - lib/httparty.rb
59
+ - Manifest
60
+ - MIT-LICENSE
61
+ - Rakefile
62
+ - README
71
63
  - setup.rb
72
64
  - spec/httparty/request_spec.rb
73
65
  - spec/httparty_spec.rb
74
66
  - spec/spec.opts
75
67
  - spec/spec_helper.rb
76
- - tasks/deployment.rake
77
- - tasks/environment.rake
78
- - tasks/website.rake
79
68
  - website/css/common.css
80
69
  - website/index.html
81
70
  has_rdoc: true
82
71
  homepage: http://httparty.rubyforge.org
83
72
  post_install_message: When you HTTParty, you must party hard!
84
73
  rdoc_options:
74
+ - --line-numbers
75
+ - --inline-source
76
+ - --title
77
+ - Httparty
85
78
  - --main
86
- - README.txt
79
+ - README
87
80
  require_paths:
88
81
  - lib
89
82
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -96,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
89
  requirements:
97
90
  - - ">="
98
91
  - !ruby/object:Gem::Version
99
- version: "0"
92
+ version: "1.2"
100
93
  version:
101
94
  requirements: []
102
95
 
@@ -1 +0,0 @@
1
- When you HTTParty, you must party hard!
data/README.txt DELETED
@@ -1,66 +0,0 @@
1
- = httparty
2
-
3
- == DESCRIPTION:
4
-
5
- Makes http fun again!
6
-
7
- == FEATURES/PROBLEMS:
8
-
9
- * Easy get, post, put, delete requests
10
- * Basic http authentication
11
- * Default request query string parameters (ie: for api keys that are needed on each request)
12
- * Automatic parsing of JSON and XML into ruby hashes based on response content-type
13
-
14
- == SYNOPSIS:
15
-
16
- The following is a simple example of wrapping Twitter's API for posting updates.
17
-
18
- class Twitter
19
- include HTTParty
20
- base_uri 'twitter.com'
21
- basic_auth 'username', 'password'
22
- end
23
-
24
- Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})
25
-
26
- That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples).
27
-
28
- That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that:
29
-
30
- class Twitter
31
- include HTTParty
32
- base_uri 'twitter.com'
33
-
34
- def initialize(u, p)
35
- @auth = {:username => u, :password => p}
36
- end
37
-
38
- def post(text)
39
- options = { :query => {:status => text}, :basic_auth => @auth }
40
- self.class.post('/statuses/update.json', options)
41
- end
42
- end
43
-
44
- Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")
45
-
46
- === REQUEST OPTIONS
47
-
48
- Each of the HTTP method (get, post, put and delete) each take a hash of options.
49
- The following keys can be specified in the options:
50
-
51
- headers:: A <tt>Hash</tt> of header key/value pairs
52
- query:: A <tt>Hash</tt> of query key/value pairs
53
- body:: The body of the request. If it's a <tt>Hash</tt>, it is
54
- converted into query-string format, otherwise it is sent
55
- as-is.
56
- basic_auth:: A <tt>Hash</tt> containing keys for <tt>:username</tt> and
57
- <tt>:password</tt>.
58
- no_follow:: Turns off automatic redirect following
59
-
60
- == REQUIREMENTS:
61
-
62
- * Active Support >= 2.1
63
-
64
- == INSTALL:
65
-
66
- * sudo gem install httparty
@@ -1,73 +0,0 @@
1
- require 'httparty/version'
2
-
3
- AUTHOR = 'John Nunemaker' # can also be an array of Authors
4
- EMAIL = "nunemaker@gmail.com"
5
- DESCRIPTION = "Makes http fun! Also, makes consuming restful web services dead easy."
6
- GEM_NAME = 'httparty' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'httparty' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
- EXTRA_DEPENDENCIES = [
11
- ['activesupport', '>= 2.1']
12
- ] # An array of rubygem dependencies [name, version]
13
-
14
- @config_file = "~/.rubyforge/user-config.yml"
15
- @config = nil
16
- RUBYFORGE_USERNAME = "unknown"
17
- def rubyforge_username
18
- unless @config
19
- begin
20
- @config = YAML.load(File.read(File.expand_path(@config_file)))
21
- rescue
22
- puts <<-EOS
23
- ERROR: No rubyforge config file found: #{@config_file}
24
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
- - See http://newgem.rubyforge.org/rubyforge.html for more details
26
- EOS
27
- exit
28
- end
29
- end
30
- RUBYFORGE_USERNAME.replace @config["username"]
31
- end
32
-
33
-
34
- REV = nil
35
- # UNCOMMENT IF REQUIRED:
36
- # REV = YAML.load(`svn info`)['Revision']
37
- VERS = HTTParty::VERSION::STRING + (REV ? ".#{REV}" : "")
38
- RDOC_OPTS = ['--quiet', '--title', 'httparty documentation',
39
- "--opname", "index.html",
40
- "--line-numbers",
41
- "--main", "README",
42
- "--inline-source"]
43
-
44
- class Hoe
45
- def extra_deps
46
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
- @extra_deps
48
- end
49
- end
50
-
51
- # Generate all the Rake tasks
52
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
- p.developer(AUTHOR, EMAIL)
55
- p.description = DESCRIPTION
56
- p.summary = DESCRIPTION
57
- p.url = HOMEPATH
58
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
- p.test_globs = ["test/**/test_*.rb"]
60
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
-
62
- # == Optional
63
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
- p.extra_deps = EXTRA_DEPENDENCIES
65
-
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
- end
68
-
69
- CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
- $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
- $hoe.rsync_args = '-av --delete --ignore-errors'
73
- $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -1,15 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
6
- begin
7
- require req_gem
8
- rescue LoadError
9
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
- puts "Installation: gem install #{req_gem} -y"
11
- exit
12
- end
13
- end
14
-
15
- $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/httparty.rb'}"
9
- puts "Loading httparty gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- GEM_NAME = 'httparty' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = 'httparty'
5
-
6
- require 'rubygems'
7
- begin
8
- require 'newgem'
9
- require 'rubyforge'
10
- rescue LoadError
11
- puts "\n\nGenerating the website requires the newgem RubyGem"
12
- puts "Install: gem install newgem\n\n"
13
- exit(1)
14
- end
15
- require 'redcloth'
16
- require 'syntax/convertors/html'
17
- require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
-
20
- version = HTTParty::VERSION::STRING
21
- download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
-
23
- def rubyforge_project_id
24
- RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
- end
26
-
27
- class Fixnum
28
- def ordinal
29
- # teens
30
- return 'th' if (10..19).include?(self % 100)
31
- # others
32
- case self % 10
33
- when 1: return 'st'
34
- when 2: return 'nd'
35
- when 3: return 'rd'
36
- else return 'th'
37
- end
38
- end
39
- end
40
-
41
- class Time
42
- def pretty
43
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
- end
45
- end
46
-
47
- def convert_syntax(syntax, source)
48
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
- end
50
-
51
- if ARGV.length >= 1
52
- src, template = ARGV
53
- template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
- else
55
- puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
- exit!
57
- end
58
-
59
- template = ERB.new(File.open(template).read)
60
-
61
- title = nil
62
- body = nil
63
- File.open(src) do |fsrc|
64
- title_text = fsrc.readline
65
- body_text_template = fsrc.read
66
- body_text = ERB.new(body_text_template).result(binding)
67
- syntax_items = []
68
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
- ident = syntax_items.length
70
- element, syntax, source = $1, $2, $3
71
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
- "syntax-temp-#{ident}"
73
- }
74
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
- body = RedCloth.new(body_text).to_html
76
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
- end
78
- stat = File.stat(src)
79
- created = stat.ctime
80
- modified = stat.mtime
81
-
82
- $stdout << template.result(binding)
@@ -1,43 +0,0 @@
1
- desc 'Preps the gem for a new release'
2
- task :prep_for_release do
3
- require 'rio'
4
- Rake::Task['manifest:refresh'].invoke
5
- gemspec = %x[rake debug_gem]
6
- lines = gemspec.split("\n")
7
- rio('httparty.gemspec') < lines[1, lines.length-1].join("\n")
8
- end
9
-
10
- desc 'Release the website and new gem version'
11
- task :deploy => [:check_version, :website, :release] do
12
- puts "Remember to create SVN tag:"
13
- puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
14
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
15
- puts "Suggested comment:"
16
- puts "Tagging release #{CHANGES}"
17
- end
18
-
19
- desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
20
- task :local_deploy => [:website_generate, :install_gem]
21
-
22
- task :check_version do
23
- unless ENV['VERSION']
24
- puts 'Must pass a VERSION=x.y.z release version'
25
- exit
26
- end
27
- unless ENV['VERSION'] == VERS
28
- puts "Please update your version.rb to match the release version, currently #{VERS}"
29
- exit
30
- end
31
- end
32
-
33
- desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
34
- task :install_gem_no_doc => [:clean, :package] do
35
- sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
36
- end
37
-
38
- namespace :manifest do
39
- desc 'Recreate Manifest.txt to include ALL files'
40
- task :refresh do
41
- `rake check_manifest | patch -p0 > Manifest.txt`
42
- end
43
- end
@@ -1,7 +0,0 @@
1
- task :ruby_env do
2
- RUBY_APP = if RUBY_PLATFORM =~ /java/
3
- "jruby"
4
- else
5
- "ruby"
6
- end unless defined? RUBY_APP
7
- end
@@ -1,17 +0,0 @@
1
- desc 'Generate website files'
2
- task :website_generate => :ruby_env do
3
- (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
- sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
- end
6
- end
7
-
8
- desc 'Upload website files to rubyforge'
9
- task :website_upload do
10
- host = "#{rubyforge_username}@rubyforge.org"
11
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
- local_dir = 'website'
13
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
- end
15
-
16
- desc 'Generate and upload website files'
17
- task :website => [:website_upload, :publish_docs]