piedesaint 0.1.0 → 0.1.1

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: 7969c9a6b8f252cae38aa29a696de6778ddfca03
4
+ data.tar.gz: 95307f09524bef075344a7aeb233a57a8103d704
5
+ SHA512:
6
+ metadata.gz: fb34f96ffaa2c258e9358c5454af46a7618fe1c6e6c9200c79da19029ee48c8b8840d701039c1f9057b72d6035e2f2b12b6f8e9ca1ad126570d9cac6c57cfebd
7
+ data.tar.gz: 9395f2195125f870431fc2dbbddf0aa1f6c5415bbbe16aee1b2466b310234e013317fbe3ee561731db747f486a7a0c623a992e9be969a7f2d00d3a80c12abb75
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ ruby-2.1.1
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Piedesaint
2
2
 
3
+ [![Build Status](http://img.shields.io/travis/tnarik/piedesaint.svg)](https://travis-ci.org/tnarik/piedesaint)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/tnarik/piedesaint.svg)](https://codeclimate.com/github/tnarik/piedesaint)
5
+ [![Coveralls](http://img.shields.io/coveralls/tnarik/piedesaint.svg)](https://coveralls.io/r/tnarik/piedesaint)
6
+ [![RubyGems](http://img.shields.io/gem/v/piedesaint.svg)](http://rubygems.org/gems/piedesaint)
7
+ [![Gemnasium](http://img.shields.io/gemnasium/tnarik/piedesaint.svg)](https://gemnasium.com/tnarik/piedesaint)
8
+
3
9
  ## In short
4
10
 
5
11
  [Piedesaint](https://github.com/tnarik/piedesaint) is a minimal web server designed to expose directly files and directories (in [TAR](http://en.wikipedia.org/wiki/Tar_(computing) format) via HTTP or HTTPS.
@@ -40,6 +46,7 @@ After this, whenever you want to serve the files/directories, just execute:
40
46
 
41
47
  $ sug
42
48
 
49
+ Alternatively, by editing ```.piedesaint/config```, you can disable compressed folders (```:tar: false```) and the need for Basic Authorization credentials (using an empty ```:username:```).
43
50
 
44
51
  ## License
45
52
 
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :build
@@ -40,6 +40,9 @@ module Piedesaint
40
40
  username: "user",
41
41
  password: "password",
42
42
  freshness: 3600,
43
+ metastore: 'file:/tmp/rack/meta',
44
+ entitystore: 'file:/tmp/rack/body',
45
+ tar: true,
43
46
  folders: parameters }
44
47
 
45
48
  open 'config', 'w' do |io| io.write config.to_yaml end
@@ -48,6 +51,19 @@ module Piedesaint
48
51
  puts "Configuration created at #{Dir.pwd}/.piedesaint"
49
52
  end
50
53
 
54
+ def cert ( cert_subject = 'CN=Piedesaint' )
55
+ key, cert = create_ssl_artifacts
56
+
57
+ FileUtils.mkdir_p ".piedesaint"
58
+ FileUtils.cd ".piedesaint" do
59
+ FileUtils.mkdir_p "ssl"
60
+ FileUtils.cd "ssl" do
61
+ open 'server.key', 'w' do |io| io.write key.to_pem end
62
+ open 'server.crt', 'w' do |io| io.write cert.to_pem end
63
+ end
64
+ end
65
+ end
66
+
51
67
  private
52
68
  def load_config
53
69
  config_path = find_default_config_path
@@ -58,7 +74,7 @@ module Piedesaint
58
74
  @config = YAML.load_file File.join(config_path, "config")
59
75
  end
60
76
 
61
- def create_ssl_artifacts
77
+ def create_ssl_artifacts ( cert_subject = 'CN=Piedesaint' )
62
78
  key = OpenSSL::PKey::RSA.new 2048
63
79
 
64
80
  cert = OpenSSL::X509::Certificate.new
@@ -67,7 +83,7 @@ module Piedesaint
67
83
  cert.not_before = Time.now
68
84
  cert.not_after = Time.now + 3 * 3600
69
85
  cert.public_key = key.public_key
70
- name = OpenSSL::X509::Name.parse 'CN=Piedesaint'
86
+ name = OpenSSL::X509::Name.parse cert_subject
71
87
  cert.subject = name
72
88
  cert.issuer = name
73
89
  cert.sign key, OpenSSL::Digest::SHA1.new
@@ -1,3 +1,3 @@
1
1
  module Piedesaint
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/piedesaint.rb CHANGED
@@ -11,6 +11,7 @@ require 'rack/cache'
11
11
  require 'rubygems/package'
12
12
  require "stringio"
13
13
  require 'time'
14
+ require "uri"
14
15
 
15
16
 
16
17
  module Piedesaint
@@ -43,7 +44,7 @@ module Piedesaint
43
44
  @options[:folders].each do |root|
44
45
  root = File.expand_path root
45
46
  puts "Service root: #{root}"
46
- @apps << Rack::DirectoryCompress.new(root, app ? app : Rack::FileEtag.new(root) )
47
+ @apps << ( @options[:tar] ? Rack::DirectoryCompress.new(root, app ? app : Rack::FileEtag.new(root)) : ::Rack::Directory.new(root) )
47
48
  end
48
49
  end
49
50
 
@@ -76,17 +77,31 @@ module Piedesaint
76
77
  use ::Rack::ShowExceptions
77
78
  use ::Rack::SslEnforcer, http_port: options[:http_port], https_port: options[:https_port]
78
79
  use ::Rack::Deflater
79
- use ::Rack::Auth::Basic, "Icecreamland" do |username, password|
80
- ( options[:username] == username ) && ( options[:password] == password )
80
+
81
+ if options[:username].nil? or options[:username].empty?
82
+ puts "Service without Basic Authentication"
83
+ else
84
+ use ::Rack::Auth::Basic, "Icecreamland" do |username, password|
85
+ ( options[:username] == username ) && ( options[:password] == password )
86
+ end
81
87
  end
88
+
82
89
  use ::Rack::Deflater
83
- use ::Rack::Cache, verbose: true,
84
- metastore: 'file:/tmp/rack/meta',
85
- entitystore: 'file:/tmp/rack/body',
86
- default_ttl: options[:freshness]
90
+
91
+ if options[:metastore].nil? or options[:metastore].empty?
92
+ puts "Service without cache"
93
+ else
94
+ use ::Rack::Cache, verbose: true,
95
+ metastore: options[:metastore],
96
+ entitystore: options[:entitystore],
97
+ default_ttl: options[:freshness]
98
+ puts "Service cache at #{options[:metastore]} / #{options[:entitystore]}"
99
+ end
100
+
87
101
  map "/" do
88
102
  run Rack::DirectoriesTraversal.new(options)
89
103
  end
104
+ puts "Serving tar'ed folders" if options[:tar]
90
105
  end
91
106
  end
92
107
 
@@ -133,6 +148,7 @@ module Piedesaint
133
148
  end
134
149
 
135
150
  begin
151
+ puts "Service starting at #{options[:http_port]} -> #{options[:https_port]}"
136
152
  puma.run.join
137
153
  rescue Interrupt
138
154
  graceful_stop puma
metadata CHANGED
@@ -1,105 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piedesaint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tnarik Innael
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '1.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '1.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: puma
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.6.3
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.6.3
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rack-ssl-enforcer
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rack-cache
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
- description: ! 'Drop-in web server to serve files and tar''ed directories.
95
-
96
- Use it as a tool to make available databse backups, installation packages that don''t
97
- support automatic download, full GIT bare repositories, etc. for Chef Opscode cookbooks
98
- based on remote files.
99
-
83
+ description: |
84
+ Drop-in web server to serve files and tar'ed directories.
85
+ Use it as a tool to make available databse backups, installation packages that don't support automatic download, full GIT bare repositories, etc. for Chef Opscode cookbooks based on remote files.
100
86
  Underlying it uses Puma, Basic Auth, SSL and SSL enforcing.
101
-
102
- '
103
87
  email:
104
88
  - tnarik@gmail.com
105
89
  executables:
@@ -107,12 +91,13 @@ executables:
107
91
  extensions: []
108
92
  extra_rdoc_files: []
109
93
  files:
110
- - .gitignore
111
- - .ruby-gemset
112
- - .ruby-version
94
+ - ".gitignore"
95
+ - ".ruby-gemset"
96
+ - ".ruby-version"
113
97
  - Gemfile
114
98
  - LICENSE.txt
115
99
  - README.md
100
+ - Rakefile
116
101
  - bin/sug
117
102
  - lib/piedesaint.rb
118
103
  - lib/piedesaint/cli.rb
@@ -122,32 +107,25 @@ files:
122
107
  homepage: https://github.com/tnarik/piedesaint
123
108
  licenses:
124
109
  - MIT
110
+ metadata: {}
125
111
  post_install_message:
126
112
  rdoc_options: []
127
113
  require_paths:
128
114
  - lib
129
115
  required_ruby_version: !ruby/object:Gem::Requirement
130
- none: false
131
116
  requirements:
132
- - - ! '>='
117
+ - - ">="
133
118
  - !ruby/object:Gem::Version
134
119
  version: '0'
135
- segments:
136
- - 0
137
- hash: 2452808336996512805
138
120
  required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
121
  requirements:
141
- - - ! '>='
122
+ - - ">="
142
123
  - !ruby/object:Gem::Version
143
124
  version: '0'
144
- segments:
145
- - 0
146
- hash: 2452808336996512805
147
125
  requirements: []
148
126
  rubyforge_project:
149
- rubygems_version: 1.8.25
127
+ rubygems_version: 2.4.5
150
128
  signing_key:
151
- specification_version: 3
129
+ specification_version: 4
152
130
  summary: Drop-in web server to serve files and tar'ed directories
153
131
  test_files: []