Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add executable for non-Rails installs

  • Loading branch information...
commit 27535ad8359bf7aec3a8a596763f3c863eae1676 1 parent 84b9cd2
@kaishin kaishin authored
View
5 bin/neat
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require "neat"
+
+Neat::Generator.new(ARGV).run
View
2  lib/neat.rb
@@ -1,3 +1,5 @@
+require "neat/generator"
+
module Neat
if defined?(Rails) && defined?(Rails::Engine)
class Engine < ::Rails::Engine
View
73 lib/neat/generator.rb
@@ -0,0 +1,73 @@
+require "fileutils"
+
+module Neat
+ class Generator
+ def initialize(arguments)
+ @subcommand = arguments.first
+ end
+
+ def run
+ if @subcommand == "install"
+ install
+ elsif @subcommand == "update"
+ update
+ elsif @subcommand == "remove"
+ remove
+ end
+ end
+
+ def update
+ if neat_files_already_exist?
+ remove_neat_directory
+ install_files
+ puts "Neat files updated."
+ else
+ puts "No existing neat installation. Doing nothing."
+ end
+ end
+
+ def install
+ if neat_files_already_exist?
+ puts "Neat files already installed, doing nothing."
+ else
+ install_files
+ puts "Neat files installed to neat/"
+ end
+ end
+
+ def remove
+ if neat_files_already_exist?
+ remove_neat_directory
+ puts "Neat was successfully removed."
+ else
+ puts "No existing neat installation. Doing nothing."
+ end
+ end
+
+ private
+
+ def neat_files_already_exist?
+ File.directory?("neat")
+ end
+
+ def install_files
+ FileUtils.cp_r(all_stylesheets, "neat/")
+ end
+
+ def remove_neat_directory
+ FileUtils.rm_rf("neat")
+ end
+
+ def all_stylesheets
+ Dir["#{stylesheets_directory}/*"]
+ end
+
+ def stylesheets_directory
+ File.join(top_level_directory, "app", "assets", "stylesheets")
+ end
+
+ def top_level_directory
+ File.dirname(File.dirname(File.dirname(__FILE__)))
+ end
+ end
+end
View
2  lib/neat/version.rb
@@ -1,3 +1,3 @@
module Neat
- VERSION = '1.0.0.pre'
+ VERSION = '1.0.0'
end
Please sign in to comment.
Something went wrong with that request. Please try again.