elexis-wiki-interface 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2648db86e47b0f31d0000cc3a391a5e14f4d2961
4
- data.tar.gz: 7215cc7f784d1c6fae10de1415300714670ec7c0
3
+ metadata.gz: 019d50ea4aa4b5c071d1ed165465ee19cb9531aa
4
+ data.tar.gz: 9c2ed2aa44fb6b347fc3fbc5213e0ca7931a95f5
5
5
  SHA512:
6
- metadata.gz: 9cac2544523b57463976dd13a1852898eaf09fdc41a4ce3f1b4611a0be81258e75236c567b15aa5aaa757c391e2ef2594dd36cdc71719341e66d95ee8d56bdea
7
- data.tar.gz: eeb844354ed4a01a7f14b3a75e0d58d39ec74fd334201602fb09360503b683e6aa6ce14f171b96c9694418c58b9c41fab2b60faf717cac7972603ef837f76358
6
+ metadata.gz: 517b5b4354a1821127fab40a167a97497275cb0439140c2a5067b775544f4747647a1a84d0172a8028b119f9193c49f3a75f317c32caa36f4732a1d6f7338f35
7
+ data.tar.gz: 1b56dcf1ef10e695612db9df15a4042771dc47d2e8b355e5dfe0dc4dcdfe14f80baeaebf3b6aeb56fee9818d0309891262a138b86ecd8f3e7020d7e16b7454e9
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/version_tmp
16
16
  tmp
17
17
  vendor
18
18
  config
19
+ spec/run
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
 
7
7
  gem 'eclipse-plugin' # , :git => 'https://github.com/ngiger/eclipse-plugin'
8
+ # gem 'pry-nav'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elexis-wiki-interface (0.4.3)
4
+ elexis-wiki-interface (0.4.4)
5
5
  eclipse-plugin (>= 0.1)
6
6
  mediawiki-gateway
7
7
  rubyzip (< 1.0.0)
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.4.4 / 14.08.2015
2
+
3
+ * Check whether all features have an entry in the Matrix_3.0 page
4
+ * Create logical link inside a doc directory. This allows the mylyn preview to work
5
+ * Allow images without a directory in their name.
6
+
1
7
  === 0.4.3 / 07.08.2015
2
8
 
3
9
  * Use gem eclipse-plugin from rubygem not github
data/bin/wiki_pull_daily CHANGED
@@ -4,12 +4,12 @@ require 'elexis/wiki/interface/workspace'
4
4
 
5
5
  workspace = Elexis::Wiki::Interface::Workspace.new(Dir.pwd)
6
6
  workspace.pull
7
- workspace.show_missing(true)
8
7
  files = Dir.glob('doc_??') +
9
8
  Dir.glob('*/doc/*.mediawiki') +
10
9
  Dir.glob('*/doc/*.png')
11
10
  Dir.glob('*/doc/*.jpg')
12
11
  Dir.glob('*/doc/*.gif')
12
+ (Dir.glob("doc_??/*") + Dir.glob('*/doc/*')).each{|f| files << f if File.symlink?(f) }
13
13
  files.each{
14
14
  |file|
15
15
  if /:/.match(File.basename(file))
@@ -17,9 +17,12 @@ files.each{
17
17
  exit 2
18
18
  end
19
19
  }
20
- system("git add -f #{files.join(' ')}")
21
- system("git status")
22
- system("git commit --all -m '#{File.basename(__FILE__)}: #{Date.today.to_s} from #{workspace.wiki.sub(/api.php/i, '')}'")
23
- system("git status")
24
- system("git log -1")
25
- # system("git push")
20
+ if true
21
+ system("git add -f #{files.join(' ')}")
22
+ system("git status")
23
+ system("git commit --all -m '#{File.basename(__FILE__)}: #{Date.today.to_s} from #{workspace.wiki.sub(/api.php/i, '')}'")
24
+ system("git status")
25
+ system("git log -1")
26
+ # system("git push")
27
+ end
28
+ workspace.show_missing(true)
@@ -1,7 +1,7 @@
1
1
  module Elexis
2
2
  module Wiki
3
3
  module Interface
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
5
5
  end
6
6
  end
7
7
  end
@@ -15,7 +15,7 @@ module Elexis
15
15
  $ws_errors = []
16
16
 
17
17
  # All images under wiki.elexis.info must have images corresponding to the following scheme
18
- # directory: id of the plugin/feature (with feature.feature.group removed)
18
+ # directory (optional): id of the plugin/feature (with feature.feature.group removed)
19
19
  # imagename:
20
20
  # Therefore you find und http://wiki.elexis.info/index.php?title=Ch.elexis.connect.mythic&action=edit the line
21
21
  # [[Image:ch.elexis.connect.mythic_kabel.png|image]] [fig:kabel]
@@ -24,9 +24,9 @@ module Elexis
24
24
 
25
25
  def Interface.return_canonical_image_name(pagename, filename)
26
26
  pagename = pagename.sub('.feature.feature.group', '')
27
- short = File.basename(filename.clone.sub(ImagePrefix, ''))
27
+ short = File.basename(filename.downcase.sub(ImagePrefix, ''))
28
28
  short = short.split(':')[-1]
29
- return pagename + '/' + short
29
+ /[:\/]/.match(filename) ? pagename + '/' + short : short
30
30
  end
31
31
 
32
32
  def Interface.fix_image_locations(filename, pagename)
@@ -45,6 +45,9 @@ module Elexis
45
45
  newLines << line
46
46
  else
47
47
  new_name = Interface.return_canonical_image_name(pagename, m[2])
48
+ unless new_name.eql?(File.basename(new_name))
49
+ FileUtils.ln_s('.', File.dirname(new_name), :verbose => true) unless File.exists?(File.dirname(new_name))
50
+ end
48
51
  simpleName = File.join(dirName, File.basename(new_name))
49
52
  if files = Dir.glob(simpleName, File::FNM_CASEFOLD) and files.size == 1
50
53
  new_line = line.sub(m[2], new_name)
@@ -78,6 +81,12 @@ module Elexis
78
81
  @features_missing_documentation =[]
79
82
  end
80
83
  def show_missing(details = false)
84
+ puts
85
+ msg = "Show errors for #{@info.workspace_dir}"
86
+ puts "-" * msg.size
87
+ puts msg
88
+ puts "-" * msg.size
89
+
81
90
  if views_missing_documentation.size and
82
91
  plugins_missing_documentation.size == 0 and
83
92
  features_missing_documentation.size == 0 and
@@ -197,29 +206,34 @@ module Elexis
197
206
  end
198
207
 
199
208
  def pull
209
+ savedDir = Dir.pwd
200
210
  @doc_projects.each{
201
211
  |prj|
202
212
  dir = File.dirname(prj)
203
213
  get_content_from_wiki(dir, File.basename(dir))
204
214
  remove_image_files_with_id(File.basename(File.dirname(prj)), info, dir)
205
- }
215
+ } # unless defined?(RSpec)
206
216
 
207
217
  @info.plugins.each{
208
218
  |id, info|
219
+ # next if not defined?(RSpec) and not /ehc|icp/i.match(id)
209
220
  puts "Pulling for plugin #{id}" if $VERBOSE
210
221
  pull_docs_views(info)
211
222
  pull_docs_plugins(info)
212
223
  pull_docs_perspectives(info)
213
224
  remove_image_files_with_id(id, info)
214
225
  }
226
+
215
227
  @info.features.each{
216
228
  |id, info|
217
- # next unless /icpc/i.match(id)
229
+ # next if not defined?(RSpec) and not /ehc|icp/i.match(id)
218
230
  puts "Pulling for feature #{id}" if $VERBOSE
231
+ check_page_in_matrix(id)
219
232
  pull_docs_features(info)
220
233
  remove_image_files_with_id(id, info)
221
234
  }
222
- saved = Dir.pwd
235
+
236
+ Dir.chdir(savedDir)
223
237
  end
224
238
 
225
239
  def perspectiveToPageName(perspective)
@@ -240,6 +254,13 @@ module Elexis
240
254
  pageName
241
255
  end
242
256
 
257
+ def check_page_in_matrix(pagename, matrix_name = 'Matrix_3.0')
258
+ puts Dir.pwd
259
+ res = get_content_from_wiki('.', matrix_name)
260
+ return true if res.index("[[#{pagename}]]") or res.index("[[#{pagename}.feature.group]]")
261
+ $ws_errors << "#{matrix_name}: could not find #{pagename}"
262
+ end
263
+
243
264
  private
244
265
  def wiki_json_timestamp_to_time(json, page_or_img)
245
266
  return nil unless json
@@ -294,9 +315,17 @@ module Elexis
294
315
  end
295
316
  end
296
317
  if image_url
297
- File.open(downloaded_image, 'w') do |file|
298
- file.write(open(image_url).read)
299
- end
318
+ m = /#{downloaded_image}/i.match(image_url)
319
+ # downloaded_image = m[0] if m # Sometimes the filename is capitalized
320
+ File.open(downloaded_image, 'w') do |file|
321
+ file.write(open(image_url).read)
322
+ end
323
+ files = Dir.glob(downloaded_image, File::FNM_CASEFOLD)
324
+ files.each{
325
+ |file|
326
+ next if file.eql?(downloaded_image)
327
+ FileUtils.rm_f(file, :verbose => true)
328
+ }
300
329
  else
301
330
  puts "skipping image #{image} for page #{pageName}"
302
331
  end
@@ -313,6 +342,7 @@ module Elexis
313
342
  puts "get_content_from_wiki page #{pageName} -> #{out_dir}" if $VERBOSE
314
343
  out_name = File.join(out_dir, pageName + '.mediawiki')
315
344
  FileUtils.makedirs(out_dir) unless File.directory?(out_dir)
345
+ savedDir = Dir.pwd
316
346
  Dir.chdir(out_dir)
317
347
  begin
318
348
  content = @mw.get(pageName)
@@ -325,12 +355,13 @@ module Elexis
325
355
  @mw.images(pageName).each{
326
356
  |image|
327
357
  download_image_file(pageName, image.gsub(' ', '_'))
328
- break if defined?(RSpec) and not /icpc/i.match(pageName) # speed up RSpec
358
+ break if defined?(RSpec) and not /icpc|ehc/i.match(pageName) # speed up RSpec
329
359
  }
330
360
  Elexis::Wiki::Interface.fix_image_locations(out_name, pageName)
331
361
  else
332
362
  puts "Could not fetch #{pageName} from #{@mw}" if $VERBOSE
333
363
  end
364
+ Dir.chdir(savedDir)
334
365
  content
335
366
  end
336
367
  def pull_docs_views(plugin)
@@ -0,0 +1,2 @@
1
+ # Allow
2
+ !*.png
@@ -12,3 +12,4 @@ tag_five [[Datei:Ch.elexis.icpc:icpc5.png|image]]<br />
12
12
 
13
13
 
14
14
 
15
+
data/spec/pull_spec.rb CHANGED
@@ -12,45 +12,40 @@ describe 'Plugin' do
12
12
  end
13
13
  before :all do
14
14
  @dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'pull'))
15
+ @workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
16
+ @workspace.pull
15
17
  end
16
18
 
17
- before :each do
18
- remove_all_mediawiki
19
- end
20
-
21
- after :each do
19
+ after :all do
22
20
  remove_all_mediawiki
23
21
  end
24
22
 
25
23
  it "should pull doc.de ch.elexis.core.ui" do
26
24
  # TODO: Handle http://wiki.elexis.info/Doc_de
27
25
  # TODO: http://wiki.elexis.info/Doc_de
28
- # Nach elexis-3-base?
29
- # @dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'doc'))
30
- workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
31
- workspace.pull
32
26
  search = "#{@dataDir}/?oc_??/*.mediawiki"
33
27
  mediawikis = Dir.glob(search)
34
28
  expect(mediawikis.size).to eq 1
35
29
  end
36
30
 
31
+ it "should pull views" do
32
+ expect(@workspace.info.views.size).to eq 9
33
+ expect(@workspace.views_missing_documentation.size).to be <= 9
34
+ end
35
+
37
36
  it "should pull all mediawiki content for ch.elexis.core.ui" do
38
37
  # TODO: http://wiki.elexis.info/Ch.elexis.core.ui.feature.feature.group
39
- workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
40
- workspace.pull
41
- workspace.info.show
42
- expect(workspace.info.views.size).to eq 9
43
- expect(workspace.info.preferencePages.size).to eq 8
44
- expect(workspace.info.perspectives.size).to eq 2
45
- expect(workspace.info.plugins.size).to eq 3
46
- expect(workspace.info.features.size).to eq 1
38
+ @workspace.info.show
39
+ expect(@workspace.info.preferencePages.size).to eq 8
40
+ expect(@workspace.info.perspectives.size).to eq 2
41
+ expect(@workspace.info.plugins.size).to eq 3
42
+ expect(@workspace.info.features.size).to eq 1
47
43
  search = "#{@dataDir}/**/*.mediawiki"
48
44
  mediawikis = Dir.glob(search)
49
45
  expect(mediawikis.size).to be > 1
50
- workspace.show_missing(true)
51
- expect(workspace.views_missing_documentation.size).to be <= 9
52
- expect(workspace.plugins_missing_documentation.size).to eq 0
53
- expect(workspace.perspectives_missing_documentation.size).to be <= 1
46
+ @workspace.show_missing(true)
47
+ expect(@workspace.plugins_missing_documentation.size).to eq 0
48
+ expect(@workspace.perspectives_missing_documentation.size).to be <= 1
54
49
  if $VERBOSE
55
50
  search = "#{@dataDir}/**/*.mediawiki"
56
51
  wiki_files = Dir.glob(search)
@@ -65,6 +60,9 @@ describe 'Plugin' do
65
60
 
66
61
  name = File.join(@dataDir, "ch.elexis.notes", "doc", "Ch.elexis.notes.mediawiki")
67
62
  expect(Dir.glob(name).size).to eq 1
63
+ end
64
+
65
+ it "should pull everything for DOC_DE" do
68
66
  search = "#{@dataDir}/**/doc/*.png"
69
67
  images = Dir.glob(search)
70
68
  images.each{
@@ -72,8 +70,10 @@ describe 'Plugin' do
72
70
  expect(/:/.match(img)).to be_nil
73
71
  }
74
72
  expect(images.size).to be >= 1
75
- expect(workspace.features_missing_documentation.size).to eq 0
73
+ expect(@workspace.features_missing_documentation.size).to eq 0
74
+ end
76
75
 
76
+ it "should pull everything for ICPC" do
77
77
  name = File.join(@dataDir, "ch.elexis.icpc", "doc", "P_ICPC.mediawiki")
78
78
  expect(Dir.glob(name).size).to eq 1
79
79
  name = File.join(@dataDir, "ch.elexis.icpc", "doc", "ChElexisIcpcViewsEpisodesview.mediawiki")
@@ -83,13 +83,23 @@ describe 'Plugin' do
83
83
  content = IO.read(name)
84
84
  m = /(Image:[\w\.]+)[:_](\w+.png)/.match(content)
85
85
  expect(m).to eq nil
86
- m = /(Image:[\w\.]+)\/(\w+.png)/.match(content)
86
+ m = /(Image:[\w\.]+)\/(icpc0.png)/i.match(content)
87
87
  expect(m[0]).to eq 'Image:Ch.elexis.icpc/icpc0.png'
88
88
  end
89
89
 
90
90
  it "should show all users" do
91
- workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
92
- puts "We have #{workspace.mw.users.size} wiki users"
91
+ @workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
92
+ puts "We have #{@workspace.mw.users.size} wiki users"
93
+ end unless ENV['TRAVIS']
94
+
95
+ it "should check the matrix" do
96
+ @workspace.info.show
97
+ $ws_errors = []
98
+ @workspace.check_page_in_matrix('ch.elexis.notes.feature.feature.group')
99
+ expect($ws_errors.size).to eq 0
100
+ $ws_errors = []
101
+ @workspace.check_page_in_matrix('xxxxxxxxx')
102
+ expect($ws_errors.size).to eq 1
93
103
  end
94
104
 
95
105
  end
@@ -42,7 +42,7 @@ describe 'ImageHandling' do
42
42
  }
43
43
  end
44
44
 
45
- it "should adapt correctly the image name" do
45
+ it "should adapt correctly the image name being in in #{Dir.pwd}" do
46
46
  wiki_file = File.join(@dataDir, 'ch.elexis.icpc', 'doc', 'test.mediawiki')
47
47
  expect(File.exists?(wiki_file)).to eq true
48
48
  before = ['tag_one [[Image:ch.elexis.icpc:icpc1.png|image]]',
@@ -53,19 +53,33 @@ describe 'ImageHandling' do
53
53
  ]
54
54
  original = IO.read(wiki_file)
55
55
  before.each{|string| expect(original).to include string }
56
- puts Dir.pwd
56
+ end
57
+
58
+ it "should adapt correctly the image name being in #{@dataDir}" do
59
+ wiki_file = File.join(@dataDir, 'ch.elexis.icpc', 'doc', 'test.mediawiki')
57
60
  Dir.chdir(@dataDir)
58
- puts Dir.pwd
59
61
 
60
62
  Elexis::Wiki::Interface.fix_image_locations(wiki_file, 'ch.elexis.icpc')
61
63
  after =['tag_one [[Image:ch.elexis.icpc/icpc1.png|image]]',
62
64
  'tag_two [[Image:ch.elexis.icpc/icpc2.png|image]]',
63
- 'tag_three [[Image:ch.elexis.icpc/icpc3.png|image]]',
65
+ 'tag_three [[Image:icpc3.png|image]]',
64
66
  'tag_four [[Datei:ch.elexis.icpc/icpc4.png|image]]',
65
67
  'tag_five [[Datei:ch.elexis.icpc/icpc5.png|image]]',
66
68
  ]
67
69
  changed = IO.read(wiki_file)
68
70
  after.each{|string| expect(changed).to include string }
69
71
  end
72
+
73
+ it "should adapt allow the image names without an ID" do
74
+ wiki_file = File.join(@dataDir, 'ch.elexis.icpc', 'doc', 'test.mediawiki')
75
+ Dir.chdir(@dataDir)
76
+
77
+ Elexis::Wiki::Interface.fix_image_locations(wiki_file, 'ch.elexis.icpc')
78
+ after =['tag_three [[Image:icpc3.png|image]]',
79
+ ]
80
+ changed = IO.read(wiki_file)
81
+ after.each{|string| expect(changed).to include string }
82
+ end
83
+
70
84
  end
71
85
 
data/spec/user_spec.rb ADDED
@@ -0,0 +1,32 @@
1
+ #encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ require 'elexis/wiki/interface'
5
+ require "elexis/wiki/interface/workspace"
6
+ describe 'Plugin' do
7
+
8
+ def remove_all_mediawikii
9
+ files2rm = Dir.glob("#{@dataDir}/**/*.mediawiki") + Dir.glob("#{@dataDir}/**/*.png")
10
+ FileUtils.rm(files2rm, :verbose => $VERBOSE) if files2rm.size > 0
11
+ end
12
+ before :all do
13
+ @dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'pull'))
14
+ end
15
+
16
+ before :each do
17
+ remove_all_mediawikii
18
+ end
19
+
20
+ after :each do
21
+ remove_all_mediawikii
22
+ end
23
+
24
+ it "should show all users" do
25
+ workspace = Elexis::Wiki::Interface::Workspace.new(@dataDir)
26
+ wiki_users = workspace.mw.users
27
+ puts "We have #{wiki_users.size} wiki users"
28
+ expect wiki_users.size <= 50
29
+ contribs = workspace.mw.contributions(wiki_users.first)
30
+ end
31
+
32
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elexis-wiki-interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklaus Giger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -147,6 +147,7 @@ files:
147
147
  - lib/elexis/wiki/interface.rb
148
148
  - lib/elexis/wiki/interface/version.rb
149
149
  - lib/elexis/wiki/interface/workspace.rb
150
+ - spec/data/.gitignore
150
151
  - spec/data/doc/doc_de/.project
151
152
  - spec/data/pull/ch.elexis.agenda/.project
152
153
  - spec/data/pull/ch.elexis.agenda/META-INF/MANIFEST.MF
@@ -189,6 +190,7 @@ files:
189
190
  - spec/run/push/ch.elexis.icpc/doc/icpc5.png
190
191
  - spec/spec_helper.rb
191
192
  - spec/update_images_spec.rb
193
+ - spec/user_spec.rb
192
194
  homepage: http://wiki.elexis.info
193
195
  licenses:
194
196
  - GPLv3
@@ -214,6 +216,7 @@ signing_key:
214
216
  specification_version: 4
215
217
  summary: Interface between elexis source and wiki
216
218
  test_files:
219
+ - spec/data/.gitignore
217
220
  - spec/data/doc/doc_de/.project
218
221
  - spec/data/pull/ch.elexis.agenda/.project
219
222
  - spec/data/pull/ch.elexis.agenda/META-INF/MANIFEST.MF
@@ -256,3 +259,4 @@ test_files:
256
259
  - spec/run/push/ch.elexis.icpc/doc/icpc5.png
257
260
  - spec/spec_helper.rb
258
261
  - spec/update_images_spec.rb
262
+ - spec/user_spec.rb