ronin-support 0.2.0.rc2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -13,6 +13,8 @@
13
13
  * Added {String#format_js}.
14
14
  * Added {Net.smtp_send_message}.
15
15
  * Added {Net.http_status}.
16
+ * Added {Net.http_get_headers}.
17
+ * Added {Net.http_post_headers}.
16
18
  * Added YARD `@api` tags to define the public, semi-public and private APIs.
17
19
  * Renamed `Kernel#attempt` to {Kernel#try}.
18
20
  * Allow `:method` to be used with {Net.http_ok?}.
@@ -25,6 +27,8 @@
25
27
  for unicode characters.
26
28
  * Deprecated {String#common_postfix}, in favor of {String#common_suffix}.
27
29
  {String#common_postfix} will be removed in ronin-support 1.0.0.
30
+ * {Net.http_get_body} no longer accepts a block.
31
+ * {Net.http_post_body} no longer accepts a block.
28
32
 
29
33
  ### 0.1.0 / 2011-03-20
30
34
 
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ platforms :jruby do
7
7
  end
8
8
 
9
9
  group :development do
10
- gem 'rake', '~> 0.8.7'
10
+ gem 'rake', '~> 0.8'
11
11
 
12
12
  gem 'ore-tasks', '~> 0.4'
13
13
  gem 'rspec', '~> 2.4'
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  * [Issues](http://github.com/ronin-ruby/ronin-support/issues)
5
5
  * [Documentation](http://rubydoc.info/gems/ronin-support/frames)
6
6
  * [Mailing List](http://groups.google.com/group/ronin-ruby)
7
- * irc.freenode.net #ronin
7
+ * [irc.freenode.net #ronin](http://webchat.freenode.net/?channels=ronin&uio=Mj10cnVldd)
8
8
 
9
9
  ## Description
10
10
 
data/Rakefile CHANGED
@@ -3,16 +3,16 @@ require 'rubygems'
3
3
  begin
4
4
  require 'bundler'
5
5
  rescue LoadError => e
6
- STDERR.puts e.message
7
- STDERR.puts "Run `gem install bundler` to install Bundler."
6
+ warn e.message
7
+ warn "Run `gem install bundler` to install Bundler."
8
8
  exit e.status_code
9
9
  end
10
10
 
11
11
  begin
12
12
  Bundler.setup(:development)
13
13
  rescue Bundler::BundlerError => e
14
- STDERR.puts e.message
15
- STDERR.puts "Run `bundle install` to install missing gems"
14
+ warn e.message
15
+ warn "Run `bundle install` to install missing gems"
16
16
  exit e.status_code
17
17
  end
18
18
 
data/gemspec.yml CHANGED
@@ -17,8 +17,7 @@ dependencies:
17
17
  hexdump: ~> 0.1
18
18
  combinatorics: ~> 0.3
19
19
  uri-query_params: ~> 0.5, >= 0.5.2
20
- # data_paths: ~> 0.3
21
- data_paths: 0.3.0.rc1
20
+ data_paths: ~> 0.3
22
21
 
23
22
  development_dependencies:
24
23
  bundler: ~> 1.0.10
@@ -160,8 +160,8 @@ class String
160
160
  # Please use {#common_suffix} instead.
161
161
  #
162
162
  def common_postfix(other)
163
- STDERR.puts "DEPRECATED: String#common_postfix was deprecated in 0.2.0."
164
- STDERR.puts "DEPRECATED: Please use String#common_suffix instead."
163
+ warn "DEPRECATED: String#common_postfix was deprecated in 0.2.0."
164
+ warn "DEPRECATED: Please use String#common_suffix instead."
165
165
 
166
166
  common_suffix(other)
167
167
  end
@@ -398,27 +398,39 @@ module Net
398
398
  end
399
399
 
400
400
  #
401
- # Performs an HTTP Get request.
401
+ # Performs an HTTP Get request and returns the Response Headers.
402
402
  #
403
403
  # @param [Hash] options
404
404
  # Additional options.
405
405
  #
406
- # @yield [response]
407
- # If a block is given, it will be passed the response received from
408
- # the request.
406
+ # @return [Hash{String => Array<String>}]
407
+ # The Headers of the HTTP response.
409
408
  #
410
- # @yieldparam [Net::HTTP::Response] response
411
- # The HTTP response object.
409
+ # @see http_get
410
+ #
411
+ # @since 0.2.0
412
+ #
413
+ # @api public
414
+ #
415
+ def Net.http_get_headers(options={})
416
+ Net.http_get(options).to_hash
417
+ end
418
+
419
+ #
420
+ # Performs an HTTP Get request and returns the Respond Body.
421
+ #
422
+ # @param [Hash] options
423
+ # Additional options.
412
424
  #
413
425
  # @return [String]
414
426
  # The body of the HTTP response.
415
427
  #
416
- # @see http_request
428
+ # @see http_get
417
429
  #
418
430
  # @api public
419
431
  #
420
- def Net.http_get_body(options={},&block)
421
- Net.http_get(options,&block).body
432
+ def Net.http_get_body(options={})
433
+ Net.http_get(options).body
422
434
  end
423
435
 
424
436
  #
@@ -587,7 +599,7 @@ module Net
587
599
  end
588
600
 
589
601
  #
590
- # Performs an HTTP Post request.
602
+ # Performs an HTTP Post request and returns the Response Headers.
591
603
  #
592
604
  # @param [Hash] options
593
605
  # Additional options.
@@ -595,22 +607,37 @@ module Net
595
607
  # @option options [Hash, String] :form_data
596
608
  # The form data to send with the HTTP Post request.
597
609
  #
598
- # @yield [response]
599
- # If a block is given, it will be passed the response received from
600
- # the request.
610
+ # @return [Hash{String => Array<String>}]
611
+ # The headers of the HTTP response.
601
612
  #
602
- # @yieldparam [Net::HTTP::Response] response
603
- # The HTTP response object.
613
+ # @see http_post
614
+ #
615
+ # @since 0.2.0
616
+ #
617
+ # @api public
618
+ #
619
+ def Net.http_post_headers(options={})
620
+ Net.http_post(options).to_hash
621
+ end
622
+
623
+ #
624
+ # Performs an HTTP Post request and returns the Response Body.
625
+ #
626
+ # @param [Hash] options
627
+ # Additional options.
628
+ #
629
+ # @option options [Hash, String] :form_data
630
+ # The form data to send with the HTTP Post request.
604
631
  #
605
632
  # @return [String]
606
633
  # The body of the HTTP response.
607
634
  #
608
- # @see http_request
635
+ # @see http_post
609
636
  #
610
637
  # @api public
611
638
  #
612
- def Net.http_post_body(options={},&block)
613
- Net.http_post(options,&block).body
639
+ def Net.http_post_body(options={})
640
+ Net.http_post(options).body
614
641
  end
615
642
 
616
643
  #
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Support
22
22
  # ronin-support version
23
- VERSION = '0.2.0.rc2'
23
+ VERSION = '0.2.0'
24
24
  end
25
25
  end
@@ -1,15 +1,131 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- begin
4
- Ore::Specification.new do |gemspec|
5
- # custom logic here
6
- end
7
- rescue NameError
8
- begin
9
- require 'ore/specification'
10
- retry
11
- rescue LoadError
12
- STDERR.puts "The '#{__FILE__}' file requires Ore."
13
- STDERR.puts "Run `gem install ore-core` to install Ore."
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gemspec|
6
+ root = File.dirname(__FILE__)
7
+ lib_dir = File.join(root,'lib')
8
+ files = if File.directory?('.git')
9
+ `git ls-files`.split($/)
10
+ elsif File.directory?('.hg')
11
+ `hg manifest`.split($/)
12
+ elsif File.directory?('.svn')
13
+ `svn ls -R`.split($/).select { |path| File.file?(path) }
14
+ else
15
+ Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
+ end
17
+
18
+ filter_files = lambda { |paths|
19
+ case paths
20
+ when Array
21
+ (files & paths)
22
+ when String
23
+ (files & Dir[paths])
24
+ end
25
+ }
26
+
27
+ version = {
28
+ :file => 'ronin/support/version',
29
+ :constant => 'Ronin::Support::VERSION'
30
+ }
31
+
32
+ defaults = {
33
+ 'name' => File.basename(root),
34
+ 'files' => files,
35
+ 'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
36
+ 'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
37
+ 'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
38
+ }
39
+
40
+ metadata = defaults.merge(YAML.load_file('gemspec.yml'))
41
+
42
+ gemspec.name = metadata.fetch('name',defaults[:name])
43
+ gemspec.version = if metadata['version']
44
+ metadata['version']
45
+ else
46
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
47
+
48
+ require version[:file]
49
+ eval(version[:constant])
50
+ end
51
+
52
+ gemspec.summary = metadata.fetch('summary',metadata['description'])
53
+ gemspec.description = metadata.fetch('description',metadata['summary'])
54
+
55
+ case metadata['license']
56
+ when Array
57
+ gemspec.licenses = metadata['license']
58
+ when String
59
+ gemspec.license = metadata['license']
60
+ end
61
+
62
+ case metadata['authors']
63
+ when Array
64
+ gemspec.authors = metadata['authors']
65
+ when String
66
+ gemspec.author = metadata['authors']
67
+ end
68
+
69
+ gemspec.email = metadata['email']
70
+ gemspec.homepage = metadata['homepage']
71
+
72
+ case metadata['require_paths']
73
+ when Array
74
+ gemspec.require_paths = metadata['require_paths']
75
+ when String
76
+ gemspec.require_path = metadata['require_paths']
77
+ end
78
+
79
+ gemspec.files = filter_files[metadata['files']]
80
+
81
+ gemspec.executables = metadata['executables']
82
+ gemspec.extensions = metadata['extensions']
83
+
84
+ if Gem::VERSION < '1.7.'
85
+ gemspec.default_executable = gemspec.executables.first
86
+ end
87
+
88
+ gemspec.test_files = filter_files[metadata['test_files']]
89
+
90
+ unless gemspec.files.include?('.document')
91
+ gemspec.extra_rdoc_files = metadata['extra_doc_files']
92
+ end
93
+
94
+ gemspec.post_install_message = metadata['post_install_message']
95
+ gemspec.requirements = metadata['requirements']
96
+
97
+ if gemspec.respond_to?(:required_ruby_version=)
98
+ gemspec.required_ruby_version = metadata['required_ruby_version']
99
+ end
100
+
101
+ if gemspec.respond_to?(:required_rubygems_version=)
102
+ gemspec.required_rubygems_version = metadata['required_ruby_version']
103
+ end
104
+
105
+ parse_versions = lambda { |versions|
106
+ case versions
107
+ when Array
108
+ versions.map { |v| v.to_s }
109
+ when String
110
+ versions.split(/,\s*/)
111
+ end
112
+ }
113
+
114
+ if metadata['dependencies']
115
+ metadata['dependencies'].each do |name,versions|
116
+ gemspec.add_dependency(name,parse_versions[versions])
117
+ end
118
+ end
119
+
120
+ if metadata['runtime_dependencies']
121
+ metadata['runtime_dependencies'].each do |name,versions|
122
+ gemspec.add_runtime_dependency(name,parse_versions[versions])
123
+ end
124
+ end
125
+
126
+ if metadata['development_dependencies']
127
+ metadata['development_dependencies'].each do |name,versions|
128
+ gemspec.add_development_dependency(name,parse_versions[versions])
129
+ end
14
130
  end
15
131
  end
@@ -156,12 +156,12 @@ describe IPAddr do
156
156
  end
157
157
  end
158
158
 
159
- let(:ip) { IPAddr.new(Resolv.getaddress('www.example.com')) }
159
+ let(:ip) { IPAddr.new('127.0.0.1') }
160
160
  let(:bad_ip) { IPAddr.new('0.0.0.0') }
161
161
 
162
162
  describe "#lookup" do
163
163
  it "should lookup the host-name for an IP" do
164
- ip.lookup.should == ['www.example.com']
164
+ ip.lookup.should include('localhost')
165
165
  end
166
166
 
167
167
  it "should return an empty Array for unknown IP addresses" do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 0.2.0.rc2
4
+ prerelease:
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Postmodern
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-07 00:00:00 Z
13
+ date: 2011-07-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chars
@@ -64,9 +64,9 @@ dependencies:
64
64
  requirement: &id005 !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - "="
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 0.3.0.rc1
69
+ version: "0.3"
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: *id005
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  requirements: []
265
265
 
266
266
  rubyforge_project: ronin-support
267
- rubygems_version: 1.8.1
267
+ rubygems_version: 1.8.5
268
268
  signing_key:
269
269
  specification_version: 3
270
270
  summary: A support library for Ronin.