delish 0.7.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/delish CHANGED
@@ -14,14 +14,9 @@ else
14
14
  end
15
15
  #}}}
16
16
 
17
- #{{{ Output only and debug
17
+ #{{{ Output only
18
18
  unless ARGV[1].nil?
19
19
  OUTPUT_ONLY = true
20
- unless ARGV[2].nil?
21
- DEBUG = true
22
- else
23
- DEBUG = false
24
- end
25
20
  else
26
21
  OUTPUT_ONLY = false
27
22
  end
@@ -30,7 +25,7 @@ end
30
25
  require 'delish_bookmark_search.rb'
31
26
  include Delish
32
27
 
33
- delish_bookmark_search = Delish_Bookmark_Search.new(string, db)
28
+ delish_bookmark_search = Delish_Bookmark_Search.new(string, db, !OUTPUT_ONLY)
34
29
 
35
30
  if OUTPUT_ONLY
36
31
  delish_bookmark_search.each { |bookmark| puts "#{bookmark[1]}: [#{bookmark[0]}]" }
data/bin/import_delicious CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'rexml/document'
5
- require 'net/https'
6
4
  require 'sqlite3'
7
5
 
8
6
  user = ENV['delish_user']
data/bin/update_delicious CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'rexml/document'
5
- require 'net/https'
6
4
  require 'sqlite3'
7
5
 
8
6
  user = ENV['delish_user']
@@ -22,11 +22,12 @@ module Delish
22
22
  #---
23
23
  #{{{ initialize(search, database)
24
24
  #+++
25
- def initialize(search, database)
25
+ def initialize(search, database, access)
26
26
  @db = database
27
27
 
28
28
  @TAG_SPLIT = ','
29
29
  @SPLIT = ':'
30
+ @ACCESS = access
30
31
 
31
32
  @search_string = search
32
33
  @sss = []
@@ -57,7 +58,7 @@ module Delish
57
58
  @submatches = $3.split(@SPLIT)
58
59
  self.sub_search_parse
59
60
  end
60
- self.execute(false)
61
+ self.execute
61
62
  end
62
63
  end
63
64
  #---
@@ -190,17 +191,17 @@ module Delish
190
191
  #---
191
192
  #{{{ execute
192
193
  #+++
193
- def execute(access)
194
+ def execute
194
195
  @sss << @date_greater_or_equal unless @date_greater_or_equal.variables.empty?
195
196
  @sss << @date_less_than unless @date_less_than.variables.empty?
196
197
 
197
198
  @sss.sort! { |a, b| a.order <=> b.order }
198
199
 
199
- statement, variables = self.build_statement(access)
200
+ statement, variables = self.build_statement
200
201
 
201
202
  @results = @db.execute(statement, variables)
202
203
 
203
- if access
204
+ if @ACCESS
204
205
  hashes = []
205
206
  @results.each { |i| hashes << i[1] }
206
207
  self.mark_accessed(hashes)
@@ -236,14 +237,14 @@ module Delish
236
237
  #+++
237
238
 
238
239
  #---
239
- #{{{ build_statement(access)
240
+ #{{{ build_statement
240
241
  #+++
241
- def build_statement(access)
242
+ def build_statement
242
243
  variables = []
243
244
 
244
245
  statement = "SELECT url"
245
246
 
246
- unless access
247
+ unless @ACCESS
247
248
  statement += ", description"
248
249
  else
249
250
  statement += ", posts.hash"
data/lib/import_delish.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'version.rb'
2
+ require 'rexml/document'
3
+ require 'net/https'
4
+
1
5
  module Delish
2
6
 
3
7
  #{{{
@@ -8,8 +12,7 @@ module Delish
8
12
  @user = user
9
13
  @pass = pass
10
14
  @db = db
11
- # Version should somehow be gotten from GEM
12
- @agent = 'delish commandline client 0.7.7'
15
+ @agent = 'delish commandline client #{Version::STRING}'
13
16
  end
14
17
  #}}}
15
18
 
@@ -108,39 +111,41 @@ module Delish
108
111
  end
109
112
  #}}}
110
113
 
111
- # This function is STILL TOO LONG
114
+ # This function is too nesty
112
115
  #{{{ update_bookmarks
113
116
  def update_bookmarks(&block)
114
117
 
115
- if self.update_exists?
118
+ return unless self.update_exists?
116
119
 
117
- found = false
118
- amount = 10
119
- increment = 10
120
+ found = false
121
+ amount = 10
122
+ increment = 10
120
123
 
121
- # Maximum for del.icio.us api is 100
122
- until found == true or amount >= 100
123
- self.delicious_communication("/v1/posts/recent?count=#{amount}") do |data|
124
+ # Maximum for del.icio.us api is 100
125
+ until found == true or amount >= 100
126
+ self.delicious_communication("/v1/posts/recent?count=#{amount}") do |data|
124
127
 
125
- elements = data.elements.to_a("/posts/post")
126
- # Remove the ones we already went through
127
- elements.slice(increment, amount - increment)
128
+ # Remove the ones we already went through
129
+ elements = data.elements.to_a("/posts/post").slice(increment, amount - increment)
128
130
 
129
- elements.each do |post,i|
130
- if post.attributes['time'] <= @last_update
131
- found = true
132
- else
133
- # Output should be able to be surpressed
134
- yield(post.attributes['href'], post.attributes['description']) unless block.nil?
135
- self.insert_post_xml_helper(post)
136
- end
131
+ elements.each do |post,i|
132
+ if post.attributes['time'] <= @last_update
133
+ found = true
134
+ else
135
+ yield(post.attributes['href'], post.attributes['description']) unless block.nil?
136
+ self.insert_post_xml_helper(post)
137
137
  end
138
138
 
139
139
  end
140
- amount += increment
140
+
141
141
  end
142
+
143
+ amount += increment
144
+
142
145
  end
146
+
143
147
  self.set_last_update
148
+
144
149
  end
145
150
 
146
151
  #}}}
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Delish
2
+ module Version
3
+ STRING = "1.0.0"
4
+ end
5
+ end
data/test/test_db ADDED
Binary file
data/test/tests CHANGED
@@ -1,34 +1,46 @@
1
1
  #!/usr/bin/ruby -w
2
- require '../delish_bookmark_search.rb'
2
+ require '../lib/delish_bookmark_search.rb'
3
+ require '../lib/import_delish.rb'
4
+ include Delish
5
+ require 'rubygems'
3
6
  require 'test/unit'
4
7
  require 'sqlite3'
5
8
 
6
9
  @@db = SQLite3::Database.new( "test_db" )
7
10
  # username = delish_test
8
11
  # pass = 5VRiVVd
9
- class Delish < Test::Unit::TestCase
12
+ class ImportTest < Test::Unit::TestCase
13
+ def test_import
14
+ import = ImportDelish.new('delish_test', '5VRiVVd', @@db)
15
+
16
+
17
+
18
+ end
19
+ end
20
+
21
+ class Delish_Test < Test::Unit::TestCase
10
22
 
11
23
  def test_basic_search
12
- search = Delish_Bookmark_Search.new('readable2', @@db )
24
+ search = Delish_Bookmark_Search.new('readable2', @@db, false )
13
25
  search.each {|i| assert_equal('http://frew.livejournal.com/friends/readable2', i[0]); assert_equal('readable2', i[1]) }
14
26
  assert_equal('http://frew.livejournal.com/friends/readable2', search[0][0])
15
27
  assert_equal('readable2', search[0][1])
16
28
  end
17
29
 
18
30
  def test_tag_equality_search
19
- search = Delish_Bookmark_Search.new('(tzsh,wiki)', @@db )
31
+ search = Delish_Bookmark_Search.new('(tzsh,wiki)', @@db, false )
20
32
  assert_equal('http://zshwiki.org/home/', search[0][0])
21
33
  assert_equal('ZshWiki', search[0][1])
22
34
  end
23
35
 
24
36
  def test_tag_starts_with_search
25
- search = Delish_Bookmark_Search.new('(svis,fun)', @@db )
37
+ search = Delish_Bookmark_Search.new('(svis,fun)', @@db, false )
26
38
  assert_equal('http://www.drurywriting.com/david/05-SnowmanArt.htm', search[0][0])
27
39
  assert_equal('calvin & hobbes snowman art', search[0][1])
28
40
  end
29
41
 
30
42
  def test_tag_inside_search
31
- search = Delish_Bookmark_Search.new('(ivi,unn)', @@db )
43
+ search = Delish_Bookmark_Search.new('(ivi,unn)', @@db, false )
32
44
  assert_equal('http://www.bemroses.net/images/curves.jpg', search[2][0])
33
45
  assert_equal('Editor Learning Curves', search[2][1])
34
46
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: delish
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.7
7
- date: 2007-07-09 00:00:00 -06:00
6
+ version: 1.0.0
7
+ date: 2007-07-13 00:00:00 -06:00
8
8
  summary: Allows use of del.icio.us bookmarksfrom the commandline with minimum keystrokes
9
9
  require_paths:
10
10
  - lib
@@ -34,7 +34,9 @@ files:
34
34
  - bin/update_delicious
35
35
  - lib/delish_bookmark_search.rb
36
36
  - lib/import_delish.rb
37
+ - lib/version.rb
37
38
  - test/tests
39
+ - test/test_db
38
40
  - README
39
41
  test_files:
40
42
  - test/tests