MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / Gem

Class Gem

src/packagedcode/gemfile_lock.py:128–269  ·  view source on GitHub ↗

A Gem can be packaged as a .gem archive, or it can be a source gem either fetched from GIT or SVN or from a local path.

Source from the content-addressed store, hash-verified

126
127@attr.s()
128class Gem(object):
129 """
130 A Gem can be packaged as a .gem archive, or it can be a source gem either
131 fetched from GIT or SVN or from a local path.
132 """
133 supported_opts = 'remote', 'ref', 'revision', 'branch', 'submodules', 'tag',
134
135 name = String()
136 version = String()
137
138 platform = String(
139 help='Gem platform')
140
141 remote = String(
142 help='remote can be a path, git, svn or Gem repo url. One of GEM, PATH, GIT or SVN')
143
144 type = String(
145 # validator=choices(GEM_TYPES),
146 help='the type of this Gem: One of: {}'.format(', '.join(GEM_TYPES))
147 )
148 pinned = Boolean()
149 spec_version = String()
150
151 # relative path
152 path = String()
153
154 revision = String(
155 help='A version control full revision (e.g. a Git commit hash).'
156 )
157
158 ref = String(
159 help='A version control ref (such as a tag, a shortened revision hash, etc.).'
160 )
161
162 branch = String()
163 submodules = String()
164 tag = String()
165
166 requirements = List(
167 item_type=String,
168 help='list of constraints such as ">= 1.1.9"'
169 )
170
171 dependencies = Mapping(
172 help='a map of direct dependent Gems, keyed by name',
173 value_type='Gem',
174 )
175
176 def refine(self):
177 """
178 Apply some refinements to the Gem based on its type:
179 - fix version and revisions for Gems checked-out from VCS
180 """
181 if self.type == PATH:
182 self.path = self.remote
183
184 if self.type in (GIT, SVN,):
185 # FIXME: this likely WRONG

Callers 6

get_or_createMethod · 0.85
parse_dependencyMethod · 0.85
test_Gem_as_nv_treeMethod · 0.85
test_Gem_flattenMethod · 0.85
test_Gem_to_dictMethod · 0.85

Calls 6

StringFunction · 0.90
BooleanFunction · 0.90
ListFunction · 0.90
MappingFunction · 0.90
formatMethod · 0.45
joinMethod · 0.45

Tested by 4

test_Gem_as_nv_treeMethod · 0.68
test_Gem_flattenMethod · 0.68
test_Gem_to_dictMethod · 0.68