Class: Pasco

Inherits:
Object
  • Object
show all
Defined in:
lib/pasco.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = "", modified_time = "", access_time = "", file_name = "", directory = "", http_header = "") ⇒ Pasco

Returns a new instance of Pasco.



5
6
7
8
9
10
11
12
# File 'lib/pasco.rb', line 5

def initialize(url="",modified_time="",access_time="",file_name="",directory="",http_header="")
  @url = url
  @modified_time = modified_time
  @access_time = access_time;
  @file_name = file_name
  @directory =directory
  @http_header = http_header
end

Instance Attribute Details

#access_timeObject (readonly)

Returns the value of attribute access_time.



4
5
6
# File 'lib/pasco.rb', line 4

def access_time
  @access_time
end

#directoryObject (readonly)

Returns the value of attribute directory.



4
5
6
# File 'lib/pasco.rb', line 4

def directory
  @directory
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



4
5
6
# File 'lib/pasco.rb', line 4

def file_name
  @file_name
end

#http_headerObject (readonly)

Returns the value of attribute http_header.



4
5
6
# File 'lib/pasco.rb', line 4

def http_header
  @http_header
end

#modified_timeObject (readonly)

Returns the value of attribute modified_time.



4
5
6
# File 'lib/pasco.rb', line 4

def modified_time
  @modified_time
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/pasco.rb', line 4

def url
  @url
end

Class Method Details

.get_history(file_name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pasco.rb', line 14

def self.get_history(file_name)
 if !file_name.nil? &&  File.extname(file_name) == ".dat"
   if RUBY_PLATFORM=~ /linux/ || RUBY_PLATFORM =~ /darwin/
      pasco_path = File.expand_path(File.join(File.dirname(__FILE__),"pasco"))
      command = "#{pasco_path} #{file_name}"
      result =`#{command}`
   else #FOR Windows Not tested yet
      pasco_path = File.expand_path(File.dirname(__FILE__),"pasco.exe")
      command = "#{pasco_path} #{file_name}"
      result = `#{command}`
   end  
   @ie_histories = self.process_history(result)
 else
   puts "Please enter file name"
   return -1
 end 
 return @ie_histories
end

.process_history(result) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pasco.rb', line 34

def self.process_history(result)
  ie_histories = []
  results =result.split("\n")
  results.each do |result|
    if !result.match(/^URL/).nil?
      result_of_url = result.split("\t")
      browsing_url = result_of_url[1].match(/((\w+):\/\/(.+))/)[0] rescue nil
      modified_time = result_of_url[2]
      acess_time = result_of_url[3]
      file_name = result_of_url[4]
      directory = result_of_url[5]
      http_header = result_of_url[6]
      if !browsing_url.nil?
       ie_histories << Pasco.new(browsing_url,modified_time,acess_time,file_name,directory,http_header)
     end 
    end
  end
  ie_histories
end