Class: RubyPoint
- Inherits:
-
Object
show all
- Defined in:
- lib/rubypoint.rb,
lib/rubypoint/element.rb,
lib/rubypoint/presentation.rb
Defined Under Namespace
Classes: App, ContentTypes, Element, File, Presentation, PresentationRel, Relationship, Slide, TextField
Constant Summary
collapse
- @@working_directory =
''
Class Method Summary
collapse
Class Method Details
.clear_working_directory ⇒ Object
41
42
43
|
# File 'lib/rubypoint.rb', line 41
def self.clear_working_directory
system("rm -rf #{self.working_directory}*")
end
|
.compress_folder(folder_path, file_path) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rubypoint.rb', line 27
def self.compress_folder(folder_path, file_path)
Zip::Archive.open(file_path, Zip::CREATE) do |zip_file|
Dir.glob("#{folder_path}/**/*", ::File::FNM_DOTMATCH).each do |path|
zip_path = path.gsub("#{folder_path}/","")
next if zip_path == "." || zip_path == ".." || zip_path.match(/DS_Store/)
if ::File.directory?(path)
zip_file.add_dir(zip_path)
else
zip_file.add_file(zip_path, path)
end
end
end
end
|
.diff(doc1, doc2) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/rubypoint.rb', line 45
def self.diff(doc1, doc2)
doc_id = Time.now.to_i
open_doc(doc1, "tmp/TEST#{doc_id}_1")
open_doc(doc2, "tmp/BASE#{doc_id}_2")
`mate tmp/TEST#{doc_id}_1`
`mate tmp/BASE#{doc_id}_2`
end
|
.open_doc(file_path, save_path) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/rubypoint.rb', line 17
def self.open_doc(file_path, save_path)
file_name = file_path.split('/').last
save_path = file_name.split('.').first unless save_path
tmp_file = "#{save_path}/#{file_name}"
system("mkdir #{save_path}")
system("cp #{file_path} #{tmp_file}")
system("unzip -q #{tmp_file} -d #{save_path}/")
system("rm #{tmp_file}")
end
|
.show(doc1, doc2, path) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/rubypoint.rb', line 53
def self.show(doc1, doc2, path)
require 'xmlsimple'
doc_id = Time.now.to_i
open_doc(doc1, "tmp/#{doc_id}_1")
open_doc(doc2, "tmp/#{doc_id}_2")
puts "tmp/#{doc_id}_1/#{path}"
return Dir.glob("tmp/#{doc_id}_1/**/*", ::File::FNM_DOTMATCH).inspect unless ::File.exists?("tmp/#{doc_id}_1/#{path}") && ::File.exists?("tmp/#{doc_id}_2/#{path}")
file1 = `xmllint --format tmp/#{doc_id}_1/#{path}`
file2 = `xmllint --format tmp/#{doc_id}_2/#{path}`
sizes_array = []
file1_array = []
file2_array = []
file1.each_line { |line| file1_array << line }
file2.each_line { |line| file2_array << line}
max = 200
results = ""
file1_array.each_with_index do |line,i|
disp = line
disp += file2_array[i]
results += disp
end
results
end
|
.working_directory ⇒ Object
9
10
11
|
# File 'lib/rubypoint.rb', line 9
def self.working_directory
@@working_directory
end
|
.working_directory=(directory) ⇒ Object
13
14
15
|
# File 'lib/rubypoint.rb', line 13
def self.working_directory=(directory)
@@working_directory = directory
end
|