mdata 1.0.0 → 1.0.1

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: 59ba3c43a2d5c4a92d35f80cd17e376009691f59
4
- data.tar.gz: 3fd5301f77852b750e80218a71170c42f30db8ba
3
+ metadata.gz: 7e3bbd437f56887d62ef25076a5b592e38adc217
4
+ data.tar.gz: fcd07349f0490723c12d3c50f383644d07d40914
5
5
  SHA512:
6
- metadata.gz: a7f0de6579e18a699d0e08aaff78deadcf7e5ff03cb395e0cca8ea1d2a635832881f4288c902185181d9c2323ff6c58c9a14481afab892d240d5cf587a7a7c10
7
- data.tar.gz: f9642aed7d6d97e4f35f58d1dca0b042636a70cfe47434103b009838878e2d2d4eb1e6fae4c49cf3f6f62ef5500e168a316ed8c0c429eb30fd3fda045a388527
6
+ metadata.gz: 47797064e35bad49dd8b155eeb473c3be459c74cf8ba1f7b2104677c986889f6d0ca8029f7d775f32d68e8beb55f3b982c947114d8be7e3d2023208cfea86326
7
+ data.tar.gz: d2c9fc0697e1b24ae895493f5116a9a67c9fd9e7ad4430de9c969667caf2698784193e36b7766056c3fcdc542a19562e2fdd0165d879428e7d920c04918dd94a
data/bin/mdata CHANGED
@@ -5,7 +5,7 @@ require 'commander/import'
5
5
  require 'mdata/metadata'
6
6
  require 'terminal-table'
7
7
 
8
- program :version, '1.0.0'
8
+ program :version, '1.0.1'
9
9
  program :description, 'Your Salesforce metadata navigator and manipulator'
10
10
  program :help, 'Author', 'Ben Burwell <ben.burwell@trifecta.com>'
11
11
 
@@ -4,6 +4,11 @@ require 'mdata/types'
4
4
 
5
5
  module Salesforce
6
6
  module Metadata
7
+ # A Salesforce Profile metadata object.
8
+ #
9
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm
10
+ #
11
+ # @author Ben Burwell
7
12
  class Profile
8
13
  include ROXML
9
14
 
@@ -58,6 +63,15 @@ module Salesforce
58
63
  as: [Salesforce::Types::ProfileUserPermission],
59
64
  from: 'userPermissions'
60
65
 
66
+ # Read a profile file from its name and directory
67
+ #
68
+ # The default file path is `./src/profiles/NAME.profile`, but the
69
+ # directory can be overridden by passing a non-nil String.
70
+ #
71
+ # @param name [String] the name of the profile to read, like 'Admin'
72
+ # @param dir [String] the directory to search for the profile in. If
73
+ # nil, defaults to `./src/profiles`.
74
+ # @return [Profile] the profile object that has been instantiated
61
75
  def self.read name, dir
62
76
  dir = './src/profiles' if dir.nil?
63
77
  filename = "#{dir}/#{name}.profile"
@@ -66,6 +80,9 @@ module Salesforce
66
80
  profile
67
81
  end
68
82
 
83
+ # Save the profile to disk, writing it to the file from whence it came
84
+ #
85
+ # Relies on the profile object having a `@filename` to save to.
69
86
  def save
70
87
  doc = ::Nokogiri::XML::Document.new
71
88
  doc.root = to_xml()
@@ -75,6 +92,11 @@ module Salesforce
75
92
  end
76
93
  end
77
94
 
95
+ # Create an empty profile by name in directory
96
+ #
97
+ # @param name [String] the name of the profile to create
98
+ # @param dir [String] the directory to create it in, defaulting to
99
+ # `./src/profiles`.
78
100
  def self.touch name, dir
79
101
  dir = './src/profiles' if dir.nil?
80
102
  filename = "#{dir}/#{name}.profile"
@@ -1 +1,10 @@
1
1
  require 'mdata/metadata/Profile'
2
+
3
+ module Salesforce
4
+ # The Metadata module encapsulates the first-class metadata object types in
5
+ # Salesforce. These are things like Profiles, PermissionSets, Flows, and so
6
+ # on.
7
+ #
8
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_types_list.htm
9
+ module Metadata; end
10
+ end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic ApexClassAccess class that can be extended for specific
6
+ # metadata objects, e.g. ProfileApexClassAccess.
7
+ #
8
+ # @author Ben Burwell
5
9
  class ApexClassAccess
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :enabled
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileApexClassAccess_title
12
17
  class ProfileApexClassAccess < ApexClassAccess; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic ApexPageAccess class that can be extended for specific
6
+ # metadata objects, e.g. ProfileApexPageAccess.
7
+ #
8
+ # @author Ben Burwell
5
9
  class ApexPageAccess
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :enabled
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileApexPageAccess_title
12
17
  class ProfileApexPageAccess < ApexPageAccess; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic ApplicationVisibility class that can be extended for specific
6
+ # metadata objects, e.g. ProfileApplicationVisibility.
7
+ #
8
+ # @author Ben Burwell
5
9
  class ApplicationVisibility
6
10
  include ROXML
7
11
 
@@ -10,6 +14,7 @@ module Salesforce
10
14
  xml_accessor :visible
11
15
  end
12
16
 
17
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileapplicationvisibility_title
13
18
  class ProfileApplicationVisibility < ApplicationVisibility; end
14
19
  end
15
20
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic CustomPermissions class that can be extended for specific
6
+ # metadata objects, e.g. ProfileCustomPermissions.
7
+ #
8
+ # @author Ben Burwell
5
9
  class CustomPermissions
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :name
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#ProfileCustomPermissions_title
12
17
  class ProfileCustomPermissions < CustomPermissions; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic ExternalDataSource class that can be extended for specific
6
+ # metadata objects, e.g. ProfileExternalDataSource.
7
+ #
8
+ # @author Ben Burwell
5
9
  class ExternalDataSourceAccess
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :externalDataSource
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileExternalDataSourceAccess_title
12
17
  class ProfileExternalDataSourceAccess < ExternalDataSourceAccess; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic FieldLevelSecurity class that can be extended for specific
6
+ # metadata objects, e.g. ProfileFieldLevelSecurity.
7
+ #
8
+ # @author Ben Burwell
5
9
  class FieldLevelSecurity
6
10
  include ROXML
7
11
 
@@ -10,6 +14,11 @@ module Salesforce
10
14
  xml_accessor :hidden
11
15
  xml_accessor :readable
12
16
 
17
+ # Get all the permissions granted as an easy-to-use Array
18
+ #
19
+ # @author Ben Burwell
20
+ # @return [Array] an array of strings representing the permissions that
21
+ # are granted.
13
22
  def get_permissions
14
23
  permissions = Array.new
15
24
  permissions.push 'Editable' if @editable == 'true'
@@ -18,10 +27,24 @@ module Salesforce
18
27
  permissions
19
28
  end
20
29
 
30
+ # Get a string representation of the permissions
31
+ #
32
+ # @author Ben Burwell
33
+ # @return [String] the permissions granted on the field, comma separated
21
34
  def to_s
22
35
  get_permissions.join(', ')
23
36
  end
24
37
 
38
+ # Produces a string representation of the permissions suitable for
39
+ # displaying in a list, à la `ls -la`. The resulting list might look
40
+ # something like this:
41
+ #
42
+ # Readable Editable
43
+ # Hidden
44
+ # Readable
45
+ #
46
+ # @author Ben Burwell
47
+ # @return [String] the permissions granted on the field, flag-style
25
48
  def to_flag_style
26
49
  flags = ''
27
50
  if @readable == 'true'
@@ -47,6 +70,7 @@ module Salesforce
47
70
 
48
71
  end
49
72
 
73
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profilefieldlevelsecurity_title
50
74
  class ProfileFieldLevelSecurity < FieldLevelSecurity; end
51
75
  end
52
76
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic LayoutAssignments class that can be extended for specific
6
+ # metadata objects, e.g. ProfileLayoutAssignments.
7
+ #
8
+ # @author Ben Burwell
5
9
  class LayoutAssignments
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :recordType
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profilelayoutassignments
12
17
  class ProfileLayoutAssignments < LayoutAssignments; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic LoginHours class that can be extended for specific
6
+ # metadata objects, e.g. ProfileLoginHours.
7
+ #
8
+ # @author Ben Burwell
5
9
  class LoginHours
6
10
  include ROXML
7
11
 
@@ -21,6 +25,7 @@ module Salesforce
21
25
  xml_accessor :sundayEnd
22
26
  end
23
27
 
28
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#ProfileLoginHours_title
24
29
  class ProfileLoginHours < LoginHours; end
25
30
  end
26
31
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic LoginIpRange class that can be extended for specific
6
+ # metadata objects, e.g. ProfileLoginIpRange.
7
+ #
8
+ # @author Ben Burwell
5
9
  class LoginIpRange
6
10
  include ROXML
7
11
 
@@ -10,6 +14,7 @@ module Salesforce
10
14
  xml_accessor :startAddress
11
15
  end
12
16
 
17
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#ProfileLoginIpRange_title
13
18
  class ProfileLoginIpRange < LoginIpRange; end
14
19
  end
15
20
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic ObjectPermissions class that can be extended for specific
6
+ # metadata objects, e.g. ProfileObjectPermissions.
7
+ #
8
+ # @author Ben Burwell
5
9
  class ObjectPermissions
6
10
  include ROXML
7
11
 
@@ -14,6 +18,7 @@ module Salesforce
14
18
  xml_accessor :viewAllRecords
15
19
  end
16
20
 
21
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileobjectpermissions_title
17
22
  class ProfileObjectPermissions < ObjectPermissions; end
18
23
  end
19
24
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic RecordTypeVisibility class that can be extended for specific
6
+ # metadata objects, e.g. ProfileRecordTypeVisibility.
7
+ #
8
+ # @author Ben Burwell
5
9
  class RecordTypeVisibility
6
10
  include ROXML
7
11
 
@@ -11,6 +15,7 @@ module Salesforce
11
15
  xml_accessor :visible
12
16
  end
13
17
 
18
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profilerecordtypevisibility_title
14
19
  class ProfileRecordTypeVisibility < RecordTypeVisibility; end
15
20
  end
16
21
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic TabVisibility class that can be extended for specific
6
+ # metadata objects, e.g. ProfileTabVisibility.
7
+ #
8
+ # @author Ben Burwell
5
9
  class TabVisibility
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :visibility # enum: DefaultOff, DefaultOn, Hidden
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profiletabvisibility_title
12
17
  class ProfileTabVisibility < TabVisibility; end
13
18
  end
14
19
  end
@@ -2,6 +2,10 @@ require 'roxml'
2
2
 
3
3
  module Salesforce
4
4
  module Types
5
+ # A generic UserPermission class that can be extended for specific
6
+ # metadata objects, e.g. ProfileUserPermission.
7
+ #
8
+ # @author Ben Burwell
5
9
  class UserPermission
6
10
  include ROXML
7
11
 
@@ -9,6 +13,7 @@ module Salesforce
9
13
  xml_accessor :name
10
14
  end
11
15
 
16
+ # See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profileUserPerm_title
12
17
  class ProfileUserPermission < UserPermission; end
13
18
  end
14
19
  end
data/lib/mdata/types.rb CHANGED
@@ -11,3 +11,12 @@ require 'mdata/types/ApexPageAccess'
11
11
  require 'mdata/types/RecordTypeVisibility'
12
12
  require 'mdata/types/TabVisibility'
13
13
  require 'mdata/types/UserPermission'
14
+
15
+ module Salesforce
16
+ # The `Salesforce::Types` module encapsulates XML node type classes, like
17
+ # `ApexClassAccess`. These base types are extended for each metadata object
18
+ # type that needs them, because for some reason ProfileObjectPermissions is
19
+ # different than PermissionSetObjectPermissions to Salesforce, despite them
20
+ # having identical structures.
21
+ module Types; end
22
+ end
data/lib/mdata.rb CHANGED
@@ -1,2 +1,6 @@
1
1
  require 'mdata/types'
2
2
  require 'mdata/metadata'
3
+
4
+ # The Salesforce module encapsulates all classes created in the `mdata` gem.
5
+ # It has two submodules, `Salesforce::Types` and `Salesforce::Metadata`.
6
+ module Salesforce; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Burwell
@@ -103,3 +103,4 @@ signing_key:
103
103
  specification_version: 4
104
104
  summary: Your Salesforce metadata navigator and manipulator
105
105
  test_files: []
106
+ has_rdoc: