Class: PressPass::Cli::Linker
- Inherits:
-
Object
- Object
- PressPass::Cli::Linker
- Defined in:
- lib/presspass/cli/linker.rb
Class Method Summary collapse
- .directory_is_theme?(path) ⇒ Boolean
- .link(theme_path, installation_path) ⇒ Object
- .run(arguments = nil) ⇒ Object
Class Method Details
.directory_is_theme?(path) ⇒ Boolean
40 41 42 |
# File 'lib/presspass/cli/linker.rb', line 40 def self.directory_is_theme?(path) File.exists?(File.join(path, 'style.css')) end |
.link(theme_path, installation_path) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/presspass/cli/linker.rb', line 44 def self.link(theme_path, installation_path) link_path = File.join(installation_path, 'wp-content', 'themes', File.basename(theme_path)) if File.symlink?(link_path) puts "Theme directory #{theme_path} is already linked in #{link_path}" return end puts "Linking #{theme_path} into #{link_path}" File.symlink(theme_path, link_path) end |
.run(arguments = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/presspass/cli/linker.rb', line 9 def self.run(arguments = nil) config_file = File.join(Dir.home, '.presspass.yml') config = {} File.open( config_file, "r+") do |file| config = YAML.load(file) end if config["installation_dir"].nil? puts <<-EOF You don't have a local PressPass-enabled WordPress installation yet. Install one using: presspass new <directory> EOF return end if arguments.empty? if directory_is_theme?(Dir.pwd) link(Dir.pwd, File.(config["installation_dir"])) end end end |