Module: Wagon
- Defined in:
- lib/wagon.rb
Class Method Summary collapse
-
.get_wagon_path ⇒ Object
Determines if there is a wagon path in the immediate directory or the directory above it.
-
.is_wagon_dir?(path = '.') ⇒ String
FROM : github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/cli.rb#L8-L31 This method is heavily tweaked and may require more modifications to be acurate.
-
.process_options(options) ⇒ Object
Converts the provided options into the appropriate string to append to the wagon command.
- .pull(options) ⇒ Object
- .push(options) ⇒ Object
Class Method Details
.get_wagon_path ⇒ Object
Determines if there is a wagon path in the immediate directory or the directory above it. If so, the path will be returned, otherwise nill. This does not search sub directories.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/wagon.rb', line 82 def self.get_wagon_path() dir = nil if is_wagon_dir? Dir.pwd dir = Dir.pwd else require 'pathname' Pathname.new(Dir.pwd).ascend do |parent| if is_wagon_dir? parent dir = parent.to_s break end end end return dir end |
.is_wagon_dir?(path = '.') ⇒ String
FROM : github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/cli.rb#L8-L31 This method is heavily tweaked and may require more modifications to be acurate. Check if the path given in option (‘.’ by default) points to a LocomotiveCMS site. It is also possible to pass a path other than the one from the options.
75 76 77 78 |
# File 'lib/wagon.rb', line 75 def self.is_wagon_dir?(path = '.') path = path == '.' ? Dir.pwd : File.(path) return File.exists?(File.join(path, 'config', 'site.yml')) end |
.process_options(options) ⇒ Object
Converts the provided options into the appropriate string to append to the wagon command. Supported options:
"-p" or "-pages": pages
"-a" or "-theme_assets": theme_assets
"-t" or "-translations": translations
"-e" or "-content_entries": content_entries
"-y" or "-content_types": content_types
"-n" or "-snippets": snippets
"-s" or "-site": site
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wagon.rb', line 16 def self.() resource_opts = [] for option in case option when "-p", "-pages" unless resource_opts.include? "pages" resource_opts.push("pages") end when "-a", "-theme_assets" unless resource_opts.include? "theme_assets" resource_opts.push("theme_assets") end when "-t", "-translations" unless resource_opts.include? "translations" resource_opts.push("translations") end when "-e", "-content_entries" unless resource_opts.include? "content_entries" resource_opts.push("content_entries") end when "-y", "-content_types" unless resource_opts.include? "content_types" resource_opts.push("content_types") end when "-n", "-snippets" unless resource_opts.include? "snippets" resource_opts.push("snippets") end when "-s", "-site" unless resource_opts.include? "site" resource_opts.push("site") end end end unless resource_opts.empty? return " -r #{resource_opts.join(' ')}" else return '' end end |