short-url-creator 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ba618fc867dcaa7d8d7a248fa769d45d55d57b1
4
+ data.tar.gz: 5facce071c2fed4508f9253560ff1a703a8e40b3
5
+ SHA512:
6
+ metadata.gz: 9b198c1e95e135b0585297fe3097fd63793cde2e2539e50207aba5a08513a8f9dae232bdd6514eaee1dc3d48c2e059b161cc735f9b7ce91961f54b2eb0c4485b
7
+ data.tar.gz: 3dab0076b4d573ec4f21e22af365ddb846cc456cf403f1d69dbb3f99f7ba1faeb27971dfa51d0e110fe6e9ee659b70fa16dd243b8d13e653c07b36b03ea6efb4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,8 +1,11 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  # file: short-url-creator.rb
4
4
 
5
+ require 'builder'
6
+
5
7
  class ShortUrlCreator
8
+
6
9
  def initialize()
7
10
  @chars = ('a'..'z').to_a + ('1'..'9').to_a + ('A'..'Z').to_a
8
11
  @array_size = @chars.size
@@ -17,6 +20,41 @@ class ShortUrlCreator
17
20
  @k = 0
18
21
  @short_url = []
19
22
  end
23
+
24
+ def generate(count)
25
+ get_short_url(count)
26
+ if block_given? then
27
+ yield(@short_url)
28
+ else
29
+ @short_url
30
+ end
31
+ end
32
+
33
+ def save(filename='surl.xml')
34
+
35
+ xml = Builder::XmlMarkup.new( :target => buffer='', :indent => 2 )
36
+ xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
37
+
38
+ xml.urls do
39
+ xml.summary do
40
+ xml.recordx_type 'dynarex'
41
+ xml.format_mask '[!short_url] [!full_url]'
42
+ xml.schema 'urls/url(short_url,full_url)'
43
+ end
44
+ xml.records do
45
+ @short_url.each_with_index do |x,i|
46
+ xml.url({'created' => Time.now, 'id' => (i + 1).to_s}) do
47
+ xml.short_url x
48
+ xml.full_url
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ File.open(filename,'w'){|f| f.write buffer}
55
+ end
56
+
57
+ private
20
58
 
21
59
  def iterate_chars(array_size)
22
60
  (0..array_size).each {|i|
@@ -41,10 +79,6 @@ class ShortUrlCreator
41
79
  end
42
80
  end
43
81
 
44
- def generate(count)
45
- get_short_url(count)
46
- @short_url
47
- end
48
82
  def get_short_url(count)
49
83
  if count > @array_size
50
84
  new_count = count - @array_size
metadata CHANGED
@@ -1,14 +1,13 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: short-url-creator
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - James Robertson
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain:
10
+ cert_chain:
12
11
  - |
13
12
  -----BEGIN CERTIFICATE-----
14
13
  MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
@@ -30,46 +29,50 @@ cert_chain:
30
29
  ihN3n0NCtp+K8/b8sHty+iDjcBvjItB8ViYb+/7bB8o3JPmPtpdna2BOC9MdWKbb
31
30
  za5fMgAiPY32oeIYADLOJ6Zgm+xLxs+c
32
31
  -----END CERTIFICATE-----
33
-
34
- date: 2013-02-06 00:00:00 Z
35
- dependencies: []
36
-
32
+ date: 2013-05-19 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: builder
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
37
48
  description:
38
49
  email:
39
50
  executables: []
40
-
41
51
  extensions: []
42
-
43
52
  extra_rdoc_files: []
44
-
45
- files:
53
+ files:
46
54
  - lib/short-url-creator.rb
47
55
  homepage:
48
56
  licenses: []
49
-
57
+ metadata: {}
50
58
  post_install_message:
51
59
  rdoc_options: []
52
-
53
- require_paths:
60
+ require_paths:
54
61
  - lib
55
- required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
67
72
  requirements: []
68
-
69
73
  rubyforge_project:
70
- rubygems_version: 1.8.23
74
+ rubygems_version: 2.0.0.rc.2
71
75
  signing_key:
72
- specification_version: 3
76
+ specification_version: 4
73
77
  summary: short-url-creator
74
78
  test_files: []
75
-
metadata.gz.sig CHANGED
Binary file