purvey 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in purvey.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ purvey (0.0.1)
5
+ ftpd (~> 0.6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ ftpd (0.6.0)
12
+ memoizer (~> 1.0.1)
13
+ memoizer (1.0.1)
14
+ rspec (2.12.0)
15
+ rspec-core (~> 2.12.0)
16
+ rspec-expectations (~> 2.12.0)
17
+ rspec-mocks (~> 2.12.0)
18
+ rspec-core (2.12.2)
19
+ rspec-expectations (2.12.1)
20
+ diff-lcs (~> 1.1.3)
21
+ rspec-mocks (2.12.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ purvey!
28
+ rspec (~> 2.12.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alfonso Cora
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Purvey
2
+
3
+ Purvey is a command line application that allows to quickly start an ftp server without worrying about configuration. This makes it a handy tool to transfer files easily. It's not intended to be used in public servers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install purvey
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ To simply start the server at any available port serving the files from the current directory, run:
14
+
15
+ ```bash
16
+ purvey
17
+ ```
18
+
19
+ ## Options
20
+
21
+ - -h HOST: The interface where the server should start. When not specified, the server will start on localhost.
22
+ - -p PORT: The port where the server should start. When not specified, a random available port will be chosen.
23
+
24
+ ### Examples
25
+
26
+ ```bash
27
+ # start the server in localhost, under port 3002 and files from the current directory:
28
+ purvey -p 3002
29
+
30
+ # start the server in 192.168.1.1:9000 and serve files from /tmp/dir:
31
+ purvey /tmp/dir -h 192.168.1.1 -p 9000
32
+ ```
33
+
34
+ ## TODO
35
+ ### Authentication
36
+ An easy way to setup users and password is pending. For now the server runs without any kind of authentication.
37
+
38
+ ## Contributions and credits
39
+
40
+ This project is based on the [ftpd gem by Wayne Conrad](https://github.com/wconrad/ftpd/).
41
+ If you want to contribute to this project, just fork it and create a pull request. Also, feel free to report issues on the [issues section](issues).
42
+
43
+ ## License
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2012 Alfonso Cora
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
54
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/purvey ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ftpd'
4
+ require 'purvey'
5
+ require 'pathname'
6
+ require 'logger'
7
+
8
+ trap('SIGINT') { throw :ctrl_c }
9
+
10
+ def get_argv(option)
11
+ value = nil
12
+ if option_index = ARGV.index(option)
13
+ value = ARGV[option_index + 1]
14
+ ARGV.slice!(option_index..option_index+1)
15
+ end
16
+ value
17
+ end
18
+
19
+ host = get_argv('-h')
20
+ port = get_argv('-p').to_i
21
+
22
+ if ARGV.any? {|f| f == '--help'}
23
+ # help mode
24
+ puts 'Usage:'
25
+ puts ' purvey [path/to/directory] [-h HOST] [-p PORT]'
26
+ else
27
+ path = ARGV.first || '.'
28
+ path = Pathname.new(path).realpath.to_s
29
+
30
+ driver = Purvey::Driver.new(path)
31
+ server = Ftpd::FtpServer.new(driver)
32
+ server.server_name = "Purvey"
33
+ server.server_version = Purvey::VERSION
34
+ server.log = Logger.new(STDOUT)
35
+ server.interface = host if host
36
+ server.port = port if port
37
+ server.start
38
+
39
+ puts "#{server.server_name} #{server.server_version}"
40
+ puts "Server listening on #{server.interface}:#{server.bound_port}"
41
+ puts "Serving all files under '#{path}'"
42
+ puts "Press Ctrl+C to stop"
43
+ begin
44
+ sleep
45
+ rescue Exception
46
+ end
47
+ end
data/lib/purvey.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'purvey/version'
2
+ require 'purvey/driver'
@@ -0,0 +1,15 @@
1
+ module Purvey
2
+ class Driver
3
+ def initialize(dir)
4
+ @dir = dir
5
+ end
6
+
7
+ def authenticate(user, password)
8
+ true
9
+ end
10
+
11
+ def file_system(user)
12
+ Ftpd::DiskFileSystem.new(@dir)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Purvey
2
+ VERSION = "0.0.1"
3
+ end
data/purvey.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'purvey/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "purvey"
8
+ gem.version = Purvey::VERSION
9
+ gem.authors = ["Alfonso Cora"]
10
+ gem.email = ["acora6@gmail.com"]
11
+ gem.description = %q{Purvey is an in-place ftp server}
12
+ gem.summary = %q{Purvey is a command line application that allows to quickly start an ftp server without worrying about configuration. This makes it a handy tool to transfer files easily. It's not intended to be used in public servers.}
13
+ gem.homepage = "https://github.com/alfonsocora/purvey"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'ftpd', '~> 0.6.0'
21
+ gem.add_development_dependency 'rspec', '~> 2.12.0'
22
+ end
@@ -0,0 +1,9 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ require 'purvey'
4
+
5
+ Dir[File.expand_path("support/*", File.dirname(__FILE__))].each {|f| require f}
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :rspec
9
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: purvey
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alfonso Cora
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ftpd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.6.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.12.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.12.0
46
+ description: Purvey is an in-place ftp server
47
+ email:
48
+ - acora6@gmail.com
49
+ executables:
50
+ - purvey
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/purvey
60
+ - lib/purvey.rb
61
+ - lib/purvey/driver.rb
62
+ - lib/purvey/version.rb
63
+ - purvey.gemspec
64
+ - spec/spec_helper.rb
65
+ homepage: https://github.com/alfonsocora/purvey
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.23
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Purvey is a command line application that allows to quickly start an ftp
89
+ server without worrying about configuration. This makes it a handy tool to transfer
90
+ files easily. It's not intended to be used in public servers.
91
+ test_files:
92
+ - spec/spec_helper.rb
93
+ has_rdoc: