sieve-parser 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ module Sieve
4
+
5
+ # This class contains the attributes of vacation/autoreplay(action)
6
+ class Vacation
7
+ attr_accessor :days, :subject, :content, :type
8
+
9
+ # New object
10
+ #@param [String](:subject) subject of vacation
11
+ #@param [String](:content) content of vacation
12
+ #@param [Integer](:days) days of recurrence message for same From
13
+ def initialize params={}
14
+ @days = (params[:days] ? params[:days].to_i : 1)
15
+ @subject = params[:subject]
16
+ @content = params[:content]
17
+ @type = "vacation"
18
+ end
19
+
20
+ # Parse text and return self with params
21
+ #@param [string] text of vacation action
22
+ #@return [Vacation] object of vacation
23
+ def self.parse_text(text)
24
+ params = text.scan(/vacation :days (\d+) :subject "(.*)".*\n.*\s*(.*)/)[0]
25
+ Vacation.new(:days=>params[0],:subject => params[1],:content => params[2])
26
+ end
27
+
28
+ # Return text of vacation action
29
+ #@return [string] text of vacation formated
30
+ def to_s
31
+ %Q{vacation :days #{@days} :subject "#{@subject}" :mime text:
32
+ Content-Type: text/html;
33
+
34
+ #{@content}
35
+ .
36
+ ;}
37
+ end
38
+ end
39
+ end
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'sieve-parser'
5
- s.version = '0.0.2'
5
+ s.version = '0.0.3'
6
6
  s.summary = 'A Ruby library for sieve parser'
7
7
  s.description = <<-EOF
8
8
  sieve-parser is a pure-ruby implementation for parsing and
@@ -15,6 +15,7 @@ spec = Gem::Specification.new do |s|
15
15
  'lib/sieve-parser/condition.rb',
16
16
  'lib/sieve-parser/filter.rb',
17
17
  'lib/sieve-parser/filterset.rb',
18
+ 'lib/sieve-parser/vacation.rb',
18
19
  'lib/sieve-parser.rb',
19
20
  'sieve-parser.gemspec'
20
21
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sieve-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -22,6 +22,7 @@ files:
22
22
  - lib/sieve-parser/condition.rb
23
23
  - lib/sieve-parser/filter.rb
24
24
  - lib/sieve-parser/filterset.rb
25
+ - lib/sieve-parser/vacation.rb
25
26
  - lib/sieve-parser.rb
26
27
  - sieve-parser.gemspec
27
28
  homepage: http://github.com/selialkile/sieve-parser