Class: S3Master::PolicyDiffer

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_master/policy_differ.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_policy, local_policy) ⇒ PolicyDiffer

Returns a new instance of PolicyDiffer.



7
8
9
10
11
# File 'lib/s3_master/policy_differ.rb', line 7

def initialize(remote_policy, local_policy)
  @remote = remote_policy
  @local = local_policy
  compute_diff
end

Instance Attribute Details

#diffObject (readonly)

Returns the value of attribute diff.



5
6
7
# File 'lib/s3_master/policy_differ.rb', line 5

def diff
  @diff
end

#localObject (readonly)

Returns the value of attribute local.



5
6
7
# File 'lib/s3_master/policy_differ.rb', line 5

def local
  @local
end

#remoteObject (readonly)

Returns the value of attribute remote.



5
6
7
# File 'lib/s3_master/policy_differ.rb', line 5

def remote
  @remote
end

Instance Method Details

#compute_diffObject



13
14
15
16
17
# File 'lib/s3_master/policy_differ.rb', line 13

def compute_diff
  rj = JSON.neat_generate(@remote, sort: true)
  lj = JSON.neat_generate(@local, sort: true)
  @diff = Diffy::Diff.new(rj, lj, context: 7, include_diff_info: true)
end

#identical?Boolean

Returns:

  • (Boolean)


19
# File 'lib/s3_master/policy_differ.rb', line 19

def identical?() diff.to_s == "\n" ; end

#to_sObject



20
# File 'lib/s3_master/policy_differ.rb', line 20

def to_s() diff.to_s ; end