sunflower 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- Version: 0.4.2 alpha
1
+ Version: 0.4.3 alpha
2
2
 
3
3
  >>> English:
4
4
 
@@ -125,8 +125,8 @@ class Page
125
125
  name, anchor, _end = $1, $2, $3
126
126
 
127
127
  begin
128
- name=CGI.unescape(name)
129
- anchor=CGI.unescape((anchor||'').gsub(/\.([0-9A-F]{2})/,'%\1'))
128
+ name = name.gsub(/((?:%[0-9a-fA-F]{2})+)/){ [$1.delete('%')].pack('H*') }
129
+ anchor = (anchor||'').gsub(/\.([0-9A-F]{2})/, '%\1').gsub(/((?:%[0-9a-fA-F]{2})+)/){ [$1.delete('%')].pack('H*') }
130
130
  a='[['+name+anchor+(_end||'')
131
131
  a=a.gsub '_', ' '
132
132
  rescue
@@ -261,6 +261,6 @@ class Page
261
261
  def change_category from, to
262
262
  from=from.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
263
263
  to=to.sub(/\A\s*([cC]ategory|[kK]ategoria):/, '').strip
264
- self.text = self.text.gsub(/\[\[ *(?:[cC]ategory|[kK]ategoria) *: *#{Regexp.escape from} *(\|[^\]]+ *|)\]\]/){'[[Kategoria:'+to+$1.rstrip+']]'}
264
+ self.text = self.text.gsub(/\[\[ *(?:[cC]ategory|[kK]ategoria) *: *#{Regexp.escape from} *(\|[^\]]*|)\]\]/){'[[Kategoria:'+to+($1=='| ' ? $1 : $1.rstrip)+']]'}
265
265
  end
266
266
  end
@@ -19,7 +19,7 @@ class SunflowerError < StandardError; end
19
19
  #
20
20
  # You can use multiple Sunflowers at once, to work on multiple wikis.
21
21
  class Sunflower
22
- VERSION = '0.4.2'
22
+ VERSION = '0.4.3'
23
23
 
24
24
  INVALID_CHARS = %w(# < > [ ] | { })
25
25
  INVALID_CHARS_REGEX = Regexp.union *INVALID_CHARS
@@ -31,8 +31,13 @@ class Sunflower
31
31
 
32
32
  # Options for this Sunflower.
33
33
  attr_accessor :summary, :always_do_code_cleanup
34
+ attr_accessor :cookie, :headers, :wikiURL
34
35
 
35
- attr_accessor :cookie, :headers, :wikiURL, :warnings, :log
36
+ def is_bot?; @is_bot; end
37
+
38
+ attr_writer :warnings, :log
39
+ def warnings?; @warnings; end
40
+ def log?; @log; end
36
41
 
37
42
  # Initialize a new Sunflower working on a wiki with given URL, for ex. "pl.wikipedia.org".
38
43
  def initialize url=nil
@@ -141,11 +146,7 @@ class Sunflower
141
146
  end
142
147
 
143
148
  def log t
144
- File.open('log.txt','a'){|f| f.puts t}
145
- end
146
-
147
- def is_bot?
148
- @is_bot
149
+ File.open('log.txt','a'){|f| f.puts t} if @log
149
150
  end
150
151
  end
151
152
 
@@ -168,7 +169,10 @@ class Page
168
169
  attr_reader :sunflower
169
170
  alias :belongs_to :sunflower
170
171
 
172
+ # this is only for RDoc. wrapped in "if false" to avoid warnings when running with ruby -w
173
+ if false
171
174
  attr_reader :pageid, :ns, :title, :touched, :lastrevid, :counter, :length, :starttimestamp, :edittoken, :protection #prop=info
175
+ end
172
176
 
173
177
  # calling any of these accessors will fetch the data.
174
178
  [:pageid, :ns, :title, :touched, :lastrevid, :counter, :length, :starttimestamp, :edittoken, :protection].each do |meth|
@@ -253,20 +257,19 @@ class Page
253
257
  if !summary or summary==''
254
258
  summary = @summaryAppend.uniq.join(', ')
255
259
  else
256
- summary = summary.sub(/,\s*\Z/, '') + ', ' + @summaryAppend.uniq.join(', ')
260
+ summary = summary.sub(/,\s*\Z/, '') + ', ' + @summaryAppend.uniq.join(', ')
257
261
  end
258
262
  end
259
263
 
260
264
  if @orig_text==@text && title==@title
261
265
  @sunflower.log('Page '+title+' not saved - no changes.')
262
- return
266
+ return nil
263
267
  end
264
268
 
265
269
 
266
-
267
270
  self.code_cleanup if @sunflower.always_do_code_cleanup && self.respond_to?('code_cleanup')
268
271
 
269
- r=@sunflower.API("action=edit&bot=1&title=#{CGI.escape(title)}&text=#{CGI.escape(@text)}&summary=#{CGI.escape(summary)}&token=#{CGI.escape(@edittoken)}")# if @sunflower.isBot?
272
+ return @sunflower.API("action=edit&bot=1&title=#{CGI.escape(title)}&text=#{CGI.escape(@text)}&summary=#{CGI.escape(summary)}&token=#{CGI.escape(@edittoken)}")
270
273
  end
271
274
  alias :put :save
272
275
 
@@ -8,7 +8,7 @@ url = 'http://toolserver.org/~sk/cgi-bin/checkwiki/checkwiki.cgi?project=plwiki&
8
8
  print "Reading articles list... "
9
9
  # EDIT FILENAME BELOW
10
10
  str=Net::HTTP.get(URI.parse(url))
11
- list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.split(/\r?\n/).uniq
11
+ list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.gsub('&#039;', "'").split(/\r?\n/).uniq
12
12
  print "done (#{list.length} to do)!\n\n"
13
13
 
14
14
  # EDIT SUMMARY BELOW
@@ -8,7 +8,7 @@ url = 'http://toolserver.org/~sk/cgi-bin/checkwiki/checkwiki.cgi?project=plwiki&
8
8
  print "Reading articles list... "
9
9
  # EDIT FILENAME BELOW
10
10
  str=Net::HTTP.get(URI.parse(url))
11
- list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.split(/\r?\n/).uniq
11
+ list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.gsub('&#039;', "'").split(/\r?\n/).uniq
12
12
  print "done (#{list.length} to do)!\n\n"
13
13
 
14
14
  # EDIT SUMMARY BELOW
data/scripts/fix-langs.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'sunflower-commontasks.rb'
2
- require 'sunflower-listmaker.rb'
1
+ # coding: utf-8
2
+ require 'sunflower'
3
3
 
4
4
  # EDIT WIKI URL BELOW
5
5
  s=Sunflower.new('pl.wikipedia.org')
@@ -8,7 +8,7 @@ url = 'http://toolserver.org/~sk/cgi-bin/checkwiki/checkwiki.cgi?project=plwiki&
8
8
  print "Reading articles list... "
9
9
  # EDIT FILENAME BELOW
10
10
  str=Net::HTTP.get(URI.parse(url))
11
- list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.split(/\r?\n/).uniq
11
+ list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.gsub('&#039;', "'").split(/\r?\n/).uniq
12
12
  print "done (#{list.length} to do)!\n\n"
13
13
 
14
14
  # EDIT SUMMARY BELOW
@@ -8,7 +8,7 @@ url = 'http://toolserver.org/~sk/cgi-bin/checkwiki/checkwiki.cgi?project=plwiki&
8
8
  print "Reading articles list... "
9
9
  # EDIT FILENAME BELOW
10
10
  str=Net::HTTP.get(URI.parse(url))
11
- list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.split(/\r?\n/).uniq
11
+ list=str[(str.index('<pre>')+5)...(str.index('</pre>'))].strip.gsub('&#039;', "'").split(/\r?\n/).uniq
12
12
  print "done (#{list.length} to do)!\n\n"
13
13
 
14
14
  # EDIT SUMMARY BELOW
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunflower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-03 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &8801052 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *8801052
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rest-client
27
- requirement: &8800728 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *8800728
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Sunflower is a lightweight library to provide access to MediaWiki API
37
47
  from Ruby.
38
48
  email: matma.rex@gmail.com
@@ -85,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
95
  version: '0'
86
96
  requirements: []
87
97
  rubyforge_project:
88
- rubygems_version: 1.8.15
98
+ rubygems_version: 1.8.23
89
99
  signing_key:
90
100
  specification_version: 3
91
101
  summary: Sunflower is a lightweight library to provide access to MediaWiki API from