rultor 0.1.1 → 0.2.0

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.
data/.rubocop.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  MethodLength:
2
- Max: 30
2
+ Max: 50
data/.rultor.yml CHANGED
@@ -2,9 +2,12 @@ assets:
2
2
  rubygems.yml: "yegor256/home#assets/rubygems.yml"
3
3
  s3cfg: "yegor256/home#assets/s3cfg"
4
4
 
5
+ install: |
6
+ sudo bundle install
7
+ sudo apt-get install -y bcrypt
8
+
5
9
  release:
6
10
  script: |
7
- sudo bundle install
8
11
  rake
9
12
  rm -rf *.gem
10
13
  sed -i "s/1\.0\.snapshot/${tag}/g" lib/rultor/version.rb
data/README.md CHANGED
@@ -10,11 +10,25 @@
10
10
  Install it first:
11
11
 
12
12
  ```bash
13
- gem install rultor
13
+ $ gem install rultor
14
14
  ```
15
15
 
16
16
  Run it locally and read its output:
17
17
 
18
18
  ```bash
19
- rultor --help
19
+ $ rultor --help
20
20
  ```
21
+
22
+ To encrypt one file for Rultor:
23
+
24
+ ```bash
25
+ $ rultor encrypt -p yegor256/rultor secret.txt
26
+ ```
27
+
28
+ Where `yegor256/rultor` is the name of your Github project and `secret.txt`
29
+ is the file you need to encrypt. Result will be saved into `secret.txt.asc`.
30
+ Read more about Rultor [`decrypt`](http://doc.rultor.com/reference.html#decrypt)
31
+ configuration option.
32
+
33
+ Make sure you have [gpg](https://www.gnupg.org/documentation/manpage.html) and
34
+ [bcrypt](http://bcrypt.sourceforge.net/) installed on your machine.
@@ -28,6 +28,7 @@
28
28
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29
29
  # OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
 
31
+ require 'shellwords'
31
32
  require 'English'
32
33
 
33
34
  # Rultor main module.
@@ -38,9 +39,9 @@ module Rultor
38
39
  # Encrypting command
39
40
  class Encrypt
40
41
  def initialize(name, file)
41
- @name = name
42
- @file = file
43
- @dest = "#{@file}.asc"
42
+ @key = 'rultor-key:' + name
43
+ @dir = File.dirname(file)
44
+ @file = File.basename(file)
44
45
  end
45
46
 
46
47
  def run
@@ -48,10 +49,29 @@ module Rultor
48
49
  "
49
50
  set -x
50
51
  set -e
52
+ file=#{Shellwords.escape(@file)}
53
+ enc=#{Shellwords.escape(@file + '.enc')}
54
+ if [ -e \"${enc}\" ]; then
55
+ echo \"file already exists: ${enc}\"
56
+ exit -1
57
+ fi
58
+ asc=#{Shellwords.escape(@file + '.asc')}
59
+ if [ -e \"${asc}\" ]; then
60
+ echo \"file already exists: ${asc}\"
61
+ exit -1
62
+ fi
63
+ cd #{Shellwords.escape(@dir)}
64
+ echo #{Shellwords.escape(@key)} > \"${asc}\"
65
+ echo #{Shellwords.escape(@key)} >> \"${asc}\"
66
+ cat \"${asc}\" | bcrypt -r -o \"${file}\" > \"${enc}\"
67
+ rm \"${asc}\"
51
68
  gpg --keyserver hkp://pool.sks-keyservers.net \
52
69
  --verbose --recv-keys 9AF0FA4C
53
- gpg --trust-model always --output '#{@dest}' \
54
- --batch --armor --encrypt --verbose --recipient 9AF0FA4C '#{@file}'
70
+ gpg --trust-model always \
71
+ --output \"${asc}\" \
72
+ --batch --armor --encrypt --verbose \
73
+ --recipient 9AF0FA4C \"${enc}\"
74
+ rm -f \"${enc}\"
55
75
  "
56
76
  )
57
77
  fail 'Failed to PGP encrypt' unless $CHILD_STATUS.exitstatus == 0
@@ -33,5 +33,5 @@
33
33
  # Copyright:: Copyright (c) 2014 Yegor Bugayenko
34
34
  # License:: BSD
35
35
  module Rultor
36
- VERSION = '0.1.1'
36
+ VERSION = '0.2.0'
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rultor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-29 00:00:00.000000000 Z
12
+ date: 2014-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake