turingstudio-webloc_cleaner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2009-01-20
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,9 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ bin/webloc_cleaner
6
+ lib/webloc_cleaner.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
data/README.rdoc ADDED
@@ -0,0 +1,34 @@
1
+ = webloc_cleaner
2
+
3
+ http://github.com/turingstudio/webloc_cleaner/
4
+
5
+ == DESCRIPTION:
6
+
7
+ This RubyGem searches a path for webloc files, displays a list of OK and damaged files, and converts them to url files.
8
+
9
+ == INSTALL:
10
+
11
+ gem install turingstudio-webloc_cleaner
12
+
13
+ == LICENSE:
14
+
15
+ Copyright (c) 2009 The Turing Studio, Inc.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining
18
+ a copy of this software and associated documentation files (the
19
+ 'Software'), to deal in the Software without restriction, including
20
+ without limitation the rights to use, copy, modify, merge, publish,
21
+ distribute, sublicense, and/or sell copies of the Software, and to
22
+ permit persons to whom the Software is furnished to do so, subject to
23
+ the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be
26
+ included in all copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
29
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
31
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
32
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
33
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
34
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/webloc_cleaner'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('webloc_cleaner', WeblocCleaner::VERSION) do |p|
7
+ p.developer('The Turing Studio, Inc.', 'support@turingstudio.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ # p.rubyforge_name = nil
10
+ p.extra_deps = [
11
+ ['activesupport', '>= 2.0.2'],
12
+ ['simpleconsole', '>= 0.1.1']
13
+ ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ # path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ # p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ # p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2009-1-20.
4
+ # Copyright (c) 2009. All rights reserved.
5
+
6
+ require 'webloc_cleaner'
7
+
8
+ # begin
9
+ SimpleConsole::Application.run(ARGV.clone, WeblocCleaner::Controller)
10
+ # rescue
11
+ # WeblocCleaner::Controller.usage
12
+ # end
@@ -0,0 +1,80 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'simpleconsole'
5
+ require 'activesupport'
6
+
7
+ module WeblocCleaner
8
+ VERSION = '0.0.1'
9
+
10
+ class Controller < SimpleConsole::Controller
11
+ def default
12
+ self.class.usage
13
+ end
14
+
15
+ def list
16
+ ok, damaged = webloc_files(params[:id])
17
+
18
+ unless ok.empty?
19
+ puts 'OK:'
20
+ ok.each { |f| puts(f) }
21
+ end
22
+
23
+ puts '' unless ok.empty? && damaged.empty?
24
+
25
+ unless damaged.empty?
26
+ puts 'Damaged:'
27
+ damaged.each { |f| puts(f) }
28
+ end
29
+ end
30
+
31
+ def convert
32
+ ok, damaged = webloc_files(params[:id])
33
+
34
+ ok.each do |file|
35
+ url = webloc_url(file)
36
+ File.open(file.gsub(/\.webloc$/, '.url'), 'w') do |f|
37
+ f.write "[InternetShortcut]\r\nURL=#{url}"
38
+ end
39
+ File.delete(file)
40
+ end
41
+ end
42
+
43
+ class << self
44
+ def usage
45
+ puts "Usage:"
46
+ puts " #{program_name} list PATH"
47
+ puts " #{program_name} convert PATH"
48
+ end
49
+
50
+ def program_name
51
+ File.basename($0)
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def webloc_url(path)
58
+ %x[strings "#{path}/rsrc" | grep http | sed '/^.http/s//http/' | head -1]
59
+ end
60
+
61
+ def webloc_ok?(path)
62
+ !webloc_url(path).empty?
63
+ end
64
+
65
+ def webloc_files(path)
66
+ ok = []
67
+ damaged = []
68
+
69
+ Dir["#{path}/*.webloc"].each do |file|
70
+ if webloc_ok?(file)
71
+ ok << file
72
+ else
73
+ damaged << file
74
+ end
75
+ end
76
+
77
+ [ok, damaged]
78
+ end
79
+ end
80
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/webloc_cleaner.rb'}"
9
+ puts "Loading webloc_cleaner gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turingstudio-webloc_cleaner
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - The Turing Studio, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-30 00:00:00 -08:00
13
+ default_executable: webloc_cleaner
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.2
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: simpleconsole
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.1.1
32
+ version:
33
+ description: This RubyGem searches a path for webloc files, displays a list of OK and damaged files, and converts them to url files.
34
+ email:
35
+ - support@turingstudio.com
36
+ executables:
37
+ - webloc_cleaner
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README.rdoc
42
+ files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - README.rdoc
46
+ - Rakefile
47
+ - bin/webloc_cleaner
48
+ - lib/webloc_cleaner.rb
49
+ - script/console
50
+ - script/destroy
51
+ - script/generate
52
+ has_rdoc: true
53
+ homepage: http://github.com/turingstudio/webloc_cleaner/
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ requirements: []
72
+
73
+ rubyforge_project: webloc_cleaner
74
+ rubygems_version: 1.2.0
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: This RubyGem searches a path for webloc files, displays a list of OK and damaged files, and converts them to url files.
78
+ test_files: []
79
+