piedesaint 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a67bed518cb262ac669a97ad0283f805e2b12bc
4
- data.tar.gz: d0d02fbacbd4ee1bf4f8065d3231136e8571c848
3
+ metadata.gz: cd5187dd62378f733ea9756d5c7e6acbfca1683b
4
+ data.tar.gz: a2e52298d82e0e6bcaf2b9e7bd8ba14d298588b8
5
5
  SHA512:
6
- metadata.gz: 4d7f48a002c02e4ccd3a703890a576482e69ad1d1513a42a3e40df1c93b2fae3ea999df7bf5cb934a1be5fbf576ec2c6ea9119a53ff3b12ac9184a8c8f153c3a
7
- data.tar.gz: 67f31bf0a390ed4e4213ca9a720d8dd0214618b195a6a45529a4bc7fa8473fc7497c6cb0cdf95e7face5523e8dd17426f8813aec8ceda6033cf0cfed9ce084d6
6
+ metadata.gz: 4292e4a783972de57f212e20d46f5c31e29cbc21fc53e91da8ac81d0a4dbad0cd4ccfed05ff2ea74c141728a00cdb0ed187f83becbd60f2bfb938ae53907231c
7
+ data.tar.gz: ce9f94adb7f0af65c5c8767eefdf928d1ef87be604168915771679f1058bc61997b1a7d8df60a7ccaa9f25f8cf0006141897e4415b00b2ee6fba3b1436629b06
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.1.1
data/README.md CHANGED
@@ -8,15 +8,15 @@
8
8
 
9
9
  ## In short
10
10
 
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.
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 for convenience) via HTTP or HTTPS.
12
12
 
13
13
  ## Motivation
14
14
 
15
- It was born from the need of having the simplest web server possible (while still being reasonably fast and secure) to provide files and directories to be used by [remote_file](http://docs.opscode.com/resource_remote_file.html) Chef resources, solving the issue of distributing packages that for different reasons are not public or require some interaction to get downloaded, without requiring the installation of a full fledged web server.
15
+ It was born out of the need of having the simplest web server possible (while still being reasonably fast and secure) to provide files and directories to be used by [remote_file](http://docs.opscode.com/resource_remote_file.html) Chef resources, solving the issue of distributing packages that for different reasons might not be public or require some interaction to get downloaded, without requiring the installation of a full fledged web server.
16
16
 
17
- It also serves directories (packaging them on the fly) as a single resource.
17
+ It also serves directories (packaging them on the fly) as a single TAR resource.
18
18
 
19
- This is useful in the case of using chef-solo (combined with Vagrant, for instance, for testing) when database backups or internal git repositories or installation packages need to be transported to the client node but adding those packages to our cookbooks is not wanted or possible.
19
+ This is useful in the case of using chef-zero (combined with Vagrant or Test Kitchen, for instance) when database backups/internal git repositories/installation packages need to be transported to the client node but adding those packages to our cookbooks is not desired or possible.
20
20
 
21
21
  ## Installation
22
22
 
@@ -38,7 +38,7 @@ After installation you will need to initialize the configuration by executing:
38
38
 
39
39
  $ sug init [list of folders to serve, in cascade order]
40
40
 
41
- This creates the ```.piedesaint``` folder that you can inspect and configure (it contains a default shortlived SSL key/certificate pair and some additional configuration in [YAML](http://en.wikipedia.org/wiki/YAML) format).
41
+ This creates the `.piedesaint` folder that you can inspect and configure (it contains a default shortlived and self-signed SSL key/certificate pair and some additional configuration in [YAML](http://en.wikipedia.org/wiki/YAML) format).
42
42
 
43
43
  By default the configuration will serve the current directory, unless a list of folders is specified. If you want to serve a different folder or set of folders, just edit the configuration.
44
44
 
@@ -46,7 +46,7 @@ After this, whenever you want to serve the files/directories, just execute:
46
46
 
47
47
  $ sug
48
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:```).
49
+ Alternatively, by editing `.piedesaint/config`, you can disable compressed folders (`:tar: false`), the need for Basic Authorization credentials (using an empty `:username:`) or the SSL behaviour (using an empty `:key:`).
50
50
 
51
51
  ## License
52
52
 
data/bin/sug CHANGED
@@ -5,4 +5,4 @@ require 'piedesaint/cli'
5
5
 
6
6
  cli = Piedesaint::CLI.new
7
7
  cli.execute if ARGV.length == 0
8
- cli.send ARGV.shift, ARGV if ARGV.length >= 1
8
+ cli.public_send ARGV.shift, ARGV if ARGV.length >= 1
data/lib/piedesaint.rb CHANGED
@@ -120,14 +120,14 @@ module Piedesaint
120
120
  #ctx.cert = "./server.crt"
121
121
  #ctx.verify_mode = ::Puma::MiniSSL::VERIFY_NONE
122
122
 
123
- puma.add_tcp_listener options[:host], options[:http_port]
123
+ puma.add_tcp_listener options[:iface], options[:http_port]
124
124
 
125
125
  if ( !options[:key].nil? and !options[:key].empty? )
126
126
  ctx = ::OpenSSL::SSL::SSLContext.new
127
127
  ctx.key = OpenSSL::PKey::RSA.new File.read(options[:key])
128
128
  ctx.cert = OpenSSL::X509::Certificate.new File.read(options[:cert])
129
129
  ctx.verify_mode = ::OpenSSL::SSL::VERIFY_NONE
130
- puma.add_ssl_listener options[:host], options[:https_port], ctx
130
+ puma.add_ssl_listener options[:iface], options[:https_port], ctx
131
131
  end
132
132
 
133
133
  puma.min_threads = 1
@@ -14,6 +14,7 @@ module Piedesaint
14
14
 
15
15
  def execute
16
16
  load_config
17
+ cert(@config[:host]) if @config[:refresh_cert]
17
18
  piedesanto = Piedesaint.new @config
18
19
  piedesanto.start
19
20
  end
@@ -22,37 +23,52 @@ module Piedesaint
22
23
  if File.exist?(".piedesaint")
23
24
  abort "Configuration already exists at #{Dir.pwd}/.piedesaint"
24
25
  end
25
- key, cert = create_ssl_artifacts
26
26
 
27
- FileUtils.mkdir_p ".piedesaint"
28
- FileUtils.cd ".piedesaint" do
29
- FileUtils.mkdir_p "ssl"
30
- FileUtils.cd "ssl" do
31
- open 'server.key', 'w' do |io| io.write key.to_pem end
32
- open 'server.crt', 'w' do |io| io.write cert.to_pem end
33
- end
27
+ config = { iface: "0.0.0.0",
28
+ http_port: 8080,
29
+ https_port: 9292,
30
+ refresh_cert: true,
31
+ host: "localhost",
32
+ key: File.join(".", ".piedesaint", "ssl", "server.key" ),
33
+ cert: File.join(".", ".piedesaint", "ssl", "server.crt" ),
34
+ username: "user",
35
+ password: "password",
36
+ freshness: 3600,
37
+ metastore: 'file:/tmp/rack/meta',
38
+ entitystore: 'file:/tmp/rack/body',
39
+ tar: true,
40
+ folders: parameters }
41
+ save_config config
42
+ cert
43
+ puts "Configuration created at #{Dir.pwd}/.piedesaint"
44
+ end
34
45
 
35
- config = { host: "0.0.0.0",
36
- http_port: 8080,
37
- https_port: 9292,
38
- key: File.join(".", ".piedesaint", "ssl", "server.key" ),
39
- cert: File.join(".", ".piedesaint", "ssl", "server.crt" ),
40
- username: "user",
41
- password: "password",
42
- freshness: 3600,
43
- metastore: 'file:/tmp/rack/meta',
44
- entitystore: 'file:/tmp/rack/body',
45
- tar: true,
46
- folders: parameters }
46
+ def set_host ( host = [] )
47
+ load_config
48
+ @config[:host] = host[0]
49
+ save_config @config
50
+ cert host[0]
51
+ end
47
52
 
48
- open 'config', 'w' do |io| io.write config.to_yaml end
53
+ private
54
+ def load_config
55
+ config_path = find_default_config_path
56
+ if config_path.nil?
57
+ abort "Configuration not provided.\nExecute '#{$PROGRAM_NAME} init' to generate one"
49
58
  end
50
59
 
51
- puts "Configuration created at #{Dir.pwd}/.piedesaint"
60
+ @config = YAML.load_file File.join(config_path, "config")
52
61
  end
53
62
 
54
- def cert ( cert_subject = 'CN=Piedesaint' )
55
- key, cert = create_ssl_artifacts
63
+ def save_config ( config )
64
+ FileUtils.mkdir_p ".piedesaint"
65
+ FileUtils.cd ".piedesaint" do
66
+ open 'config', 'w' do |io| io.write config.to_yaml end
67
+ end
68
+ end
69
+
70
+ def cert ( cn = 'localhost' )
71
+ key, cert = create_ssl_artifacts cn
56
72
 
57
73
  FileUtils.mkdir_p ".piedesaint"
58
74
  FileUtils.cd ".piedesaint" do
@@ -64,17 +80,7 @@ module Piedesaint
64
80
  end
65
81
  end
66
82
 
67
- private
68
- def load_config
69
- config_path = find_default_config_path
70
- if config_path.nil?
71
- abort "Configuration not provided.\nExecute '#{$PROGRAM_NAME} init' to generate one"
72
- end
73
-
74
- @config = YAML.load_file File.join(config_path, "config")
75
- end
76
-
77
- def create_ssl_artifacts ( cert_subject = 'CN=Piedesaint' )
83
+ def create_ssl_artifacts ( cn = 'localhost' )
78
84
  key = OpenSSL::PKey::RSA.new 2048
79
85
 
80
86
  cert = OpenSSL::X509::Certificate.new
@@ -83,7 +89,7 @@ module Piedesaint
83
89
  cert.not_before = Time.now
84
90
  cert.not_after = Time.now + 3 * 3600
85
91
  cert.public_key = key.public_key
86
- name = OpenSSL::X509::Name.parse cert_subject
92
+ name = OpenSSL::X509::Name.parse "CN=#{cn}"
87
93
  cert.subject = name
88
94
  cert.issuer = name
89
95
  cert.sign key, OpenSSL::Digest::SHA1.new
@@ -1,3 +1,3 @@
1
1
  module Piedesaint
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/piedesaint.gemspec CHANGED
@@ -23,8 +23,8 @@ EOF
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  # development dependencies
26
- spec.add_development_dependency "thor"
27
- spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "bundler", "~> 1.6"
27
+ spec.add_development_dependency "rake"
28
28
 
29
29
  # runtime dependencies
30
30
  spec.add_dependency "puma", "~>1.6.3"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piedesaint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tnarik Innael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-24 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thor
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: puma
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,7 @@ files:
94
94
  - ".gitignore"
95
95
  - ".ruby-gemset"
96
96
  - ".ruby-version"
97
+ - ".travis.yml"
97
98
  - Gemfile
98
99
  - LICENSE.txt
99
100
  - README.md
@@ -103,7 +104,6 @@ files:
103
104
  - lib/piedesaint/cli.rb
104
105
  - lib/piedesaint/version.rb
105
106
  - piedesaint.gemspec
106
- - tasks/gem.thor
107
107
  homepage: https://github.com/tnarik/piedesaint
108
108
  licenses:
109
109
  - MIT
data/tasks/gem.thor DELETED
@@ -1,33 +0,0 @@
1
- class Gem < Thor
2
- include Thor::Actions
3
-
4
- # This allows for dynamic descriptions
5
- begin
6
- @gemhelper = Bundler::GemHelper.new
7
- rescue
8
- end
9
-
10
- def initialize(*args)
11
- super
12
- @gemhelper = Bundler::GemHelper.new
13
- end
14
-
15
- # tasks
16
- desc "build", @gemhelper.nil? ? "Building gem into the pkg directory" :
17
- "Building #{@gemhelper.gemspec.name}-#{@gemhelper.gemspec.version}.gem into the pkg directory"
18
- def build
19
- @gemhelper.build_gem
20
- end
21
-
22
- desc "install", @gemhelper.nil? ? "Build and install gem into system gems" :
23
- "Build and install #{@gemhelper.gemspec.name}-#{@gemhelper.gemspec.version}.gem into system gems"
24
- def install
25
- @gemhelper.install_gem
26
- end
27
-
28
- desc "release", @gemhelper.nil? ? "Create tag and build and push gem to Rubygems" :
29
- "Create tag v#{@gemhelper.gemspec.version} and build and push #{@gemhelper.gemspec.name}-#{@gemhelper.gemspec.version}.gem to Rubygems"
30
- def release
31
- @gemhelper.release_gem
32
- end
33
- end