Module: Create
Instance Method Summary collapse
Instance Method Details
#base ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/commands/create.rb', line 32 def base raise "The `projects_directory` setting is not set. Set it using `enzyme config projects_directory \"/Users/me/Projects\" --global`." unless $settings.projects_directory raise "The `sync.shared_directory` setting is not set. Set it using `enzyme config sync.shared_directory \"shared\" --global`." unless $settings.sync.shared_directory raise "The `user` setting is not set. Set it using `enzyme config user \"me\" --global`." unless $settings.user @@project_name = @@project_name+'_'+Time.now.strftime('%y%m') unless @@project_name =~ /^.+_\d{4}$/ puts puts "Creating the '#{@@project_name}' project at '#{$settings.projects_directory}/#{@@project_name}'..." puts system "mkdir #{$settings.projects_directory}/#{@@project_name}" # TODO: Move the resources directory and it's content to the sync command. Create shouldn't be responsible for it. system "mkdir #{$settings.projects_directory}/#{@@project_name}/resources" system "mkdir #{$settings.projects_directory}/#{@@project_name}/resources/#{$settings.sync.shared_directory}" system "mkdir #{$settings.projects_directory}/#{@@project_name}/resources/#{$settings.user}" system "touch #{$settings.projects_directory}/#{@@project_name}/.enzyme.yml" Dir.chdir("#{$settings.projects_directory}/#{@@project_name}") Config.set('project_name', @@project_name) Config.set('project_type', nil) end |
#koi ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/commands/create.rb', line 56 def koi raise "The `projects_directory` setting is not set. Set it using `enzyme config projects_directory \"/Users/me/Projects\" --global`." unless $settings.projects_directory raise "The `github.user` setting is not set. Set it using `enzyme config github.user \"me\" --global`." unless $settings.github.user raise "The `github.token` setting is not set. Set it using `enzyme config github.token \"0123456789abcdef0123456789abcdef\" --global`." unless $settings.github.token base Config.set('project_type', 'koi') puts puts "Downloading the latest version of Koi from 'https://github.com/katalyst/koi_cms/zipball/master'..." puts system "curl -o '/tmp/#{@@project_name}.zip' -F 'login=#{$settings.github.user}' -F 'token=#{$settings.github.token}' -L 'https://github.com/katalyst/koi_cms/zipball/master'" puts puts 'Extracting...' puts system "unzip '/tmp/#{@@project_name}.zip' -d '/tmp/#{@@project_name}.temp'" system "rm '/tmp/#{@@project_name}.zip'" extracted_dir = Dir.entries("/tmp/#{@@project_name}.temp")[2] puts puts "Copying to '#{$settings.projects_directory}/#{@@project_name}/'..." puts system "mv /tmp/#{@@project_name}.temp/#{extracted_dir}/* #{$settings.projects_directory}/#{@@project_name}" system "rm -r '/tmp/#{@@project_name}.temp'" end |
#pms ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/commands/create.rb', line 88 def pms raise "The `projects_directory` setting is not set. Set it using `enzyme config projects_directory \"/Users/me/Projects\" --global`." unless $settings.projects_directory raise "The `github.user` setting is not set. Set it using `enzyme config github.user \"me\" --global`." unless $settings.github.user raise "The `github.token` setting is not set. Set it using `enzyme config github.token \"0123456789abcdef0123456789abcdef\" --global`." unless $settings.github.token base Config.set('project_type', 'pms') puts puts "Downloading v0.4.2alpha03 of the PMS from 'https://github.com/katalyst/pms/zipball/v0.4.2alpha03'..." puts system "curl -o '/tmp/#{@@project_name}.zip' -F 'login=#{$settings.github.user}' -F 'token=#{$settings.github.token}' -L 'https://github.com/katalyst/pms/zipball/v0.4.2alpha03'" puts puts 'Extracting...' puts system "unzip '/tmp/#{@@project_name}.zip' -d '/tmp/#{@@project_name}.temp'" system "rm '/tmp/#{@@project_name}.zip'" extracted_dir = Dir.entries("/tmp/#{@@project_name}.temp")[2] puts puts "Copying to '#{$settings.projects_directory}/#{@@project_name}/'..." puts system "mv /tmp/#{@@project_name}.temp/#{extracted_dir}/* #{$settings.projects_directory}/#{@@project_name}" system "rm -r '/tmp/#{@@project_name}.temp'" end |
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/commands/create.rb', line 6 def run() ARGV.reject { |x| x.start_with?("-") } @@project_name = ARGV.shift @@project_type = ARGV.shift if @@project_name if @@project_type case @@project_type.to_sym when :pms pms when :koi koi else raise "Unknown project type `#{project_type}`." end else base end puts puts "Complete." puts else raise "A project name must be given. For example: `enzyme create project_name`" end end |