distributer 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07cd2a0fc0f52ce28594180b19b99845a9ee8fba
4
+ data.tar.gz: 91b88a7582fd5ddf6df7f0812bfe0b0627e0de0a
5
+ SHA512:
6
+ metadata.gz: a7371c91a7f1708357e83324453d588f7de65c686c421a2d9dac2ab6535331e20720c89c0e9484e6d1f0ceedcb90617cf4af4ef4e471de923cbfaa6c229eb005
7
+ data.tar.gz: c9cedd290c0d1457a819fb307b852b1379de0147050ee4336f01d88123d09c851a8bf7c931ee292dcd210c600a2acba973f0c3e471851c71d1bf2cdb93ad90aa
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in service-desk.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ distributer (1.0.5)
5
+ methadone
6
+ shotgun
7
+ sinatra
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ methadone (1.2.3)
13
+ bundler
14
+ rack (1.5.2)
15
+ rack-protection (1.3.2)
16
+ rack
17
+ rake (10.0.3)
18
+ shotgun (0.9)
19
+ rack (>= 1.0)
20
+ sinatra (1.3.4)
21
+ rack (~> 1.4)
22
+ rack-protection (~> 1.3)
23
+ tilt (~> 1.3, >= 1.3.3)
24
+ tilt (1.3.3)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ distributer!
31
+ rake
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Distributer
2
+
3
+ Version 2.0.0 is now the official most current version. Now using mongrel to serve file so large files do not crash your system when serving.
4
+
5
+ Anytime you want to share a few files just go to the directory you want to share.
6
+ Then type 'distributer'
7
+ or you can type 'distributer /path/to/directory'
8
+
9
+ You will be able to see what is going on from the server output in your terminal.
10
+
11
+ Location including port and ip is shown at start up of server.
12
+
13
+ Later versions will include an option for port number but right now I am super tired tonight and calling it good enough for now. Maybe this weekend Ill add it..
14
+
15
+ Also its at 3.0.0 because rubygems still thinks the old crap is there even after I gem yank and Im tired so I just made it 3.0.0 to get it out and me in bed.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'distributer'
22
+
23
+ And then execute:
24
+
25
+ $ bundle install
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install distributer
30
+
31
+ ## Usage
32
+
33
+ Usage: distributer or distributer directory
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/distributer ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'distributer'
6
+
7
+ include Methadone::Main
8
+ include Methadone::CLILogging
9
+
10
+ main do |config|
11
+ if config.nil?
12
+ Distributer.serve(Dir.pwd)
13
+ else
14
+ Distributer.serve(config)
15
+ end
16
+ end
17
+
18
+ description 'A tool for quickly distributing files from a directory over a network'
19
+
20
+ arg :directory, :optional
21
+
22
+ go!
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'distributer/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "distributer"
8
+ gem.version = Distributer::VERSION
9
+ gem.authors = ["tylerjones"]
10
+ gem.email = ["tyhampjone@gmail.com"]
11
+ gem.description = %q{Allows files to be distributed from a directory via HTTP.}
12
+ gem.summary = %q{Uses either the specified directory or the current directory.}
13
+ gem.homepage = "https://github.com/tylerhjones/distributer"
14
+
15
+ gem.add_dependency "sinatra"
16
+ gem.add_dependency "methadone"
17
+ gem.add_dependency "mongrel"
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,20 @@
1
+ # require "distributer/app.rb"
2
+ # require "distributer/config.ru"
3
+ require 'socket'
4
+
5
+ module Distributer
6
+ extend self
7
+
8
+ def serve(directory)
9
+ if directory.end_with?("/")
10
+ $directory = directory
11
+ else
12
+ $directory = directory + "/"
13
+ end
14
+ $ip = IPSocket.getaddress(Socket.gethostname)
15
+ puts "Directory \"#{directory}\" Files being served at : http://" + $ip + ":9393"
16
+
17
+ require 'distributer/application/app.rb'
18
+ end
19
+
20
+ end
@@ -0,0 +1,83 @@
1
+ require "sinatra"
2
+ require "pathname"
3
+
4
+
5
+ class DistributerSinatra < Sinatra::Base
6
+
7
+ set :static, true # set up static file routing
8
+
9
+ set :server, 'mongrel'
10
+
11
+ set :port, '9393'
12
+ set :host, $ip
13
+
14
+ helpers do
15
+ FileName = Struct.new(:name, :directory)
16
+
17
+ def get_files(public_dir)
18
+ puts "SERVING LIST OF : " + public_dir
19
+ pn = Pathname.new(public_dir).children()
20
+ array_of_things = Array.new
21
+
22
+
23
+ pn.each do |name|
24
+ # two subs to remove / at the front of a specified directory
25
+ short_name = name.sub(/#{$directory}/,"").sub(/^\//,"")
26
+ array_of_things.push(FileName.new(short_name, name.directory?))
27
+ end
28
+ @arr = array_of_things
29
+ erb :index
30
+ end
31
+
32
+ def give_file(file_path)
33
+ file_path.sub!(/\/\//,"\/")
34
+ puts "REQUESTED FILE_PATH : " + file_path
35
+ if File.exists? file_path
36
+ if File.directory? file_path
37
+ puts "FILE IS A DIRECTORY"
38
+ return get_files(file_path)
39
+ else
40
+ puts "RETURNING FILE : " + file_path
41
+ send_file(file_path, :disposition => 'attachment', :filename => File.basename(file_path))
42
+ end
43
+ else
44
+ return "File does not exist."
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ get "/" do
51
+ get_files($directory)
52
+ end
53
+
54
+ get '/*' do
55
+ if request.path_info.include? ".."
56
+ return " The .. is not allowed"
57
+ else
58
+ give_file($directory + request.path_info)
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+
65
+ DistributerSinatra.run!
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
@@ -0,0 +1,25 @@
1
+
2
+ <html>
3
+ <head>
4
+ <title>Tyler Jones Blog</title>
5
+ </head>
6
+ <body>
7
+
8
+ <h2>File List</h2>
9
+
10
+
11
+ <% @arr.each do |file| %>
12
+ <% if file.directory %>
13
+ <span class="info-directory">Directory</span>
14
+ <a href="/<%=file.name%>">
15
+ <%=file.name %>
16
+ </a>
17
+ <br/>
18
+ <% else %>
19
+ <span class="info-file">File</span>
20
+ <a href="/<%=file.name%>">
21
+ <%=file.name %>
22
+ </a>
23
+ <br/>
24
+ <% end %>
25
+ <% end %>
@@ -0,0 +1,3 @@
1
+ module Distributer
2
+ VERSION = "3.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: distributer
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tylerjones
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: methadone
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongrel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Allows files to be distributed from a directory via HTTP.
56
+ email:
57
+ - tyhampjone@gmail.com
58
+ executables:
59
+ - distributer
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - bin/distributer
68
+ - distributer.gemspec
69
+ - lib/Distributer.rb
70
+ - lib/distributer/application/app.rb
71
+ - lib/distributer/application/views/index.erb
72
+ - lib/distributer/version.rb
73
+ homepage: https://github.com/tylerhjones/distributer
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.0
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Uses either the specified directory or the current directory.
96
+ test_files: []