Class: PantographCore::PantographFolder
- Inherits:
-
Object
- Object
- PantographCore::PantographFolder
- Defined in:
- pantograph_core/lib/pantograph_core/pantograph_folder.rb
Constant Summary collapse
- FOLDER_NAME =
'pantograph'
Class Method Summary collapse
- .create_folder!(path = nil) ⇒ Object
-
.pantfile_path ⇒ Object
Path to the Pantfile inside the pantograph folder.
-
.path ⇒ Object
Path to the pantograph folder containing the Pantfile and other configuration files.
-
.setup? ⇒ Boolean
Does a pantograph configuration already exist?.
Class Method Details
.create_folder!(path = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'pantograph_core/lib/pantograph_core/pantograph_folder.rb', line 31 def self.create_folder!(path = nil) path = File.join(path || '.', FOLDER_NAME) return if File.directory?(path) # directory is already there UI.user_error!("Found a file called 'pantograph' at path '#{path}', please delete it") if File.exist?(path) FileUtils.mkdir_p(path) UI.success("Created new folder '#{path}'.") end |
.pantfile_path ⇒ Object
Path to the Pantfile inside the pantograph folder. This is nil when none is available
17 18 19 20 21 22 23 |
# File 'pantograph_core/lib/pantograph_core/pantograph_folder.rb', line 17 def self.pantfile_path return nil if self.path.nil? path = File.join(self.path, 'Pantfile') return path if File.exist?(path) return nil end |
.path ⇒ Object
Path to the pantograph folder containing the Pantfile and other configuration files
8 9 10 11 12 13 14 |
# File 'pantograph_core/lib/pantograph_core/pantograph_folder.rb', line 8 def self.path value ||= "./#{FOLDER_NAME}/" if File.directory?("./#{FOLDER_NAME}/") value ||= "./.#{FOLDER_NAME}/" if File.directory?("./.#{FOLDER_NAME}/") # hidden folder value ||= "./" if File.basename(Dir.getwd) == FOLDER_NAME && File.exist?('Pantfile') # inside the folder value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Pantfile') # inside the folder and hidden return value end |
.setup? ⇒ Boolean
Does a pantograph configuration already exist?
26 27 28 29 |
# File 'pantograph_core/lib/pantograph_core/pantograph_folder.rb', line 26 def self.setup? return false unless self.pantfile_path File.exist?(self.pantfile_path) end |