Module: Pbmenv
- Defined in:
- lib/pbmenv.rb,
lib/pbmenv/cli.rb,
lib/pbmenv/pbm.rb,
lib/pbmenv/helper.rb,
lib/pbmenv/version.rb,
lib/pbmenv/version_object.rb,
lib/pbmenv/directory_object.rb,
lib/pbmenv/version_pathname.rb,
lib/pbmenv/services/use_version_service.rb,
lib/pbmenv/services/download_src_service.rb,
lib/pbmenv/services/create_version_service.rb,
lib/pbmenv/services/destroy_version_service.rb
Defined Under Namespace
Classes: CLI, CreateVersionService, DestroyVersionService, DirectoryObject, DownloadSrcService, Helper, PBM, UseVersionService, VersionObject, VersionPathname
Constant Summary
collapse
- PBM_DIR =
"/usr/share/pbm"
- DEFAULT_PBM_DIR =
PBM_DIR
- VERSION =
"0.1.13"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
24
25
26
|
# File 'lib/pbmenv.rb', line 24
def logger
@logger
end
|
Class Method Details
.available_versions ⇒ Object
60
61
62
|
# File 'lib/pbmenv.rb', line 60
def self.available_versions
Pbmenv::PBM.new.available_versions.map { |x| x["name"] =~ /^v([\d.]+)/ && $1 }.compact
end
|
.chdir(to_dir) ⇒ void
This method returns an undefined value.
NOTE: テスト用
37
38
39
40
|
# File 'lib/pbmenv.rb', line 37
def self.chdir(to_dir)
raise(ArgumentError, 'テスト以外では実行できません') unless defined?(RSpec)
@current_pbm_dir = to_dir
end
|
.clean(keep_versions_size) ⇒ void
This method returns an undefined value.
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/pbmenv.rb', line 131
def self.clean(keep_versions_size)
raise ArgumentError if keep_versions_size.nil?
clean_targets = self.installed_versions[(keep_versions_size + 1)..-1]
return if clean_targets.nil?
clean_targets.each do |version_object|
next if(version_object.latest_version? or version_object.current_version?)
self.uninstall(version_object.name)
end
end
|
.command_versions ⇒ Object
77
78
79
80
81
|
# File 'lib/pbmenv.rb', line 77
def self.command_versions
self.installed_versions.map do |version|
version.current_version? ? "* #{version.name}" : " #{version.name}"
end
end
|
.install(version, use_option: false, enable_pbm_cloud: false) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/pbmenv.rb', line 65
def self.installed_versions
unsorted_dirs = Dir.glob("#{Pbmenv.pbm_dir}/v*")
sorted_version_names = unsorted_dirs.map { |name| Pathname.new(name).basename.to_s =~ /^v([\d.]+)/ && $1 }.compact.sort_by {|x| Gem::Version.new(x) }
sorted_version_names.map do |version_name|
VersionObject.new(
version_name: version_name,
is_latest: sorted_version_names.last == version_name,
is_current: Pbmenv.current_directory.readlink&.end_with?(version_name) || false,
)
end
end
|
.pbm_dir ⇒ String
43
44
45
|
# File 'lib/pbmenv.rb', line 43
def self.pbm_dir
@current_pbm_dir
end
|
.slice_logger ⇒ void
This method returns an undefined value.
48
49
50
51
52
53
|
# File 'lib/pbmenv.rb', line 48
def self.slice_logger
previous_logger = self.logger
self.logger = Logger.new(File.open(File::NULL, "w"))
yield
self.logger = previous_logger
end
|
.uninstall(version) ⇒ Object
TODO: 引数がcurrentを指しているバージョンはどうする?