rfuse_flac_to_mov_fs 0.0.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.
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rfuse_flac_to_mov_fs'
5
+ require 'rfuse_flac_to_mov_fs_opts'
6
+ require 'fileutils'
7
+
8
+
9
+ options = RFuseFlacToMovFSOpts.parse(ARGV)
10
+
11
+ filesystem = RFuseFlacToMovFS.new(options)
12
+ FuseFS.set_root( filesystem )
13
+
14
+ FileUtils.mkdir_p( options.mountpoint )
15
+
16
+ # Mount under a directory given on the command line.
17
+ FuseFS.mount_under options.mountpoint
18
+ FuseFS.run
19
+
@@ -0,0 +1,127 @@
1
+ require "rubygems"
2
+ require 'fusefs'
3
+ require 'rfuse_flac_to_mov_fs_opts'
4
+ #require 'pp'
5
+
6
+ class RFuseFlacToMovFS
7
+ # contents( path )
8
+ # file?( path )
9
+ # directory?( path )
10
+ # read_file( path )
11
+ # size( path )
12
+ #
13
+ # save
14
+ # touch( path )
15
+ # can_write?(path)
16
+ # write_to(path,body)
17
+ #
18
+ # can_delete?(path)
19
+ # delete( path )
20
+ #
21
+ # can_mkdir?( path )
22
+ # mkdir( path )
23
+ # can_rmdir( path )
24
+ # rmdir( path )
25
+ #
26
+
27
+
28
+
29
+ def initialize( options )
30
+ puts "#{__FILE__} initialize( #{options.input} )"
31
+ @base_dir = options.input
32
+ end
33
+
34
+ def contents(path)
35
+ n_path = File.expand_path( @base_dir + path )
36
+ Dir.chdir(n_path)
37
+
38
+ # TODO
39
+ # Currently just return a list of files we need to search and replace /.flac$/.mov/i
40
+
41
+ files = Dir.glob('*')
42
+ #Added command to OS X Finder not to index.
43
+ #files << 'metadata_never_index'
44
+
45
+ # incase esensitive match
46
+ files.each do |x|
47
+ x.gsub!(/\.flac$/i, ".mov")
48
+ puts x
49
+ end
50
+
51
+ return files
52
+ end
53
+
54
+ def file?(path)
55
+ #If path ends with metadata_never_index it is a file
56
+ #if path =~ /metadata_never_index$/
57
+ # return true
58
+ #end
59
+
60
+ #Need method which checks for .flac or jut not directory and everything is a file
61
+ return (not File.directory?( @base_dir + path ))
62
+ end
63
+
64
+ def directory?(path)
65
+ File.directory?(@base_dir + path)
66
+ end
67
+
68
+ def read_file(path)
69
+ input = path.dup
70
+
71
+ if File.exists?( @base_dir + input)
72
+ return File.new(@base_dir + input , "r").read
73
+ end
74
+
75
+ # mmm replacment was not case sensitive so we do not actually
76
+ # know the correct case of the file extension
77
+ # NB: the most popular format of HFS+ (mac drives) is not case sensitive
78
+ # so these should resolve correctly for now
79
+ if input =~ /\.mov$/
80
+ input['.mov'] = '.flac'
81
+ end
82
+ #puts "read file #{path}"
83
+ if File.exists?( @base_dir + input)
84
+ return File.new(@base_dir + input , "r").read
85
+ end
86
+
87
+ return "ERROR, file not found\n"
88
+
89
+ end
90
+
91
+
92
+ def size(path)
93
+ puts "size( #{path}"
94
+ input = path.dup
95
+
96
+ if File.exists?( @base_dir + path )
97
+ return File.size( @base_dir + path )
98
+ end
99
+
100
+ if input =~ /\.mov$/
101
+ puts " Converting from mov to flac"
102
+ input['.mov'] = '.flac'
103
+ end
104
+
105
+
106
+ if File.exists?( @base_dir + input )
107
+ return File.size( @base_dir + input )
108
+ else
109
+ return 16
110
+ end
111
+ end
112
+ end
113
+
114
+
115
+ if $0 == __FILE__
116
+
117
+ options = RFuseFlacToMovFSOpts.parse(ARGV)
118
+ filesystem = RFuseFlacToMovFS.new( options )
119
+ FuseFS.set_root( filesystem )
120
+
121
+ FileUtils.mkdir_p( options.mountpoint )
122
+
123
+ # Mount under a directory given on the command line.
124
+ FuseFS.mount_under options.mountpoint
125
+ FuseFS.run
126
+ end
127
+
@@ -0,0 +1,72 @@
1
+ require 'optparse'
2
+ require 'optparse/time'
3
+ require 'ostruct'
4
+
5
+ class RFuseFlacToMovFSOpts
6
+
7
+
8
+ #
9
+ # Return a structure describing the options.
10
+ #
11
+ def self.parse(args)
12
+ @VERSION = "0.0.2"
13
+
14
+ # The options specified on the command line will be collected in *options*.
15
+ # We set default values here.
16
+ options = OpenStruct.new
17
+
18
+ options.verbose = false
19
+ options.mountpoint = ""
20
+ options.input = ""
21
+
22
+
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = "Usage: #{__FILE__} [options]"
25
+ opts.separator ""
26
+ opts.separator "Common options:"
27
+
28
+ # No argument, shows at tail. This will print an options summary.
29
+ opts.on("-h", "--help", "Show this message") do
30
+ puts opts
31
+ exit
32
+ end
33
+
34
+ # Another typical switch to print the version.
35
+ opts.on("--version", "Show version") do
36
+ #puts OptionParser::Version.join('.')
37
+ puts "Version #{@VERSION}"
38
+ exit
39
+ end
40
+
41
+ # Boolean switch.
42
+ #opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
43
+ # options.verbose = v
44
+ #end
45
+
46
+ opts.separator ""
47
+ opts.separator "Specific options:"
48
+
49
+
50
+ # Cast 'delay' argument to a Float.
51
+ opts.on("--mountpoint path", String, "Root of new Filesystem") do |n|
52
+ options.mountpoint = n
53
+ end
54
+
55
+ opts.on("--input N", String, "Folder FS will point to") do |n|
56
+ options.input = File.expand_path( n )
57
+ end
58
+
59
+
60
+ end
61
+
62
+ options.leftovers = opts.parse!(args)
63
+
64
+ if (options.mountpoint == "") and (options.input == "") and (options.leftovers.size==2)
65
+ options.mountpoint = options.leftovers[0]
66
+ options.input = File.expand_path( options.leftovers[1] )
67
+ end
68
+ return options
69
+ end # parse()
70
+
71
+ end # class OptparseExample
72
+
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rfuse_flac_to_mov_fs
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Morgan Prior
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-28 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: fusefs
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 0
34
+ version: 0.7.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: "Virtual Filesystem Written in Ruby Fuse, which lets *.flac look like *.mov for iTunes. Use incombination with the Xiph Component http://xiph.org/quicktime/download.html "
38
+ email: rfuse_flac_to_mov_fs_gem@amaras-tech.co.uk
39
+ executables:
40
+ - rfuse_flac_to_mov_fs
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - bin/rfuse_flac_to_mov_fs
47
+ - lib/rfuse_flac_to_mov_fs.rb
48
+ - lib/rfuse_flac_to_mov_fs_opts.rb
49
+ has_rdoc: true
50
+ homepage: http://amaras-tech.co.uk/software/rfuse_flac_to_mov_fs
51
+ licenses: []
52
+
53
+ post_install_message: To use 'rfuse_flac_to_mov_fs' as a standalone application your gems folder must be on your path
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Ruby Fuse, Filesystem to make *.flac files look like *.mov for itunes Mac OS X.
83
+ test_files: []
84
+