tendersync 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.4 2008-08-25
2
+
3
+ * Fix bug in index generation
4
+ * Add option to override index permalink
5
+
1
6
  == 1.0.3 2009-08-20
2
7
 
3
8
  * Fixed problem pulling individual urls
@@ -134,10 +134,11 @@ class Tendersync::Document
134
134
  Dir.glob("#{section}/*").each { |f| yield Tendersync::Document.read_from_file(f) }
135
135
  end
136
136
 
137
- def self.index_for(section_id, section_name)
137
+ def self.index_for(section_id, section_name, permalink = nil)
138
+ permalink ||= "#{section_id}-table-of-contents"
138
139
  new(:section => section_id,
139
140
  :title => "#{section_name} Table of Contents",
140
- :permalink => "#{section_id}-table-of-contents",
141
+ :permalink => permalink,
141
142
  :keywords => "toc index")
142
143
  end
143
144
 
@@ -161,7 +162,7 @@ class Tendersync::Document
161
162
  private
162
163
 
163
164
  def create_toc(groups)
164
- groups += groups + [Group::Default] # array of groups
165
+ groups << Group::Default # array of groups
165
166
  link_root = {}
166
167
  self.class.each(section) do |document|
167
168
  next if document.permalink =~ /-table-of-contents$/
@@ -22,13 +22,13 @@ class Tendersync::Runner
22
22
  op.on( '--docurl', '=URL', String, "* tender site URL" ) { |dir| settings['docurl'] = dir }
23
23
  op.separator ""
24
24
  op.separator "Indexing Options:"
25
- op.on('-g', '--group', '=TITLE;regex', String, "*map of regex to group title for TOC groups") do | g |
25
+ op.on( '--group', '=TITLE;regex', String, "*map of regex to group title for TOC groups") do | g |
26
26
  pair = g.split(';')
27
27
  settings['groups'] << [pair.first, pair.last]
28
28
  end
29
- op.on('-d', '--depth', '=DEPTH', String, "*Number of levels to descend into a document being indexed") { | g | settings['depth'] = g.to_i }
30
-
31
-
29
+ op.on( '--name', '=PERMALINK', String, "override the default name of the index page") { |n| @index_name = n }
30
+ op.on( '--depth', '=DEPTH', String, "*Number of levels to descend into a document being indexed") { | g | settings['depth'] = g.to_i }
31
+
32
32
  %Q{
33
33
  * saved in .tendersync file for subsequent default
34
34
 
@@ -126,9 +126,11 @@ class Tendersync::Runner
126
126
  if @dry_run
127
127
  puts "would post #{document.section}/#{document.permalink} to tender."
128
128
  else
129
+ puts "uploading #{document.permalink}..."
129
130
  $session.post(document)
130
131
  end
131
132
  }
133
+ puts "...done"
132
134
  end
133
135
  alias push post
134
136
 
@@ -182,9 +184,9 @@ class Tendersync::Runner
182
184
  end
183
185
  section_details = $session.all_sections
184
186
  sections.each do |section|
185
- doc = Tendersync::Document.index_for section, section_details[section]
187
+ doc = Tendersync::Document.index_for(section, section_details[section], @index_name)
186
188
  puts "indexing #{section}: #{doc.section}/#{doc.permalink}"
187
- doc.refresh_index groups, settings['depth'] || 2
189
+ doc.refresh_index(groups, settings['depth'] || 1)
188
190
  doc.save
189
191
  end
190
192
  end
@@ -27,7 +27,11 @@ class Tendersync::Session
27
27
 
28
28
  def get(url)
29
29
  login
30
- page = @agent.get(url)
30
+ begin
31
+ page = @agent.get(url)
32
+ rescue WWW::Mechanize::ResponseCodeError => e
33
+ raise Tendersync::Runner::Error, "Unable to get #{url}"
34
+ end
31
35
  def page.links_like(r)
32
36
  result = []
33
37
  links.each { |l| result << l.href if l.href =~ r }
data/lib/tendersync.rb CHANGED
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Tendersync
5
- VERSION = '1.0.3'
5
+ VERSION = '1.0.4'
6
6
  end
data/tendersync.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tendersync}
5
- s.version = "1.0.3"
5
+ s.version = "1.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bill Kayser"]
9
- s.date = %q{2009-08-20}
9
+ s.date = %q{2009-08-26}
10
10
  s.default_executable = %q{tendersync}
11
11
  s.description = %q{Tendersync is a utility for syncing files from ENTP's Tender site for managing customer facing documentation. It can be used to pull and push documents to a local repository as well as create indexes for each documentation section.
12
12
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tendersync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Kayser
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-20 00:00:00 -07:00
12
+ date: 2009-08-26 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency