tendersync 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 1.0.7 2010-01-20
2
+
3
+ * Merged title option for create from Ross MacDonald
4
+ * Merged fix for mechanize problem from Ijonas Kisselbach
5
+
1
6
  == 1.0.6 2010-01-15
2
7
 
3
8
  * Merged some stuff from technoweenie
@@ -6,5 +6,5 @@ module Tendersync
6
6
  autoload :Runner, 'tendersync/runner'
7
7
  autoload :Session, 'tendersync/session'
8
8
 
9
- VERSION = '1.0.6'
9
+ VERSION = '1.0.7'
10
10
  end
@@ -41,8 +41,9 @@ class Tendersync::Runner
41
41
  post PATTERN -- post the matching documents to tender; use /regexp/ or glob
42
42
  irb -- drops you into IRB with a tender session & related classes (for hacking/
43
43
  one-time tasks). Programmers only.
44
- create PERMALINK -- create a new tender document with the specified permalink in the section
45
- specified by --section=... (must be only one.)
44
+ create PERMALINK [ title ]
45
+ -- create a new tender document with the specified permalink in the section
46
+ specified by --section=... (must be only one.)
46
47
 
47
48
  Version #{Tendersync::VERSION}
48
49
 
@@ -135,18 +136,23 @@ Version #{Tendersync::VERSION}
135
136
  alias push post
136
137
 
137
138
  def create
138
- raise Error, "You must specify exactly one section to put the document in." if sections.length != 1
139
- raise Error, "You must specify exactly one document permalink." if @args.length != 1
139
+ raise Error, "You must specify exactly one section to put the document in." if sections.length != 1
140
+ raise Error, "You must specify one document permalink." if @args.length == 0
140
141
  section,permalink = sections.first,@args.first
142
+ title = @args.last unless @args.length == 1#ignore the permalink and use default title
141
143
  filename = "#{@root}/#{section}/#{permalink}"
144
+ filename = "#{section}/#{permalink}" if @root.nil?
145
+ puts "Checking for : #{filename}..."
146
+ puts "Creating default body as file not found to parse out text." unless File.exist?(filename)
142
147
  text = File.read(filename) rescue ""
143
148
  text = "Put Text Here" if text.strip.empty?
144
149
  if $dry_run
145
150
  puts "would create document #{permalink}\nin #{section} as #{filename}"
146
151
  puts "\ntext:\n------------\n#{text}"
147
152
  else
148
- document = $session.create_document(section,permalink,text)
153
+ document = $session.create_document(section,permalink,text, title)
149
154
  document.save
155
+ puts "Uploaded file successfully."
150
156
  end
151
157
  end
152
158
 
@@ -211,4 +217,4 @@ Version #{Tendersync::VERSION}
211
217
  end
212
218
  @settings
213
219
  end
214
- end
220
+ end
@@ -60,22 +60,36 @@ class Tendersync::Session
60
60
  end
61
61
  sections
62
62
  end
63
-
63
+
64
+ def edit_form_for(section, edit_page)
65
+ edit_page.forms.each do |form|
66
+ document = Tendersync::Document.from_form(section,form)
67
+ return document unless document.document_id.nil?
68
+ end
69
+ end
64
70
  def pull_from_tender(*sections)
65
71
  sections = all_sections.keys if sections.empty?
66
72
  for section in sections do
67
73
  documents(section).collect do |doc_url|
68
- page =Tendersync::Document.from_form(section,edit_page_for(doc_url))
69
- puts "Section: #{section}, page=#{page.inspect}"
70
- doc = page.form_with(:action => /edit/)
74
+ edit_page = edit_page_for(doc_url)
75
+ doc = edit_form_for(section, edit_page)
71
76
  puts " #{doc.permalink}"
72
77
  doc.save unless $dry_run
73
78
  end
74
79
  end
75
80
  end
81
+
82
+ def get_section_id(section)
83
+ page = get("#{@site}/dashboard/sections/#{section}")
84
+ form = page.form_with(:action => "/dashboard/sections/#{section}")
85
+ form.form_node.to_s =~ /id="edit_section_(.*?)"/
86
+ $1
87
+ end
88
+
76
89
  # Print out a list of all documents
77
90
  def ls(*sections)
78
91
  sections = all_sections.keys if sections.empty?
92
+
79
93
  sections.each do | section |
80
94
  puts "Section #{section}"
81
95
  documents(section).map {|url| url =~ %r{/([^/]*)$} && $1 }.each do |link|
@@ -91,18 +105,24 @@ class Tendersync::Session
91
105
  document.to_form(form)
92
106
  form.submit unless $dry_run
93
107
  end
94
- def create_document(section,permalink,body)
108
+ def create_document(section,permalink,body, title)
95
109
  login
96
110
  form = get("#{@site}/faq/new").form_with(:action => "/faqs")
111
+
112
+ puts "Using default Title..." if title.nil?
113
+ title = "New Tendersync::Document" if title.nil?
97
114
  document = Tendersync::Document.new(
98
115
  :section => section,
99
- :title => "New Tendersync::Document",
116
+ :title => title,
100
117
  :permalink => permalink,
101
118
  :body => body
102
119
  )
103
120
  document.to_form(form)
104
121
  return if $dry_run
105
- form.radiobuttons_with(:value => Tender_id_for_section[section]).first.click
122
+
123
+ id = get_section_id(section)
124
+
125
+ form.radiobuttons_with(:value => id).first.click
106
126
  form.submit
107
127
  Tendersync::Document.from_form(section,edit_page_for("#{@site}/faqs/#{section}/#{permalink}").form_with(:action => /edit/))
108
128
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tendersync}
5
- s.version = "1.0.6"
5
+ s.version = "1.0.7"
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{2010-01-15}
9
+ s.date = %q{2010-01-20}
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.6
4
+ version: 1.0.7
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: 2010-01-15 00:00:00 -08:00
12
+ date: 2010-01-20 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency