Class: Banis::ModDev::DevRepos
- Inherits:
-
Object
- Object
- Banis::ModDev::DevRepos
- Includes:
- ModelFact::ModelHelper, TR::CondUtils
- Defined in:
- lib/banis/mod_dev/dev_repos.rb
Constant Summary collapse
- VCS_REPOSITORY =
0
- VCS_WORKSPACE =
1
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ DevRepos
constructor
A new instance of DevRepos.
- #is_vcs_engine?(vt) ⇒ Boolean
- #is_vcs_repos? ⇒ Boolean
- #is_vcs_workspace? ⇒ Boolean
- #repos_type_name(sel = nil) ⇒ Object
- #save ⇒ Object
- #set_vcs_as_repos ⇒ Object
- #set_vcs_as_workspace ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ DevRepos
Returns a new instance of DevRepos.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 35 def initialize(opts = {}) opts = {} if opts.nil? if not opts[:instance].nil? _inst = opts[:instance] _inst.did = SecureRandom.uuid if is_empty?(_inst.did) set_model_instance(_inst) else _inst = ModelFact.new_instance(_model_key) _inst.send("dev_project_id=", opts[:dev_project_id]) if not_empty?(opts[:dev_project_id]) _inst.send("name=", opts[:name]) if not_empty?(opts[:name]) # workspace? repository? _inst.send("vcs_type=", opts[:vcs_type]) if not_empty?(opts[:vcs_type]) # git? svn? _inst.send("vcs_engine=", opts[:vcs_engine]) if not_empty?(opts[:vcs_engine]) _inst.send("vcs_path=", File.(opts[:vcs_path])) if not_empty?(opts[:vcs_path]) _inst.send("notes=", opts[:notes]) if not_empty?(opts[:notes]) _inst.did = SecureRandom.uuid set_model_instance(_inst) end ensure_attributes_defined self.class.init_model if is_vcs_workspace? self.extend(DevReposWorkspace) elsif is_vcs_repos? self.extend(DevReposRepos) end end |
Class Method Details
.init_model ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 19 def self.init_model self.record_translator do |val| case val when Array, ActiveRecord::Relation val.collect { |e| DevRepos.new(instance: e) } else if not val.nil? DevRepos.new(instance: val) else val end end end end |
Instance Method Details
#is_vcs_engine?(vt) ⇒ Boolean
92 93 94 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 92 def is_vcs_engine?(vt) model.vcs_engine.to_s == vt.to_s end |
#is_vcs_repos? ⇒ Boolean
88 89 90 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 88 def is_vcs_repos? self.vcs_type == VCS_REPOSITORY end |
#is_vcs_workspace? ⇒ Boolean
70 71 72 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 70 def is_vcs_workspace? self.vcs_type == VCS_WORKSPACE end |
#repos_type_name(sel = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 74 def repos_type_name(sel = nil) key = sel || self.vcs_type.to_i case key when VCS_WORKSPACE "Workspace" when VCS_REPOSITORY "Repository" end end |
#save ⇒ Object
96 97 98 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 96 def save model.save end |
#set_vcs_as_repos ⇒ Object
84 85 86 87 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 84 def set_vcs_as_repos self.vcs_type = VCS_REPOSITORY self.extend(DevReposRepos) if not self.is_a?(DevReposRepos) end |
#set_vcs_as_workspace ⇒ Object
66 67 68 69 |
# File 'lib/banis/mod_dev/dev_repos.rb', line 66 def set_vcs_as_workspace self.vcs_type = VCS_WORKSPACE self.extend(DevReposWorkspace) if not self.is_a?(DevReposWorkspace) end |