lyrics 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +45 -0
  6. data/VERSION +1 -0
  7. data/bin/lyrics +66 -0
  8. data/lib/lyrics.rb +4 -0
  9. data/lib/lyrics/cli/application.rb +99 -0
  10. data/lib/lyrics/cli/optionsparser.rb +228 -0
  11. data/lib/lyrics/cli/pluginadapter.rb +56 -0
  12. data/lib/lyrics/cli/plugins.rb +79 -0
  13. data/lib/lyrics/cli/wikipluginadapter.rb +139 -0
  14. data/lib/lyrics/i18n/README +1 -0
  15. data/lib/lyrics/i18n/en.rb +181 -0
  16. data/lib/lyrics/i18n/es.rb +181 -0
  17. data/lib/lyrics/i18n/i18n.rb +126 -0
  18. data/lib/lyrics/i18n/sk.rb +174 -0
  19. data/lib/lyrics/itrans/COPYRIGHT +31 -0
  20. data/lib/lyrics/itrans/itrans +0 -0
  21. data/lib/lyrics/itrans/itrans.txt +8 -0
  22. data/lib/lyrics/itrans/lyric.txt +23 -0
  23. data/lib/lyrics/itrans/udvng.ifm +206 -0
  24. data/lib/lyrics/lyrics.rb +567 -0
  25. data/lib/lyrics/lyrics_AZLyrics.rb +113 -0
  26. data/lib/lyrics/lyrics_DarkLyrics.rb +124 -0
  27. data/lib/lyrics/lyrics_Giitaayan.rb +124 -0
  28. data/lib/lyrics/lyrics_Jamendo.rb +166 -0
  29. data/lib/lyrics/lyrics_LeosLyrics.rb +142 -0
  30. data/lib/lyrics/lyrics_LoudSongs.rb +135 -0
  31. data/lib/lyrics/lyrics_LyricWiki.rb +328 -0
  32. data/lib/lyrics/lyrics_LyricsDownload.rb +118 -0
  33. data/lib/lyrics/lyrics_LyricsMania.rb +141 -0
  34. data/lib/lyrics/lyrics_Lyriki.rb +286 -0
  35. data/lib/lyrics/lyrics_SeekLyrics.rb +108 -0
  36. data/lib/lyrics/lyrics_Sing365.rb +103 -0
  37. data/lib/lyrics/lyrics_TerraLetras.rb +126 -0
  38. data/lib/lyrics/mediawikilyrics.rb +1417 -0
  39. data/lib/lyrics/utils/formdata.rb +56 -0
  40. data/lib/lyrics/utils/htmlentities.rb +291 -0
  41. data/lib/lyrics/utils/http.rb +198 -0
  42. data/lib/lyrics/utils/itrans.rb +160 -0
  43. data/lib/lyrics/utils/logger.rb +123 -0
  44. data/lib/lyrics/utils/strings.rb +378 -0
  45. data/lib/lyrics/utils/xmlhash.rb +111 -0
  46. data/lyrics.gemspec +98 -0
  47. data/spec/lyrics_spec.rb +7 -0
  48. data/spec/spec.opts +1 -0
  49. data/spec/spec_helper.rb +9 -0
  50. metadata +137 -0
@@ -0,0 +1,111 @@
1
+ # Copyright (C) 2006-2008 by Sergio Pistone
2
+ # sergio_pistone@yahoo.com.ar
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the
16
+ # Free Software Foundation, Inc.,
17
+ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
+
19
+ require "rexml/document"
20
+
21
+ module XMLHash
22
+
23
+ def XMLHash.write( file, hash )
24
+
25
+ begin
26
+ read_file = nil
27
+ read_file = file.is_a?( File ) ? file : File.new( file, "r" )
28
+ root = REXML::Document.new( read_file ).root
29
+ rescue Exception
30
+ root = REXML::Document.new( "<?xml version='1.0' encoding='UTF-8' ?>" ).add_element( "settings" )
31
+ ensure
32
+ read_file.close() if read_file
33
+ end
34
+
35
+ begin
36
+ write_file = nil
37
+ if ( file.is_a?( File ) )
38
+ file.reopen( file.path, "w+" )
39
+ write_file = file
40
+ else
41
+ write_file = File.new( file, "w+" )
42
+ end
43
+ hash.each do |key, value|
44
+ element = root.elements[key]
45
+ element = root.add_element( key ) if ! element
46
+ element.text = value.is_a?( Array ) ? value.join( "\n" ) : value.to_s()
47
+ element.add_attribute( "type", value.class.name.downcase )
48
+ end
49
+ root.parent.write( write_file )
50
+ write_file.flush()
51
+ return true
52
+ rescue Exception => e
53
+ puts e
54
+ puts e.backtrace
55
+ return false
56
+ ensure
57
+ write_file.close() if write_file != file
58
+ end
59
+
60
+ end
61
+
62
+ def XMLHash.read( file, hash, only_hash_keys=true )
63
+
64
+ begin
65
+ read_file = nil
66
+ read_file = file.is_a?( File ) ? file : File.new( file, "r" )
67
+ elements = REXML::Document.new( read_file ).root.elements
68
+ return false if elements == nil
69
+ rescue Exception => e
70
+ return false
71
+ ensure
72
+ read_file.close() if read_file && read_file != file
73
+ end
74
+
75
+ requested_keys = hash.keys
76
+
77
+ keys = hash.keys
78
+ if ! only_hash_keys
79
+ elements.each() do |element|
80
+ key = element.name
81
+ keys << key if ! keys.include?( key )
82
+ end
83
+ end
84
+
85
+ read_keys = []
86
+ keys.each() do |key|
87
+ if elements[key]
88
+ value = elements[key].text.to_s()
89
+ type = elements[key].attribute( "type" ).to_s()
90
+ if type == "array"
91
+ hash[key] = value.split( "\n" )
92
+ elsif ( type == "fixnum" )
93
+ hash[key] = value.to_i()
94
+ elsif ( type == "float" )
95
+ hash[key] = value.to_f()
96
+ elsif ( type == "trueclass" )
97
+ hash[key] = true
98
+ elsif ( type == "falseclass" )
99
+ hash[key] = false
100
+ else
101
+ hash[key] = value
102
+ end
103
+ read_keys << key
104
+ end
105
+ end
106
+
107
+ return (requested_keys - read_keys).empty?
108
+
109
+ end
110
+
111
+ end
@@ -0,0 +1,98 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{lyrics}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David A. Cuadrado"]
12
+ s.date = %q{2010-07-21}
13
+ s.default_executable = %q{lyrics}
14
+ s.description = %q{lib and cli to fetch lyrics}
15
+ s.email = %q{krawek@gmail.com}
16
+ s.executables = ["lyrics"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/lyrics",
29
+ "lib/lyrics.rb",
30
+ "lib/lyrics/cli/application.rb",
31
+ "lib/lyrics/cli/optionsparser.rb",
32
+ "lib/lyrics/cli/pluginadapter.rb",
33
+ "lib/lyrics/cli/plugins.rb",
34
+ "lib/lyrics/cli/wikipluginadapter.rb",
35
+ "lib/lyrics/i18n/README",
36
+ "lib/lyrics/i18n/en.rb",
37
+ "lib/lyrics/i18n/es.rb",
38
+ "lib/lyrics/i18n/i18n.rb",
39
+ "lib/lyrics/i18n/sk.rb",
40
+ "lib/lyrics/itrans/COPYRIGHT",
41
+ "lib/lyrics/itrans/itrans",
42
+ "lib/lyrics/itrans/itrans.txt",
43
+ "lib/lyrics/itrans/lyric.txt",
44
+ "lib/lyrics/itrans/udvng.ifm",
45
+ "lib/lyrics/lyrics.rb",
46
+ "lib/lyrics/lyrics_AZLyrics.rb",
47
+ "lib/lyrics/lyrics_DarkLyrics.rb",
48
+ "lib/lyrics/lyrics_Giitaayan.rb",
49
+ "lib/lyrics/lyrics_Jamendo.rb",
50
+ "lib/lyrics/lyrics_LeosLyrics.rb",
51
+ "lib/lyrics/lyrics_LoudSongs.rb",
52
+ "lib/lyrics/lyrics_LyricWiki.rb",
53
+ "lib/lyrics/lyrics_LyricsDownload.rb",
54
+ "lib/lyrics/lyrics_LyricsMania.rb",
55
+ "lib/lyrics/lyrics_Lyriki.rb",
56
+ "lib/lyrics/lyrics_SeekLyrics.rb",
57
+ "lib/lyrics/lyrics_Sing365.rb",
58
+ "lib/lyrics/lyrics_TerraLetras.rb",
59
+ "lib/lyrics/mediawikilyrics.rb",
60
+ "lib/lyrics/utils/formdata.rb",
61
+ "lib/lyrics/utils/htmlentities.rb",
62
+ "lib/lyrics/utils/http.rb",
63
+ "lib/lyrics/utils/itrans.rb",
64
+ "lib/lyrics/utils/logger.rb",
65
+ "lib/lyrics/utils/strings.rb",
66
+ "lib/lyrics/utils/xmlhash.rb",
67
+ "lyrics.gemspec",
68
+ "spec/lyrics_spec.rb",
69
+ "spec/spec.opts",
70
+ "spec/spec_helper.rb"
71
+ ]
72
+ s.homepage = %q{http://github.com/dcu/lyrics}
73
+ s.rdoc_options = ["--charset=UTF-8"]
74
+ s.require_paths = ["lib"]
75
+ s.rubygems_version = %q{1.3.6}
76
+ s.summary = %q{lib and cli to fetch lyrics}
77
+ s.test_files = [
78
+ "spec/lyrics_spec.rb",
79
+ "spec/spec_helper.rb"
80
+ ]
81
+
82
+ if s.respond_to? :specification_version then
83
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
84
+ s.specification_version = 3
85
+
86
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
87
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
88
+ s.add_development_dependency(%q<yard>, [">= 0"])
89
+ else
90
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
91
+ s.add_dependency(%q<yard>, [">= 0"])
92
+ end
93
+ else
94
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
95
+ s.add_dependency(%q<yard>, [">= 0"])
96
+ end
97
+ end
98
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Lyrics" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'lyrics'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lyrics
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - David A. Cuadrado
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-21 00:00:00 -05:00
18
+ default_executable: lyrics
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: yard
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ description: lib and cli to fetch lyrics
47
+ email: krawek@gmail.com
48
+ executables:
49
+ - lyrics
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - .document
57
+ - .gitignore
58
+ - LICENSE
59
+ - README.rdoc
60
+ - Rakefile
61
+ - VERSION
62
+ - bin/lyrics
63
+ - lib/lyrics.rb
64
+ - lib/lyrics/cli/application.rb
65
+ - lib/lyrics/cli/optionsparser.rb
66
+ - lib/lyrics/cli/pluginadapter.rb
67
+ - lib/lyrics/cli/plugins.rb
68
+ - lib/lyrics/cli/wikipluginadapter.rb
69
+ - lib/lyrics/i18n/README
70
+ - lib/lyrics/i18n/en.rb
71
+ - lib/lyrics/i18n/es.rb
72
+ - lib/lyrics/i18n/i18n.rb
73
+ - lib/lyrics/i18n/sk.rb
74
+ - lib/lyrics/itrans/COPYRIGHT
75
+ - lib/lyrics/itrans/itrans
76
+ - lib/lyrics/itrans/itrans.txt
77
+ - lib/lyrics/itrans/lyric.txt
78
+ - lib/lyrics/itrans/udvng.ifm
79
+ - lib/lyrics/lyrics.rb
80
+ - lib/lyrics/lyrics_AZLyrics.rb
81
+ - lib/lyrics/lyrics_DarkLyrics.rb
82
+ - lib/lyrics/lyrics_Giitaayan.rb
83
+ - lib/lyrics/lyrics_Jamendo.rb
84
+ - lib/lyrics/lyrics_LeosLyrics.rb
85
+ - lib/lyrics/lyrics_LoudSongs.rb
86
+ - lib/lyrics/lyrics_LyricWiki.rb
87
+ - lib/lyrics/lyrics_LyricsDownload.rb
88
+ - lib/lyrics/lyrics_LyricsMania.rb
89
+ - lib/lyrics/lyrics_Lyriki.rb
90
+ - lib/lyrics/lyrics_SeekLyrics.rb
91
+ - lib/lyrics/lyrics_Sing365.rb
92
+ - lib/lyrics/lyrics_TerraLetras.rb
93
+ - lib/lyrics/mediawikilyrics.rb
94
+ - lib/lyrics/utils/formdata.rb
95
+ - lib/lyrics/utils/htmlentities.rb
96
+ - lib/lyrics/utils/http.rb
97
+ - lib/lyrics/utils/itrans.rb
98
+ - lib/lyrics/utils/logger.rb
99
+ - lib/lyrics/utils/strings.rb
100
+ - lib/lyrics/utils/xmlhash.rb
101
+ - lyrics.gemspec
102
+ - spec/lyrics_spec.rb
103
+ - spec/spec.opts
104
+ - spec/spec_helper.rb
105
+ has_rdoc: true
106
+ homepage: http://github.com/dcu/lyrics
107
+ licenses: []
108
+
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --charset=UTF-8
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project:
131
+ rubygems_version: 1.3.6
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: lib and cli to fetch lyrics
135
+ test_files:
136
+ - spec/lyrics_spec.rb
137
+ - spec/spec_helper.rb