iudex-barc 1.2.b.0-java → 1.2.b.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.2.b.1 (2012-5-31)
2
+ * Improve usability of iudex-http-record CLI
3
+ * Output (H) default type in BARCResponseHandler (as used by
4
+ iudex-http-record)
5
+
1
6
  === 1.2.b.0 (2012-3-4)
2
7
  * Upgrade to gravitext-util ~> 1.6.b (beta)
3
8
  * Upgrade to tarpit ~> 2.0, bundler Gemfile, gemspec (dev)
data/Manifest.txt CHANGED
@@ -7,4 +7,4 @@ bin/iudex-barc
7
7
  bin/iudex-http-record
8
8
  lib/iudex-barc/base.rb
9
9
  lib/iudex-barc.rb
10
- lib/iudex-barc/iudex-barc-1.2.b.0.jar
10
+ lib/iudex-barc/iudex-barc-1.2.b.1.jar
@@ -19,33 +19,97 @@
19
19
  $LOAD_PATH.unshift File.join( File.dirname(__FILE__), "..", "lib" )
20
20
 
21
21
  require 'rubygems'
22
- require 'rjack-logback'
23
- RJack::Logback.config_console
22
+ require 'optparse'
24
23
 
25
- #RJack::Logback[ "org.apache.commons.httpclient" ].level = RJack::Logback::INFO
26
- #RJack::Logback[ "iudex" ].level = RJack::Logback::DEBUG
24
+ module IudexBinScript
27
25
 
28
- require 'iudex-barc'
29
- require 'iudex-httpclient-3' #FIXME: Unspecified dependency
26
+ require 'rjack-logback'
27
+ include RJack
30
28
 
31
- import 'iudex.httpclient3.HTTPClient3'
32
- import 'iudex.barc.http.BARCResponseHandler'
33
- import 'iudex.barc.BARCFile'
29
+ Logback.config_console( :stderr => true )
34
30
 
35
- hmanager = RJack::HTTPClient3::ManagerFacade.new
36
- hmanager.start
31
+ #FIXME: Add debug flags
32
+ #RJack::Logback[ "org.apache.commons.httpclient" ].level = RJack::Logback::INFO
33
+ #RJack::Logback[ "iudex" ].level = RJack::Logback::DEBUG
37
34
 
38
- hclient = HTTPClient3.new( hmanager.client )
35
+ require 'iudex-barc'
39
36
 
40
- barc_file = BARCFile.new( java.io.File.new( './record.barc' ) ) #FIXME: param
41
- barc_file.truncate #FIXME: Optional
37
+ require 'iudex-httpclient-3' #FIXME: Unspecified dependency
42
38
 
43
- handler = BARCResponseHandler.new( barc_file )
44
- handler.do_compress = false #FIXME: Option
39
+ class BARCRecorder
40
+ import 'iudex.httpclient3.HTTPClient3'
41
+ import 'iudex.barc.http.BARCResponseHandler'
45
42
 
46
- hsession = hclient.createSession;
47
- hsession.url = 'http://gravitext.com/blog' #FIXME: param
43
+ def initialize
44
+ @req_headers = { 'User-Agent' => http_user_agent,
45
+ 'Accept' => accept_types }
46
+ end
48
47
 
49
- hclient.request( hsession, handler )
48
+ def run( args = ARGV )
49
+ urls = parse_args( args )
50
50
 
51
- hmanager.shutdown
51
+ mgr = Iudex::HTTPClient3.create_manager
52
+ mgr.client_params.set_int_parameter( "http.protocol.max-redirects", 8 )
53
+ mgr.start
54
+
55
+ hclient = HTTPClient3.new( mgr.client )
56
+
57
+ barc_file = Iudex::BARC::BARCFile.new( java.io.File.new( @barc_name ) )
58
+ barc_file.truncate if @barc_name == './record.barc'
59
+
60
+ handler = BARCResponseHandler.new( barc_file )
61
+ handler.do_compress = false
62
+
63
+ urls.each do |url|
64
+ hsession = hclient.createSession;
65
+ hsession.url = url
66
+ headers = @req_headers.map { |h,v| Iudex::HTTP::Header.new( h, v ) }
67
+ hsession.add_request_headers( headers )
68
+ hclient.request( hsession, handler )
69
+ end
70
+
71
+ ensure
72
+ mgr.shutdown if mgr
73
+ barc_file.close if barc_file
74
+ end
75
+
76
+ def parse_args( args = ARGV )
77
+ parser = OptionParser.new do |opts|
78
+ opts.banner = ( "Usage: iudex-http-record [options] URL... " +
79
+ "[BARCFile]\n" +
80
+ "Options:\n" )
81
+
82
+ opts.on( "-v", "--version", "Display version and exit" ) do
83
+ puts "iudex-barc: #{Iudex::BARC::VERSION}"
84
+ exit 1
85
+ end
86
+
87
+ opts.on( "-A", "--User-Agent UA", String, "Set alt User-Agent" ) do |s|
88
+ @req_headers[ 'User-Agent' ] = s
89
+ end
90
+
91
+ end
92
+
93
+ args = parser.parse( args )
94
+ @barc_name = './record.barc'
95
+ if args.last =~ /.barc$/
96
+ @barc_name = args.pop
97
+ end
98
+
99
+ args #urls
100
+ end
101
+
102
+ def http_user_agent
103
+ ( "Mozilla/5.0 (compatible; " +
104
+ "Iudex #{Iudex::HTTPClient3::VERSION}; " +
105
+ "+http://gravitext.com/iudex)" )
106
+ end
107
+
108
+ def accept_types
109
+ "application/xhtml+xml,text/html,application/xml;q=0.9,text/*;q=0.8"
110
+ end
111
+
112
+ end
113
+
114
+ BARCRecorder.new.run
115
+ end
@@ -16,7 +16,7 @@
16
16
 
17
17
  module Iudex
18
18
  module BARC
19
- VERSION = '1.2.b.0'
19
+ VERSION = '1.2.b.1'
20
20
 
21
21
  LIB_DIR = File.dirname( __FILE__ ) # :nodoc:
22
22
  end
data/pom.xml CHANGED
@@ -5,7 +5,7 @@
5
5
  <groupId>iudex</groupId>
6
6
  <artifactId>iudex-barc</artifactId>
7
7
  <packaging>jar</packaging>
8
- <version>1.2.b.0</version>
8
+ <version>1.2.b.1</version>
9
9
  <name>Iudex Basic ARChive Format</name>
10
10
 
11
11
  <parent>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: iudex-barc
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 4
5
- version: 1.2.b.0
5
+ version: 1.2.b.1
6
6
  platform: java
7
7
  authors:
8
8
  - David Kellum
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-05 00:00:00 Z
13
+ date: 2012-06-01 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rjack-slf4j
@@ -88,7 +88,7 @@ files:
88
88
  - bin/iudex-http-record
89
89
  - lib/iudex-barc/base.rb
90
90
  - lib/iudex-barc.rb
91
- - lib/iudex-barc/iudex-barc-1.2.b.0.jar
91
+ - lib/iudex-barc/iudex-barc-1.2.b.1.jar
92
92
  homepage: http://github.com/dekellum/iudex
93
93
  licenses: []
94
94