Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .yardoc/checksums

This file was deleted.

Binary file removed .yardoc/object_types
Binary file not shown.
Binary file removed .yardoc/objects/root.dat
Binary file not shown.
Binary file removed .yardoc/proxy_types
Binary file not shown.
13 changes: 1 addition & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
source 'http://rubygems.org'

gem "split-where" , ">= 0.0.3"

#gem 'ruby-managesieve'

group :test, :development do
gem 'pry'
gem 'guard-rspec'
gem 'yard'
gem 'rspec'
gem "rspec-rails", "~> 2.4"
gem 'rb-fsevent', '~> 0.9.1'
end
gemspec
192 changes: 116 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,92 +1,132 @@
PATH
remote: .
specs:
sieve-parser (1.0.0)
split-where

GEM
remote: http://rubygems.org/
specs:
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
builder (3.0.3)
coderay (1.0.7)
diff-lcs (1.1.3)
erubis (2.7.0)
guard (1.4.0)
listen (>= 0.4.2)
thor (>= 0.14.6)
guard-rspec (2.0.0)
guard (>= 1.1)
rspec (~> 2.11)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.5)
listen (0.5.2)
method_source (0.8)
multi_json (1.3.6)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.0.5)
crass (1.0.4)
diff-lcs (1.3)
erubi (1.8.0)
ffi (1.11.1)
formatador (0.2.5)
guard (2.15.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
method_source (0.9.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
nenv (0.3.0)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rb-fsevent (0.9.1)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
rspec-rails (2.11.0)
thor (>= 0.19.0, < 2.0)
rake (12.3.2)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
slop (3.3.3)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
ruby_dep (1.5.0)
shellany (0.0.1)
split-where (0.0.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.16.0)
tilt (1.3.3)
yard (0.8.2.1)
thor (0.20.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
concurrent-ruby
guard-rspec
pry
rb-fsevent (~> 0.9.1)
rb-fsevent
rspec
rspec-rails (~> 2.4)
split-where (>= 0.0.3)
yard
rspec-rails
sieve-parser!

BUNDLED WITH
1.17.3
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@
5. REFERENCES


0. INTRODUCTION
===============
## 0. INTRODUCTION

sieve-parser is a pure-ruby implementation for parsing and manipulate the sieve scripts.


1. REQUIREMENTS
===============
## 1. REQUIREMENTS

Ruby/SieveParser requires Ruby version 1.9.1 or newer.


2. INSTALLATION
===============
## 2. INSTALLATION

gem install sieve-parser


3. LICENSE
==========
## 3. LICENSE

Copyright (c) 2012 Thiago Coutinho <[email protected]>
<[email protected]>
Expand All @@ -47,28 +43,29 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


4. AUTHOR
=========
## 4. AUTHOR

Ruby/SieveParser was developed by Thiago Coutinho in Locaweb
(http://www.locaweb.com.br).


5. REFERENCES
=============
## 5. REFERENCES

[1] http://www.faqs.org/rfcs/rfc3028.html
[2] http://www.faqs.org/rfcs/rfc5804.html
[3] http://www.faqs.org/rfcs/rfc5230.html
[4] http://www.faqs.org/rfcs/rfc5229.html
- http://www.faqs.org/rfcs/rfc3028.html
- http://www.faqs.org/rfcs/rfc5804.html
- http://www.faqs.org/rfcs/rfc5230.html
- http://www.faqs.org/rfcs/rfc5229.html

6. LAST CHANGES
===============
## 6. LAST CHANGES
*1.0.0*
- Upgrading gems
- Adding travis

[0.0.6]
*0.0.6*
- require 'split-where'
- Sieve::Conditions => Parse new types and spliter more faster without regex
- Examples:
```
# header :contains "Subject" "lala"
# not header :contains "Subject" "popo"
# not exists "Subject"
Expand All @@ -79,3 +76,4 @@ Ruby/SieveParser was developed by Thiago Coutinho in Locaweb
# header :count "eq" :comparator "i;ascii-numeric" "Subject" "7"
# header :value "gt" :comparator "i;ascii-numeric" "Subject" "9"
# header :value "eq" :comparator "i;ascii-numeric" "Subject" "11"
```
14 changes: 7 additions & 7 deletions lib/sieve-parser/filterset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Sieve

class FilterSet
attr_accessor :text_sieve, :auto_require

#Create FilterSet
#@param [String] text of sieve
#@return [FilterSet]
Expand Down Expand Up @@ -81,7 +81,7 @@ def requires
#@param [string] name of require
def add_require(req)
#TODO: Implement config of requires allowed
raise Exception.new("Is not a require valid!") unless req =~ /\S+/
raise Exception.new("Is not a require valid!") unless req =~ /\S+/
@requires << req
@requires.uniq!
end
Expand All @@ -96,16 +96,16 @@ def to_s
end

# Return a array of filters by select with all given params
#@param [{:name=>String, :disabled => Boolean, :text => String}]
#@param [{:name=>String, :disabled => Boolean, :text => String}]
#@note The :text only have text to search
#@return [Array<Sieve::Filter>]
def where
entries =[]
@filters.each do |filter|
@filters.each do |filter|
cond = false
cond = filter.name == args[:name] unless args[:name].nil?
cond = filter.disabled? == args[:disabled] unless args[:disabled].nil?
cond = filter.to_s =~ /#{args[:text]}/ unless args[:text].nil?
cond = filter.to_s =~ /#{args[:text]}/ unless args[:text].nil?
entries << filter if cond
end
entries
Expand All @@ -115,11 +115,11 @@ def where
# Make de parse and put results in variables
def parse
#return a array with string of elements: "xxxx", "yyyyyy"
@text_sieve.scan(/^require\s\["(\S+)"\];$/).each do |r|
@text_sieve.scan(/^require\s\["(\S+)"\];$/).each do |r|
@requires.concat(r[0].split('","'))
end

@text_sieve.scan(/(^#.*\nif[\s\w\:\"\.\;\(\)\,\-]*\n\{[a-zA-Z0-9\s\@\<>=\:\[\]\_\"\.\;\(\)\&\,\-\/]*\n\}$)/).each do |f|
@text_sieve.scan(/(^#.*\nif[\s\w\:\"\.\;\(\)\,\-@]*\n\{[a-zA-Z0-9\s\@\<>=\:\[\]\_\"\.\;\(\)\&\,\-\/]*\n\}$)/).each do |f|
@filters << Sieve::Filter.new(text:f[0])
end

Expand Down
Loading