inline_encryption 0.0.6 → 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fccdde1cde46737f071121d887829fa13c9c163a
4
+ data.tar.gz: da3d167ac867a8880661dd300ce96beaec865323
5
+ SHA512:
6
+ metadata.gz: 0e34529782b514f89a9086a6e5849e2d7d439079601b245f1d63d18fe528c41896ac9c0cd7debe6751eb1012aeafcd3f4ba68bfb13113e91a0227c43bf743d5b
7
+ data.tar.gz: 604e51533dde74f5774382d390c64a6dd763967ead24a5a2a4faa59620047693579eed6077b51e3b60f6679044c198b9934144dbb5f681c7a5ee4bbd33900d45
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p353
data/.travis.yml CHANGED
@@ -2,4 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
+ - "2.1.0"
5
6
  script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -1,6 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in inline_encryption.gemspec
4
3
  gemspec
5
4
 
6
- gem 'simplecov', :require => false, :group => :test
5
+ gem 'bundler', '~> 1.3'
6
+ gem 'hashie'
7
+ gem 'i18n'
8
+ gem 'thor'
9
+
10
+ group :development, :test do
11
+ gem 'debugger'
12
+ gem 'guard'
13
+ gem 'guard-rspec'
14
+ gem 'guard-spork'
15
+ gem 'rake'
16
+ gem 'redcarpet'
17
+ gem 'rspec'
18
+ gem 'simplecov', require: false
19
+ gem 'yard'
20
+ end
data/Gemfile.lock CHANGED
@@ -1,77 +1,92 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inline_encryption (0.0.6)
5
- hashie
6
- thor
4
+ inline_encryption (1.0.0)
7
5
 
8
6
  GEM
9
7
  remote: https://rubygems.org/
10
8
  specs:
11
- childprocess (0.3.9)
9
+ celluloid (0.15.2)
10
+ timers (~> 1.1.0)
11
+ childprocess (0.4.0)
12
12
  ffi (~> 1.0, >= 1.0.11)
13
- coderay (1.0.9)
14
- diff-lcs (1.2.4)
15
- ffi (1.8.1)
13
+ coderay (1.1.0)
14
+ columnize (0.3.6)
15
+ debugger (1.6.5)
16
+ columnize (>= 0.3.1)
17
+ debugger-linecache (~> 1.2.0)
18
+ debugger-ruby_core_source (~> 1.3.1)
19
+ debugger-linecache (1.2.0)
20
+ debugger-ruby_core_source (1.3.1)
21
+ diff-lcs (1.2.5)
22
+ docile (1.1.2)
23
+ ffi (1.9.3)
16
24
  formatador (0.2.4)
17
- guard (1.8.0)
25
+ guard (2.3.0)
18
26
  formatador (>= 0.2.4)
19
- listen (>= 1.0.0)
20
- lumberjack (>= 1.0.2)
21
- pry (>= 0.9.10)
22
- thor (>= 0.14.6)
23
- guard-rspec (3.0.1)
24
- guard (>= 1.8)
25
- rspec (~> 2.13)
26
- guard-spork (1.5.0)
27
+ listen (~> 2.1)
28
+ lumberjack (~> 1.0)
29
+ pry (>= 0.9.12)
30
+ thor (>= 0.18.1)
31
+ guard-rspec (4.2.4)
32
+ guard (~> 2.1)
33
+ rspec (>= 2.14, < 4.0)
34
+ guard-spork (1.5.1)
27
35
  childprocess (>= 0.2.3)
28
36
  guard (>= 1.1)
29
37
  spork (>= 0.8.4)
30
38
  hashie (2.0.5)
31
- listen (1.1.5)
39
+ i18n (0.6.9)
40
+ listen (2.4.0)
41
+ celluloid (>= 0.15.2)
32
42
  rb-fsevent (>= 0.9.3)
33
43
  rb-inotify (>= 0.9)
34
- rb-kqueue (>= 0.2)
35
- lumberjack (1.0.3)
36
- method_source (0.8.1)
37
- multi_json (1.7.7)
38
- pry (0.9.12.2)
39
- coderay (~> 1.0.5)
44
+ lumberjack (1.0.4)
45
+ method_source (0.8.2)
46
+ multi_json (1.8.4)
47
+ pry (0.9.12.4)
48
+ coderay (~> 1.0)
40
49
  method_source (~> 0.8)
41
50
  slop (~> 3.4)
42
- rake (10.1.0)
43
- rb-fsevent (0.9.3)
44
- rb-inotify (0.9.0)
51
+ rake (10.1.1)
52
+ rb-fsevent (0.9.4)
53
+ rb-inotify (0.9.3)
45
54
  ffi (>= 0.5.0)
46
- rb-kqueue (0.2.0)
47
- ffi (>= 0.5.0)
48
- rspec (2.13.0)
49
- rspec-core (~> 2.13.0)
50
- rspec-expectations (~> 2.13.0)
51
- rspec-mocks (~> 2.13.0)
52
- rspec-core (2.13.1)
53
- rspec-expectations (2.13.0)
55
+ redcarpet (3.0.0)
56
+ rspec (2.14.1)
57
+ rspec-core (~> 2.14.0)
58
+ rspec-expectations (~> 2.14.0)
59
+ rspec-mocks (~> 2.14.0)
60
+ rspec-core (2.14.7)
61
+ rspec-expectations (2.14.4)
54
62
  diff-lcs (>= 1.1.3, < 2.0)
55
- rspec-mocks (2.13.1)
56
- simplecov (0.7.1)
57
- multi_json (~> 1.0)
58
- simplecov-html (~> 0.7.1)
59
- simplecov-html (0.7.1)
60
- slop (3.4.5)
63
+ rspec-mocks (2.14.4)
64
+ simplecov (0.8.2)
65
+ docile (~> 1.1.0)
66
+ multi_json
67
+ simplecov-html (~> 0.8.0)
68
+ simplecov-html (0.8.0)
69
+ slop (3.4.7)
61
70
  spork (0.9.2)
62
71
  thor (0.18.1)
63
- yard (0.8.6.1)
72
+ timers (1.1.0)
73
+ yard (0.8.7.3)
64
74
 
65
75
  PLATFORMS
66
76
  ruby
67
77
 
68
78
  DEPENDENCIES
69
79
  bundler (~> 1.3)
80
+ debugger
70
81
  guard
71
82
  guard-rspec
72
83
  guard-spork
84
+ hashie
85
+ i18n
73
86
  inline_encryption!
74
87
  rake
88
+ redcarpet
75
89
  rspec
76
90
  simplecov
91
+ thor
77
92
  yard
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', :all_after_pass => true, :focus_on_failed => true, :all_on_start => true, :cli => "--drb" do
4
+ guard 'rspec', all_after_pass: true, failed_mode: :focus, all_on_start: true, cmd: 'rspec spec --drb --debugger' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}){ |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb'){ "spec" }
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # inline_encryption [![Build Status](https://travis-ci.org/rubyisbeautiful/inline_encryption.png)](https://travis-ci.org/rubyisbeautiful/inline_encryption)
1
+ # inline_encryption [![Build Status](https://travis-ci.org/rubyisbeautiful/inline_encryption.png)](https://travis-ci.org/rubyisbeautiful/inline_encryption)[![Code Climate](https://codeclimate.com/github/rubyisbeautiful/inline_encryption.png)](https://codeclimate.com/github/rubyisbeautiful/inline_encryption)
2
2
 
3
3
  Simple encryption relying on convention and designed to be used inline as string replacements.
4
4
 
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- mode: ruby -*-
3
- require 'rubygems'
4
- require 'inline_encryption/cli'
3
+ require 'bundler'
4
+ Bundler.setup
5
+
6
+ require 'inline_encryption'
5
7
 
6
8
  InlineEncryption::CLI.start(ARGV)
@@ -0,0 +1,10 @@
1
+ en:
2
+ target: 'Target: %{data}'
3
+ encrypted: 'Encrypted: %{data}'
4
+ error:
5
+ missing_key: "missing variable: 'key'"
6
+ es:
7
+ target: 'Destino: %{data}'
8
+ encrypted: 'Encriptado: %{data}'
9
+ error:
10
+ missing_key: "variable que falta: 'key'"
@@ -22,14 +22,4 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.executables = ['inline_encryption']
24
24
 
25
- spec.add_runtime_dependency 'hashie'
26
- spec.add_runtime_dependency 'thor'
27
-
28
- spec.add_development_dependency "bundler", "~> 1.3"
29
- spec.add_development_dependency "guard"
30
- spec.add_development_dependency "guard-rspec"
31
- spec.add_development_dependency "guard-spork"
32
- spec.add_development_dependency "rake"
33
- spec.add_development_dependency "rspec"
34
- spec.add_development_dependency "yard"
35
25
  end
@@ -13,13 +13,13 @@ module InlineEncryption
13
13
  encrypted = config.real_key.private_encrypt(data)
14
14
  converted = Base64.encode64(encrypted)
15
15
  rescue => e
16
- err = EncryptionFailureError.exception "Target: #{data}"
16
+ err = EncryptionFailureError.exception I18n.t('target', data: data)
17
17
  raise err
18
18
  end
19
19
  end
20
20
 
21
21
 
22
- # @param [String] encryption target
22
+ # @param [String] data encryption target
23
23
  # @return [String] encrypted target, or fail_text on error (default data)
24
24
  def encrypt(data, fail_text=nil)
25
25
  config.check_required_variables
@@ -43,14 +43,14 @@ module InlineEncryption
43
43
  this_key = config.real_key.private? ? config.real_key.public_key : config.real_key
44
44
  decrypted = this_key.public_decrypt(converted)
45
45
  rescue => e
46
- err = DecryptionFailureError.exception "Encrypted: #{data}"
46
+ err = DecryptionFailureError.exception I18n.t('encrypted', data)
47
47
  raise err
48
48
  end
49
49
  end
50
50
 
51
51
 
52
- # @param [String] decryption target
53
- # @param [String] text to be returned in the case of a decryption failure
52
+ # @param [String] data decryption target
53
+ # @param [String] fail_text text to be returned in the case of a decryption failure
54
54
  # @return [String] decrypted target
55
55
  def decrypt(data, fail_text=nil)
56
56
  config.check_required_variables
@@ -1,25 +1,19 @@
1
+ require 'debugger'
1
2
  require 'thor'
2
3
 
3
4
  module InlineEncryption
4
5
 
5
6
  class CLI < Thor
6
7
 
7
- class_option :config, :aliases => ["-c"], :type => :string
8
-
9
8
  def initialize(args=[], opts=[], config={})
10
9
  super(args, opts, config)
11
-
12
- if options[:config] && File.exists?(options[:config])
13
- @options = YAML.load_file(options[:config]).symbolize_keys.merge(@options.symbolize_keys)
14
- end
15
10
  end
16
11
 
17
12
 
18
- desc "encrypt [DATA]", "encrypt stuff"
19
- class_option :require, :aliases => ["-r"], :type => :string
13
+ desc 'encrypt [DATA]', 'encrypt stuff'
14
+ class_option :require, :aliases => ['-r'], :type => :string
20
15
  def encrypt(data)
21
- #puts options
22
- load_enviroment(options[:require])
16
+ load_environment(options[:require]) if options[:require]
23
17
 
24
18
  puts InlineEncryption.encrypt(data)
25
19
  end
@@ -29,19 +23,8 @@ module InlineEncryption
29
23
  protected
30
24
 
31
25
 
32
- def load_enviroment(file=nil)
33
- file ||= "."
34
-
35
- if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
36
- require "rails"
37
- require File.expand_path("#{file}/config/environment.rb")
38
- if defined?(::Rails) && ::Rails.respond_to?(:application)
39
- # Rails 3
40
- # ::Rails.application.eager_load!
41
- end
42
- elsif File.file?(file)
43
- require File.expand_path(file)
44
- end
26
+ def load_environment(file)
27
+ require File.expand_path(file)
45
28
  end
46
29
 
47
30
  end
@@ -13,7 +13,7 @@ module InlineEncryption
13
13
  # checks required, currently only the 'key'
14
14
  # @raises [InlineEncryption::MissingRequiredVariableError] raise on a missing variable
15
15
  def check_required_variables
16
- raise MissingRequiredVariableError.new("missing variable: 'key'") unless self.has_key?(:key)
16
+ raise MissingRequiredVariableError.new(I18n.t('error.missing_key')) unless self.has_key?(:key)
17
17
  end
18
18
 
19
19
 
@@ -1,3 +1,3 @@
1
1
  module InlineEncryption
2
- VERSION = "0.0.6"
3
- end
2
+ VERSION = '1.0.0'
3
+ end
@@ -1,3 +1,5 @@
1
+ require 'i18n'
2
+ require 'base64'
1
3
  require 'inline_encryption/version'
2
4
  require 'inline_encryption/config'
3
5
  require 'inline_encryption/base'
@@ -7,4 +9,11 @@ require 'inline_encryption/cli'
7
9
  module InlineEncryption
8
10
  extend InlineEncryption::Base
9
11
 
12
+ unless @_i18n_initialized_for_ie
13
+ locale_file = File.expand_path(File.join(File.dirname(__FILE__), '../config/locales.yml'))
14
+ I18n.load_path << locale_file
15
+ @_i18n_initialized_for_ie = true
16
+ end
17
+
18
+
10
19
  end
@@ -1,19 +1,56 @@
1
1
  require 'spec_helper'
2
2
  require 'base64'
3
3
 
4
+ def tmp_filename
5
+ File.expand_path(File.join(File.dirname(__FILE__), '../../tmp/bar.rb'))
6
+ end
7
+
4
8
  describe InlineEncryption::CLI do
5
9
 
6
- let(:subject){ InlineEncryption::CLI.new }
10
+ describe 'initialize' do
11
+
12
+ let(:subject){ InlineEncryption::CLI.new }
13
+
14
+ before :all do
15
+ @default_key = OpenSSL::PKey::RSA.generate(2048)
16
+ InlineEncryption.config[:key] = @default_key
17
+ end
18
+
19
+ it 'should encrypt' do
20
+ InlineEncryption.should_receive(:encrypt).with('hello')
21
+
22
+ subject.encrypt('hello')
23
+ end
24
+
25
+ it 'should require a file if passed' do
26
+ subject = InlineEncryption::CLI.new(['foo'], [ '-r', 'foo.rb' ], {})
27
+
28
+ subject.should_receive(:load_environment).with('foo.rb')
29
+
30
+ subject.encrypt('foo')
31
+ end
7
32
 
8
- before :all do
9
- @default_key = OpenSSL::PKey::RSA.generate(2048)
10
- InlineEncryption.config[:key] = @default_key
11
33
  end
12
34
 
13
- it 'should encrypt' do
14
- InlineEncryption.should_receive(:encrypt).with('hello')
15
35
 
16
- subject.encrypt('hello')
36
+ describe 'load_environment' do
37
+
38
+ before :each do
39
+ FileUtils.mkdir_p File.dirname(tmp_filename)
40
+ File.open(tmp_filename, 'w') do |file|
41
+ file.puts 'class FooForInlineEncryptionSpec; end'
42
+ end
43
+ end
44
+
45
+ after :each do
46
+ FileUtils.rm_f File.dirname(tmp_filename)
47
+ end
48
+
49
+ it 'should require the file' do
50
+ subject.send(:load_environment, tmp_filename)
51
+ expect{ FooForInlineEncryptionSpec }.not_to raise_error
52
+ end
53
+
17
54
  end
18
55
 
19
56
  end
@@ -11,7 +11,7 @@ describe InlineEncryption::Config do
11
11
 
12
12
  it "should not raise if 'key' is set" do
13
13
  subject[:key] = 'foo'
14
- expect{ subject.check_required_variables }.to_not raise_error(InlineEncryption::MissingRequiredVariableError)
14
+ expect{ subject.check_required_variables }.not_to raise_error
15
15
  end
16
16
 
17
17
  end
metadata CHANGED
@@ -1,164 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_encryption
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bryan Taylor
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-22 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: hashie
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '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'
30
- - !ruby/object:Gem::Dependency
31
- name: thor
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: bundler
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.3'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- - !ruby/object:Gem::Dependency
63
- name: guard
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: guard-rspec
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: guard-spork
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: rake
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: yard
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- description: ! ' A simple encryption tool based on common convention '
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ' A simple encryption tool based on common convention '
159
14
  email:
160
- - !binary |-
161
- YmNwdGF5bG9yQGdtYWlsLmNvbQ==
15
+ - bcptaylor@gmail.com
162
16
  executables:
163
17
  - inline_encryption
164
18
  extensions: []
@@ -166,6 +20,7 @@ extra_rdoc_files: []
166
20
  files:
167
21
  - .gitignore
168
22
  - .rspec
23
+ - .ruby-version
169
24
  - .travis.yml
170
25
  - Gemfile
171
26
  - Gemfile.lock
@@ -174,6 +29,7 @@ files:
174
29
  - README.md
175
30
  - Rakefile
176
31
  - bin/inline_encryption
32
+ - config/locales.yml
177
33
  - inline_encryption.gemspec
178
34
  - lib/inline_encryption.rb
179
35
  - lib/inline_encryption/base.rb
@@ -189,27 +45,26 @@ files:
189
45
  homepage: http://github.com/rubyisbeautiful/inline_encryption
190
46
  licenses:
191
47
  - MIT
48
+ metadata: {}
192
49
  post_install_message:
193
50
  rdoc_options: []
194
51
  require_paths:
195
52
  - lib
196
53
  required_ruby_version: !ruby/object:Gem::Requirement
197
- none: false
198
54
  requirements:
199
- - - ! '>='
55
+ - - '>='
200
56
  - !ruby/object:Gem::Version
201
57
  version: 1.9.3
202
58
  required_rubygems_version: !ruby/object:Gem::Requirement
203
- none: false
204
59
  requirements:
205
- - - ! '>='
60
+ - - '>='
206
61
  - !ruby/object:Gem::Version
207
62
  version: '0'
208
63
  requirements: []
209
64
  rubyforge_project:
210
- rubygems_version: 1.8.23
65
+ rubygems_version: 2.0.14
211
66
  signing_key:
212
- specification_version: 3
67
+ specification_version: 4
213
68
  summary: A simple encryption tool based on common convention and designed as a drop
214
69
  in for Stringish things
215
70
  test_files: