Class: Rgc::Encrypt
- Inherits:
-
Object
- Object
- Rgc::Encrypt
- Defined in:
- lib/rgc/encrypt.rb
Constant Summary collapse
- CONFIG =
'.rgc.yml'
Instance Method Summary collapse
- #determine_encryption(args, options) ⇒ Object
-
#initialize(global_options, options, args) ⇒ Encrypt
constructor
A new instance of Encrypt.
- #load_rgc_config ⇒ Object
- #save_new_config ⇒ Object
- #update_git_attributes ⇒ Object
Constructor Details
#initialize(global_options, options, args) ⇒ Encrypt
Returns a new instance of Encrypt.
5 6 7 8 9 10 11 12 13 |
# File 'lib/rgc/encrypt.rb', line 5 def initialize(, , args) load_rgc_config determine_encryption(args, ) save_new_config update_git_attributes end |
Instance Method Details
#determine_encryption(args, options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rgc/encrypt.rb', line 15 def determine_encryption(args, ) args.each do |arg| @encrypt[arg] = .select do |k, v| k == :yaml && v != nil end @encrypt[arg] = if @encrypt[arg].empty? "" else a = [] @encrypt[arg].each do |k,v| a << "--#{k} #{v}" end a.join(" ") end end end |
#load_rgc_config ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rgc/encrypt.rb', line 35 def load_rgc_config unless File.exists?(CONFIG) abort "#{CONFIG} not found. Please run `rgc init` first." end @encrypt = YAML.load_file(CONFIG) end |
#save_new_config ⇒ Object
43 44 45 46 47 |
# File 'lib/rgc/encrypt.rb', line 43 def save_new_config f = File.open(CONFIG, 'w') do |f| YAML::dump(@encrypt, f) end end |
#update_git_attributes ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rgc/encrypt.rb', line 49 def update_git_attributes unless File.exists?('.gitattributes') abort '.gitattributes file not found. Please run `rgc init` first.' end File.open('.gitattributes', 'a') do |f| @encrypt.each do |k, v| f.puts("#{k} filter=rgc diff=rgc") end end end |