elexis-wiki-interface 0.4.8 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +25 -1
  4. data/README.textile +2 -3
  5. data/bin/wiki_pull +6 -3
  6. data/bin/wiki_pull_and_commit +38 -0
  7. data/bin/wiki_push +2 -2
  8. data/elexis-wiki-interface.gemspec +4 -3
  9. data/history.textile +14 -0
  10. data/lib/elexis/wiki/images.rb +338 -0
  11. data/lib/elexis/wiki/interface.rb +152 -2
  12. data/lib/elexis/wiki/version.rb +5 -0
  13. data/lib/elexis/wiki/workspace.rb +286 -0
  14. data/spec/data/images/ch.elexis.agenda/.project +36 -0
  15. data/spec/data/images/ch.elexis.agenda/META-INF/MANIFEST.MF +33 -0
  16. data/spec/data/images/ch.elexis.agenda/doc/fixmedikationaufruf.png +0 -0
  17. data/spec/data/images/ch.elexis.agenda/plugin.properties +8 -0
  18. data/spec/data/images/ch.elexis.agenda/plugin.xml +209 -0
  19. data/spec/data/images/ch.elexis.agenda/plugin_de.properties +8 -0
  20. data/spec/data/images/ch.elexis.agenda/plugin_en.properties +8 -0
  21. data/spec/data/images/ch.elexis.agenda/plugin_fr.properties +7 -0
  22. data/spec/data/images/ch.elexis.core.application.feature/.project +23 -0
  23. data/spec/data/images/ch.elexis.core.application.feature/build.properties +1 -0
  24. data/spec/data/images/ch.elexis.core.application.feature/feature.xml +699 -0
  25. data/spec/data/images/ch.elexis.core.application.feature/pom.xml +12 -0
  26. data/spec/data/images/ch.elexis.icpc/.project +28 -0
  27. data/spec/data/images/ch.elexis.icpc/META-INF/MANIFEST.MF +26 -0
  28. data/spec/data/images/ch.elexis.icpc/doc/Com.hilotec.elexis.opendocument_anleitung_opendocument_1.png +0 -0
  29. data/spec/data/images/ch.elexis.icpc/doc/FixmedikationAufruf.png +0 -0
  30. data/spec/data/images/ch.elexis.icpc/doc/Icpc8.png +0 -0
  31. data/spec/data/images/ch.elexis.icpc/doc/ch.elexis.icpc_icpc1.png +0 -0
  32. data/spec/data/images/ch.elexis.icpc/doc/disposan.gif +0 -0
  33. data/spec/data/images/ch.elexis.icpc/doc/elexis_logo.jpg +0 -0
  34. data/spec/data/images/ch.elexis.icpc/doc/favicon_green.png +0 -0
  35. data/spec/data/images/ch.elexis.icpc/doc/icpc0.png +0 -0
  36. data/spec/data/images/ch.elexis.icpc/doc/icpc1.png +0 -0
  37. data/spec/data/images/ch.elexis.icpc/doc/icpc2.png +0 -0
  38. data/spec/data/images/ch.elexis.icpc/doc/icpc3.png +0 -0
  39. data/spec/data/images/ch.elexis.icpc/doc/icpc4.png +0 -0
  40. data/spec/data/images/ch.elexis.icpc/doc/icpc5.png +0 -0
  41. data/spec/data/images/ch.elexis.icpc/doc/icpc6.png +0 -0
  42. data/spec/data/images/ch.elexis.icpc/doc/icpc7.png +0 -0
  43. data/spec/data/images/ch.elexis.icpc/doc/icpc9.png +0 -0
  44. data/spec/data/images/ch.elexis.icpc/doc/kabel.png +0 -0
  45. data/spec/data/images/ch.elexis.icpc/doc/medevit_inbox1.png +0 -0
  46. data/spec/data/images/ch.elexis.icpc/doc/test.mediawiki +15 -0
  47. data/spec/data/images/ch.elexis.icpc/doc/test2.mediawiki +19 -0
  48. data/spec/data/images/ch.elexis.icpc/plugin.xml +74 -0
  49. data/spec/data/images/ch.elexis.notes/.project +34 -0
  50. data/spec/data/images/ch.elexis.notes/META-INF/MANIFEST.MF +17 -0
  51. data/spec/data/images/ch.elexis.notes/doc/At.medevit.medelexis.text.msword:WordBriefe.png +0 -0
  52. data/spec/data/images/ch.elexis.notes/doc/Ch.medelexis.openoffice:TextverarbeitungSettings.png +0 -0
  53. data/spec/data/images/ch.elexis.notes/doc/Icpc1.png +0 -0
  54. data/spec/data/images/ch.elexis.notes/doc/kabel.png +0 -0
  55. data/spec/data/images/ch.elexis.notes/doc/medidirect:use2.png +0 -0
  56. data/spec/data/images/ch.elexis.notes/doc/test.mediawiki +13 -0
  57. data/spec/data/images/ch.elexis.notes/plugin.properties +1 -0
  58. data/spec/data/images/ch.elexis.notes/plugin.xml +36 -0
  59. data/spec/data/images/ch.elexis.notes/plugin_de.properties +3 -0
  60. data/spec/data/images/ch.elexis.notes/plugin_en.properties +3 -0
  61. data/spec/data/images/ch.elexis.notes/plugin_fr.properties +3 -0
  62. data/spec/data/images/doc_de/.project +42 -0
  63. data/spec/data/images/elexis_api_test.png +0 -0
  64. data/spec/data/push/elexis_api_test.png +0 -0
  65. data/spec/images_spec.rb +236 -0
  66. data/spec/interface_spec.rb +118 -0
  67. data/spec/pull_spec.rb +16 -5
  68. metadata +128 -13
  69. data/History.txt +0 -41
  70. data/bin/wiki_pull_daily +0 -28
  71. data/lib/elexis/wiki/interface/version.rb +0 -7
  72. data/lib/elexis/wiki/interface/workspace.rb +0 -404
  73. data/spec/push_spec.rb +0 -31
  74. data/spec/update_images_spec.rb +0 -95
  75. data/spec/user_spec.rb +0 -32
@@ -0,0 +1,12 @@
1
+ <project xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd' xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
2
+ <modelVersion> 4.0.0 </modelVersion>
3
+ <parent>
4
+ <groupId> ch.elexis </groupId>
5
+ <artifactId> elexis-3-core </artifactId>
6
+ <version>3.0.0-SNAPSHOT</version>
7
+ </parent>
8
+ <groupId> ch.elexis </groupId>
9
+ <artifactId> ch.elexis.core.application.feature </artifactId>
10
+ <version>3.0.0-SNAPSHOT</version>
11
+ <packaging> eclipse-feature </packaging>
12
+ </project>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>ch.elexis.icpc</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.pde.ManifestBuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ <buildCommand>
19
+ <name>org.eclipse.pde.SchemaBuilder</name>
20
+ <arguments>
21
+ </arguments>
22
+ </buildCommand>
23
+ </buildSpec>
24
+ <natures>
25
+ <nature>org.eclipse.pde.PluginNature</nature>
26
+ <nature>org.eclipse.jdt.core.javanature</nature>
27
+ </natures>
28
+ </projectDescription>
@@ -0,0 +1,26 @@
1
+ Manifest-Version: 1.0
2
+ Bundle-ManifestVersion: 2
3
+ Bundle-Name: Elexis Plugin für ICPC 2
4
+ Bundle-SymbolicName: ch.elexis.icpc;singleton:=true
5
+ Bundle-Version: 3.0.0.qualifier
6
+ Bundle-Vendor: elexis.ch
7
+ Bundle-Localization: plugin
8
+ Require-Bundle: ch.elexis.core;bundle-version="3.0.0",
9
+ ch.elexis.core.data;bundle-version="3.0.0",
10
+ ch.elexis.core.ui;bundle-version="3.0.0",
11
+ ch.elexis.core.ui.icons;bundle-version="3.0.0",
12
+ ch.elexis.core.ui.importer.div;bundle-version="3.0.0",
13
+ ch.rgw.utility,
14
+ org.eclipse.core.runtime,
15
+ org.eclipse.ui,
16
+ org.eclipse.ui.forms,
17
+ com.healthmarketscience.jackcess,
18
+ ch.elexis.core.ui.medication,
19
+ ch.elexis.core.ui.laboratory,
20
+ ch.elexis.core.ui.contacts
21
+ Eclipse-LazyStart: false
22
+ Bundle-Activator: ch.elexis.icpc.Activator
23
+ Export-Package: ch.elexis.icpc; uses:="org.eclipse.core.runtime, ch.rgw.tools, ch.elexis.actions, ch.elexis.util, ch.elexis.data, ch.elexis.views.codesystems, ch.elexis.icpc.views, org.eclipse.ui, org.eclipse.swt.custom, org.eclipse.ui.plugin, org.eclipse.ui.forms.widgets, org.eclipse.osgi.util, ch.elexis.text, ch.elexis.views, ch.elexis.util.viewers, org.eclipse.jface.viewers, org.osgi.framework, org.eclipse.swt.widgets"
24
+ Created-By: Buildr
25
+ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
26
+
@@ -0,0 +1,15 @@
1
+ == Test ==
2
+
3
+ Bitte ignorieren. Wird für Tests verwendet.
4
+
5
+ == Ein Problem in einer Konsultation behandeln ==
6
+
7
+ tag_one [[Image:ch.elexis.icpc:icpc1.png|image]]<br />
8
+ tag_two [[Image:ch.elexis.icpc:icpc2.png|image]]<br />
9
+ tag_three [[Image:icpc3.png|image]]<br />
10
+ tag_four [[Datei:ch.elexis.icpc:icpc4.png|image]]<br />
11
+ tag_five [[Datei:Ch.elexis.icpc:icpc5.png|image]]<br />
12
+
13
+
14
+
15
+
@@ -0,0 +1,19 @@
1
+ == Test ==
2
+
3
+ Bitte ignorieren. Wird für Tests verwendet.
4
+
5
+ == Ein Problem in einer Konsultation behandeln ==
6
+
7
+ tag_one [[Image:ch.elexis.icpc:icpc1.png|image]]<br />
8
+ tag_two [[Image:ch.elexis.icpc:icpc2.png|image]]<br />
9
+ tag_three [[Image:icpc3.png|image]]<br />
10
+ tag_four [[Datei:ch.elexis.icpc:icpc4.png|image]]<br />
11
+ tag_png [[Datei:Ch.elexis.icpc:icpc5.png|image]]<br />
12
+ tag_jpg [[Datei:Ch.elexis.icpc:icpc6.png|image]]<br />
13
+ tag_gif [[Datei:Ch.elexis.icpc:icpc7.png|image]]<br />
14
+ tag_utf [[File:curabillsettings.png<U+200E>]]
15
+
16
+
17
+
18
+
19
+
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <?eclipse version="3.1"?>
3
+ <plugin>
4
+ <extension
5
+ point="ch.elexis.core.ui.Diagnosecode">
6
+ <Diagnosesystem
7
+ CodeDetailDisplay="ch.elexis.icpc.DetailDisplay"
8
+ CodeSelectorFactory="ch.elexis.icpc.CodeSelectorFactory"
9
+ ElementFactory="ch.elexis.icpc.IcpcFactory"
10
+ ImporterClass="ch.elexis.icpc.IcpcImporter"
11
+ name="ICPC2"/>
12
+ </extension>
13
+ <extension
14
+ point="ch.elexis.core.data.PersistentReference">
15
+ <Factory
16
+ Class="ch.elexis.icpc.IcpcFactory"
17
+ name="IcpcFactory"/>
18
+ </extension>
19
+ <extension
20
+ point="ch.elexis.core.data.DataAccess">
21
+ <DataAccess
22
+ class="ch.elexis.icpc.DataAccessor"
23
+ name="ICPC">
24
+ </DataAccess>
25
+ </extension>
26
+ <extension
27
+ point="org.eclipse.ui.views">
28
+ <category
29
+ id="ch.elexis.icpcCategory"
30
+ name="ICPC"/>
31
+ <view
32
+ category="ch.elexis.icpcCategory"
33
+ class="ch.elexis.icpc.views.EpisodesView"
34
+ icon="icons/wonca16.png"
35
+ id="ch.elexis.icpc.episodesView"
36
+ name="Probleme"/>
37
+ <view
38
+ category="ch.elexis.icpcCategory"
39
+ class="ch.elexis.icpc.views.EncounterView"
40
+ icon="icons/wonca16.png"
41
+ id="ch.elexis.icpc.encounterView"
42
+ name="Encounters"/>
43
+ <view
44
+ allowMultiple="false"
45
+ category="ch.elexis.icpcCategory"
46
+ class="ch.elexis.icpc.views.ICPCCodesView"
47
+ icon="icons/wonca16.png"
48
+ id="ch.elexis.icpc.codesView"
49
+ name="ICPC2-Codes">
50
+ </view>
51
+ </extension>
52
+ <extension
53
+ point="org.eclipse.ui.perspectives">
54
+ <perspective
55
+ class="ch.elexis.icpc.views.IcpcPerspektive"
56
+ fixed="false"
57
+ icon="icons/wonca16.png"
58
+ id="ch.elexis.icpc.perspective"
59
+ name="ICPC "/>
60
+ </extension>
61
+ <extension
62
+ point="ch.elexis.core.ui.KonsExtension">
63
+ <Link
64
+ KonsExtension="ch.elexis.icpc.KonsExtension"
65
+ name="ICPC"/>
66
+ </extension>
67
+ <extension
68
+ point="ch.elexis.core.ui.Sidebar">
69
+ <Perspektive
70
+ ID="ch.elexis.icpc.perspective"
71
+ name="ICPC-2"/>
72
+ </extension>
73
+
74
+ </plugin>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>ch.elexis.notes</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>net.sourceforge.texlipse.builder.TexlipseBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.jdt.core.javabuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ <buildCommand>
19
+ <name>org.eclipse.pde.ManifestBuilder</name>
20
+ <arguments>
21
+ </arguments>
22
+ </buildCommand>
23
+ <buildCommand>
24
+ <name>org.eclipse.pde.SchemaBuilder</name>
25
+ <arguments>
26
+ </arguments>
27
+ </buildCommand>
28
+ </buildSpec>
29
+ <natures>
30
+ <nature>net.sourceforge.texlipse.builder.TexlipseNature</nature>
31
+ <nature>org.eclipse.pde.PluginNature</nature>
32
+ <nature>org.eclipse.jdt.core.javanature</nature>
33
+ </natures>
34
+ </projectDescription>
@@ -0,0 +1,17 @@
1
+ Manifest-Version: 1.0
2
+ Bundle-ManifestVersion: 2
3
+ Bundle-Name: Elexis Notizbuch
4
+ Bundle-SymbolicName: ch.elexis.notes;singleton:=true
5
+ Bundle-Version: 3.0.0.qualifier
6
+ Bundle-Vendor: elexis.info
7
+ Bundle-Localization: plugin
8
+ Require-Bundle: org.eclipse.ui,
9
+ org.eclipse.ui.forms,
10
+ org.eclipse.core.runtime,
11
+ ch.rgw.utility;bundle-version="3.0.0",
12
+ ch.elexis.core;bundle-version="3.0.0",
13
+ ch.elexis.core.data;bundle-version="3.0.0",
14
+ ch.elexis.core.ui;bundle-version="3.0.0",
15
+ ch.elexis.core.ui.icons;bundle-version="3.0.0",
16
+ org.jdom;bundle-version="1.1.0"
17
+ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
@@ -0,0 +1,13 @@
1
+ == Test ==
2
+
3
+ Bitte ignorieren. Wird für Tests verwendet.
4
+
5
+ == Ein Problem in einer Konsultation behandeln ==
6
+
7
+ tag_one [[Image:kabel.png|image]]<br />
8
+ tag_two[[Image:icpc1.png|image]]<br />
9
+ tag_word [[Image:at.medevit.medelexis.text.msword:WordBriefe.png|Microsoft Word Integration in Elexis]]<br />
10
+
11
+
12
+
13
+
@@ -0,0 +1 @@
1
+ notes = Notes
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <?eclipse version="3.2"?>
3
+ <plugin>
4
+ <extension
5
+ point="org.eclipse.ui.perspectives">
6
+ <perspective
7
+ class="ch.elexis.notes.NotesPerspective"
8
+ icon="icons/notebook.gif"
9
+ id="ch.elexis.SchwarzesBrett"
10
+ name="%notes"/>
11
+ </extension>
12
+
13
+ <extension
14
+ point="org.eclipse.ui.views">
15
+ <view
16
+ class="ch.elexis.notes.NotesView"
17
+ icon="icons/notebook.gif"
18
+ id="ch.elexis.notes.view"
19
+ name="%notes"/>
20
+ </extension>
21
+ <extension
22
+ point="ch.elexis.core.data.PersistentReference">
23
+ <Factory
24
+ Class="ch.elexis.notes.NoteFactory"
25
+ name="NotesFactory"/>
26
+ </extension>
27
+ <extension
28
+ point="org.eclipse.ui.preferencePages">
29
+ <page
30
+ class="ch.elexis.notes.Preferences"
31
+ id="Preferences"
32
+ name="%notes">
33
+ </page>
34
+ </extension>
35
+
36
+ </plugin>
@@ -0,0 +1,3 @@
1
+ #Created by JInto - www.guh-software.de
2
+ #Wed Jul 07 09:21:15 CEST 2010
3
+ notes=Notizen
@@ -0,0 +1,3 @@
1
+ #Created by JInto - www.guh-software.de
2
+ #Wed Jul 07 08:06:32 CEST 2010
3
+ notes=Notes
@@ -0,0 +1,3 @@
1
+ #Created by JInto - www.guh-software.de
2
+ #Wed Jul 07 08:06:32 CEST 2010
3
+ notes=Notes
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>doc_de</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>net.sourceforge.texlipse.builder.TexlipseBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.jdt.core.javabuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ <buildCommand>
19
+ <name>org.eclipse.pde.ManifestBuilder</name>
20
+ <arguments>
21
+ </arguments>
22
+ </buildCommand>
23
+ <buildCommand>
24
+ <name>org.eclipse.pde.SchemaBuilder</name>
25
+ <arguments>
26
+ </arguments>
27
+ </buildCommand>
28
+ <buildCommand>
29
+ <name>org.zeroturnaround.eclipse.rebelXmlBuilder</name>
30
+ <arguments>
31
+ </arguments>
32
+ </buildCommand>
33
+ </buildSpec>
34
+ <natures>
35
+ <nature>net.sourceforge.texlipse.builder.TexlipseNature</nature>
36
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
37
+ <nature>org.eclipse.pde.PluginNature</nature>
38
+ <nature>org.eclipse.jdt.core.javanature</nature>
39
+ <nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
40
+ <nature>org.zeroturnaround.eclipse.jrebelNature</nature>
41
+ </natures>
42
+ </projectDescription>
Binary file
@@ -0,0 +1,236 @@
1
+ #encoding : utf-8
2
+ require 'spec_helper'
3
+
4
+ require "elexis/wiki/images"
5
+
6
+ describe 'Images' do
7
+ NR_PICTURES = 23
8
+
9
+ before :all do
10
+ @subdir = 'images'
11
+ @originDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', @subdir))
12
+ @dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'run', @subdir))
13
+ FileUtils.rm_rf(@dataDir)
14
+ FileUtils.makedirs(@dataDir)
15
+ FileUtils.cp_r(@originDir, @dataDir, :preserve => true)
16
+ @images = Elexis::Wiki::Images.new(@dataDir)
17
+ end
18
+
19
+ after :all do
20
+ # FileUtils.rm_rf(@dataDir)
21
+ end
22
+
23
+ it "should create the pictures.yml and .csv file" do
24
+ expect(@images.yml).to eq File.join(@images.rootDir, 'pictures.yml')
25
+ expect(@images.csv).to eq File.join(@images.rootDir, 'pictures.csv')
26
+ expect(File.exist?(@images.yml)).to eq true
27
+ expect(File.exist?(@images.csv)).to eq true
28
+ end
29
+
30
+
31
+ it "should read #{NR_PICTURES} pictures" do
32
+ expect(@images.pictures.size).to eq NR_PICTURES
33
+ end
34
+
35
+ it "pictures.yml should contain some png" do
36
+ content = IO.read(@images.yml)
37
+ expect(content.index('doc/ch.elexis.icpc_icpc1.png')).not_to eq 0
38
+ expect(content.index('doc/icpc1.png')).not_to eq 0
39
+ expect(content.index('icpc6.png')).not_to eq 0
40
+ expect(content.index('favicon_green.png')).not_to eq 0
41
+ end
42
+
43
+ it "pictures.csv should contain some png" do
44
+ content = IO.read(@images.csv)
45
+ expect(content.index('icpc6.png')).not_to eq 0
46
+ expect(content.index('favicon_green.png')).not_to eq 0
47
+ end
48
+
49
+ def check_rename(wiki_file, old_picture_name, new_picture_name, expected_new_line)
50
+ expect(IO.read(wiki_file)).to include old_picture_name
51
+ @images.change_image_name_in_mediawiki(wiki_file, old_picture_name, new_picture_name)
52
+ changed = IO.read(wiki_file)
53
+ expect(changed).to include "tag_one"
54
+ expect(changed).to include "tag_two"
55
+ expect(changed).to include "tag_three"
56
+ changed.index(new_picture_name)
57
+ expect(changed).to include expected_new_line
58
+ end
59
+
60
+ describe 'get_name_with_project' do
61
+ tests = {
62
+ 'elexis-3-base/ch.elexis.connect.reflotron.v2/doc/test.png' => 'reflotron-test.png',
63
+ 'elexis-3-base/ch.elexis.connect.reflotron.v2.feature/doc/test.png' => 'reflotron-test.png',
64
+ 'elexis-3-base/ch.elexis.laborimport.viollier.v2_test/doc/test.png' => 'viollier-test.png',
65
+ 'org.iatrix/doc/test.png' => 'iatrix-test.png',
66
+ 'org.iatrix.test/doc/test.png' => 'iatrix-test.png',
67
+ 'org.iatrix.feature/doc/test.png' => 'iatrix-test.png',
68
+ 'org.iatrix.tests/doc/test.png' => 'iatrix-test.png',
69
+ 'org.iatrix.tests/doc/test.jpg' => 'iatrix-test.jpg',
70
+ 'org.iatrix_tests/doc/test.gif' => 'iatrix-test.gif',
71
+ }
72
+ tests.each {
73
+ |path, expected|
74
+ it "should return #{expected} for #{path}" do
75
+ value = @images.get_name_with_project(path)
76
+ expect(value).to eq expected
77
+ end
78
+ }
79
+ end
80
+
81
+ rename_tests = {
82
+ 'Ch.elexis.icpc:icpc5.png' => [ 'icpc5.png', 'tag_png [[File:icpc5.png|image]]'],
83
+ 'Ch.elexis.icpc:icpc6.png' => [ 'elexis_logo.jpg', 'tag_jpg [[File:elexis_logo.jpg|image]]'],
84
+ 'Ch.elexis.icpc:icpc7.png' => [ 'disposan.gif', 'tag_gif [[File:disposan.gif|image]]'],
85
+ }
86
+ rename_tests.each {
87
+ |old_picture_name, params|
88
+ it "should go work with #{params[1]}" do
89
+ full_name = File.join(@dataDir, @subdir, 'ch.elexis.icpc', 'doc', 'test2.mediawiki')
90
+ check_rename(full_name, old_picture_name, params[0], params[1])
91
+ end
92
+ }
93
+
94
+ it "should refuse to change the image name in a mediawiki file when we find no corresponding image file" do
95
+ wiki_file = File.join(@dataDir, @subdir, 'ch.elexis.icpc', 'doc', 'test2.mediawiki')
96
+ expect(File.exist?(wiki_file)).to eq true
97
+ old_picture_name = 'ch.elexis.icpc:icpc4.png'
98
+ expect(IO.read(wiki_file)).to include old_picture_name
99
+ expect { @images.change_image_name_in_mediawiki(wiki_file, old_picture_name, 'icpc_should_not_exist.png')}.to raise_error(RuntimeError, /Could not find image/)
100
+ end
101
+
102
+ describe "determine_cleanup" do
103
+ before(:all) do
104
+ @images.determine_cleanup
105
+ end
106
+
107
+ it "should find duplicates" do
108
+ expect(@images.duplicates.size).not_to eq 0
109
+ end
110
+
111
+ it "should find nr_single_sha" do
112
+ expect(@images.nr_single_sha.size).not_to eq 0
113
+ end
114
+
115
+ it "should find to_short_names" do
116
+ expect(@images.to_short_names.size).not_to eq 0
117
+ end
118
+
119
+ # now the failing ones
120
+ it "should find same_name_but_differen_content" do
121
+ # skip "No example yet"
122
+ expect(@images.dup_non_identical.size).not_to eq 0
123
+ end
124
+
125
+ it "should find multiple_names" do
126
+ expect(@images.multiple_names.size).not_to eq 0
127
+ end
128
+ it "should find short_and_sha_okay" do
129
+ expect(@images.short_and_sha_okay.size).not_to eq 0
130
+ end
131
+
132
+ it "should find wrong_best_name" do
133
+ expect(@images.wrong_best_name.size).to eq 0
134
+ end
135
+
136
+ it "should find new_best_name" do
137
+ expect(@images.new_best_name.size).not_to eq 0
138
+ end
139
+ end
140
+ end
141
+
142
+
143
+ describe 'ImagesCleanup' do
144
+
145
+ def setup_run
146
+ @subdir = 'images'
147
+ @originDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', @subdir))
148
+ @dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'run', @subdir))
149
+ FileUtils.rm_rf(@dataDir)
150
+ FileUtils.makedirs(@dataDir)
151
+ FileUtils.cp_r(@originDir, @dataDir, :preserve => true)
152
+ @images = Elexis::Wiki::Images.new(@dataDir)
153
+ end
154
+
155
+ before :all do
156
+ setup_run
157
+ end
158
+
159
+ describe "execute_cleanup with git" do
160
+ before(:all) do
161
+ setup_run
162
+ system("git init #{@dataDir}")
163
+ @images.determine_cleanup
164
+ @images.execute_cleanup(true)
165
+ end
166
+
167
+ it "should add Icpc8.png and icpc1.png" do
168
+ expect(@images.actions.index("git add -f images/ch.elexis.icpc/doc/icpc1.png")).not_to eq nil
169
+ expect(@images.actions.index("git add -f images/ch.elexis.icpc/doc/Icpc8.png")).not_to eq nil
170
+ end
171
+ end
172
+
173
+ describe "execute_cleanup" do
174
+ before(:all) do
175
+ setup_run
176
+ @images.determine_cleanup
177
+ @images.execute_cleanup
178
+ end
179
+
180
+ it "should change_image_name_in_mediawiki" do
181
+ cmd = 'change_image_name_in_mediawiki test.mediawiki kabel.png icpc-kabel.png'
182
+ expect(@images.actions.index(cmd) >= 0)
183
+ end
184
+
185
+ it "should remove obsolete symlinks" do
186
+ cmd = 'rm Ch.elexis.notes'
187
+ expect(@images.actions.index(cmd) >= 0)
188
+ end
189
+
190
+
191
+ it "should NOT mv medevit_inbox1.png" do
192
+ cmd = 'medevit_inbox1.png'
193
+ expect(@images.actions.index(cmd)).to eq nil
194
+ end
195
+
196
+ it "should mv Com.hilotec.elexis.opendocument_anleitung_opendocument_1.png to anleitung_opendocument_1.png" do
197
+ cmd = 'mv Com.hilotec.elexis.opendocument_anleitung_opendocument_1.png anleitung_opendocument_1.png'
198
+ puts @images.actions.join("\n")
199
+ expect(@images.actions.index(cmd) >= 0)
200
+ end
201
+
202
+ it "should find mv duplicate-images" do
203
+ cmd = 'mv kabel.png icpc-kabel.png'
204
+ expect(@images.actions.index(cmd) >= 0)
205
+ @images.execute_cleanup
206
+ cmd = 'mv kabel.png icpc-kabel.png'
207
+ expect(@images.actions.index(cmd) >= 0)
208
+ end
209
+
210
+ it "should find remove old files" do
211
+ cmd = 'rm -f ch.elexis.icpc_icpc1.png'
212
+ expect(@images.actions.index(cmd) >= 0)
213
+ end
214
+
215
+ it "should find any files with ':' in their names" do
216
+ search = "#{@images.rootDir}/**/*:*"
217
+ files = Dir.glob(search)
218
+ expect(files.size).to eq 0
219
+ end
220
+ it "should remove_files_with_case_sensitive_changes" do
221
+ lowercase = "#{@images.rootDir}/test_lower_case.png"
222
+ up_case = "#{@images.rootDir}/TEST_LOWER_CASE.png"
223
+ capitalized = "#{@images.rootDir}/Test_lower_case.png"
224
+ [ lowercase, up_case, capitalized].each {
225
+ |file|
226
+ system("touch #{file}")
227
+ expect(File.exist?(file))
228
+ }
229
+ @images.remove_files_with_case_sensitive_changes(lowercase)
230
+ expect(File.exist?(lowercase))
231
+ expect(File.exist?(up_case)).to eq false
232
+ expect(File.exist?(capitalized)).to eq false
233
+ end
234
+ end
235
+ end
236
+