corto 0.80.1 → 0.80.2

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.
Files changed (6) hide show
  1. data/README +56 -1
  2. data/VERSION +1 -1
  3. data/bin/corto +2 -2
  4. data/db/corto.db +0 -0
  5. data/lib/corto.rb +2 -2
  6. metadata +58 -5
data/README CHANGED
@@ -7,8 +7,63 @@ CORTO - your url shortner gem
7
7
  Why the world needs another url shortener? Well, true to be told I don't know the answer and I'm
8
8
  pretty sure this code is far away from being revolutionary.
9
9
 
10
- However... it's fun!
10
+ However... corto is funniest!
11
11
 
12
+ - Usage
13
+
14
+ Using corto as standalone utility is straightforward. In case you want to shorten an url you just
15
+ launch the program with the url as parameter.
16
+
17
+ % bin/corto http://www.armoredcode.com
18
+ % corto: http://www.armoredcode.com shrunk as ji5jnu
19
+
20
+ Please note that you've to supply a valid URL, since internally it's parsed and rejected anything but
21
+ HTTP and HTTPS verbs.
22
+
23
+ % bin/corto funnystatementhere
24
+ % corto: it seems funnystatementhere is not a valid url to shrink
25
+
26
+ If you want to deflate a shrunk url, you have just to specify the '-d' flag this way.
27
+
28
+ % bin/corto -d ji5jnu
29
+ % corto: ji5jnu deflated is http://www.armoredcode.com
30
+
31
+ Super easy, isn't it? Now, go ahead and shrink the web!
32
+
33
+ - API
34
+
35
+ A simple corto shortening session start with class initialization, optionally telling which SQLite3
36
+ database to use and then mastering the parameter.
37
+
38
+ require 'corto'
39
+
40
+ ...
41
+ corto = Corto.new # we're now saying the gem we want to use it's internal database stored in db/corto.db
42
+ s = corto.shrink('http://www.armoredcode.com')
43
+
44
+ # s now stores the shrinked url that is already added to database if not present.
45
+ # If you'll pass an invalid url to shrink(), nil will be returned instead
46
+
47
+ Deflating a URL is super easy as well
48
+
49
+ # The deflate process is quite straightforward as well
50
+
51
+ d = corto.deflate(s)
52
+ # d has now the deflated url or nil if that url was not found
53
+
54
+ You can also count how many urls contained into db
55
+
56
+ # If you want to know how many urls you have in your database, just call the count() method.
57
+ puts 'Hey, I have stored ' + corto.count() + ' urls'
58
+
59
+ And finally you can purge your db
60
+
61
+ # Tired of your database and time for a massive clean has come? Let's purge the db.
62
+ corto.purge
63
+
64
+ # corto.count == 0 now
65
+
66
+
12
67
  - Note on Patches/Pull Requests
13
68
 
14
69
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.80.1
1
+ 0.80.2
data/bin/corto CHANGED
@@ -53,7 +53,7 @@ corto = Corto.new
53
53
  if (shrink)
54
54
  s = corto.shrink(ARGV[0])
55
55
  if (!s.nil?)
56
- puts 'corto: ' + ARGV[0] + ' shrinked as ' + s
56
+ puts 'corto: ' + ARGV[0] + ' shrunk as ' + s
57
57
  else
58
58
  puts 'corto: it seems ' + ARGV[0] + ' is not a valid url to shrink'
59
59
  end
@@ -62,7 +62,7 @@ else
62
62
  if (!s.nil?)
63
63
  puts 'corto: ' + ARGV[0] + ' deflated is ' + s
64
64
  else
65
- puts 'corto: it seems ' + ARGV[0] + ' is not a known shrinked url'
65
+ puts 'corto: it seems ' + ARGV[0] + ' is not a known shrunk url'
66
66
  end
67
67
  end
68
68
 
Binary file
@@ -45,9 +45,9 @@ class Corto
45
45
  url.hash.abs.to_s(36)
46
46
  end
47
47
 
48
- def deflate(shrinked_url)
48
+ def deflate(shrunk_url)
49
49
  @db = SQLite3::Database.new(@db_name)
50
- result = @db.execute("SELECT original FROM urls WHERE url='" +shrinked_url+"'")
50
+ result = @db.execute("SELECT original FROM urls WHERE url='" +shrunk_url+"'")
51
51
  (! result.first.nil?) ? result.first.first : nil
52
52
  end
53
53
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 349
4
+ hash: 347
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 80
9
- - 1
10
- version: 0.80.1
9
+ - 2
10
+ version: 0.80.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paolo Perego
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-09 00:00:00 +01:00
18
+ date: 2011-02-11 00:00:00 +01:00
19
19
  default_executable: corto
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -84,7 +84,60 @@ description: "CORTO - your url shortner gem\n\
84
84
  \tWhy the world needs another url shortener? Well, true to be told I don't know the answer and I'm \n\
85
85
  \tpretty sure this code is far away from being revolutionary.\n\
86
86
  \t\n\
87
- \tHowever... it's fun!\n\n\
87
+ \tHowever... corto is funniest!\n\n\
88
+ - Usage\n\
89
+ \t\n\
90
+ \tUsing corto as standalone utility is straightforward. In case you want to shorten an url you just \n\
91
+ \tlaunch the program with the url as parameter.\n\
92
+ \t\n\
93
+ \t\t% bin/corto http://www.armoredcode.com\n\
94
+ \t\t% corto: http://www.armoredcode.com shrunk as ji5jnu\n\
95
+ \t\n\
96
+ \tPlease note that you've to supply a valid URL, since internally it's parsed and rejected anything but\n\
97
+ \tHTTP and HTTPS verbs.\n\
98
+ \t\n\
99
+ \t\t% bin/corto funnystatementhere\n\
100
+ \t\t% corto: it seems funnystatementhere is not a valid url to shrink\n\
101
+ \t\n\
102
+ \tIf you want to deflate a shrunk url, you have just to specify the '-d' flag this way.\n\
103
+ \t\t\n\
104
+ \t\t% bin/corto -d ji5jnu\n\
105
+ \t\t% corto: ji5jnu deflated is http://www.armoredcode.com\n\n\
106
+ \tSuper easy, isn't it? Now, go ahead and shrink the web!\n\
107
+ \t\n\
108
+ - API\n\n\
109
+ \tA simple corto shortening session start with class initialization, optionally telling which SQLite3 \n\
110
+ \tdatabase to use and then mastering the parameter.\n\
111
+ \t\n\
112
+ \t\trequire 'corto'\n\
113
+ \t\t\n\
114
+ \t\t...\n\
115
+ \t\tcorto = Corto.new # we're now saying the gem we want to use it's internal database stored in db/corto.db\n\
116
+ \t\ts = corto.shrink('http://www.armoredcode.com')\n\
117
+ \t\n\
118
+ \t\t# s now stores the shrinked url that is already added to database if not present.\n\
119
+ \t\t# If you'll pass an invalid url to shrink(), nil will be returned instead\n\
120
+ \t\n\
121
+ \tDeflating a URL is super easy as well\n\
122
+ \t\n\
123
+ \t\t# The deflate process is quite straightforward as well\n\
124
+ \t\t\n\
125
+ \t\td = corto.deflate(s)\n\
126
+ \t\t# d has now the deflated url or nil if that url was not found\n\
127
+ \t\n\
128
+ \tYou can also count how many urls contained into db\n\
129
+ \t\t\n\
130
+ \t\t# If you want to know how many urls you have in your database, just call the count() method.\n\
131
+ \t\tputs 'Hey, I have stored ' + corto.count() + ' urls'\n\
132
+ \t\n\
133
+ \tAnd finally you can purge your db\n\
134
+ \t\t\n\
135
+ \t\t# Tired of your database and time for a massive clean has come? Let's purge the db.\n\
136
+ \t\tcorto.purge\n\
137
+ \t\t\n\
138
+ \t\t# corto.count == 0 now\n\
139
+ \t\t \n\
140
+ \t\n\
88
141
  - Note on Patches/Pull Requests\n\n\
89
142
  \t* Fork the project.\n\
90
143
  \t* Make your feature addition or bug fix.\n\