summaryrefslogtreecommitdiff
path: root/lib/dashing/cli.rb
diff options
context:
space:
mode:
authorpseudomuto <david.muto@gmail.com>2013-12-19 12:08:07 -0500
committerpseudomuto <david.muto@gmail.com>2013-12-19 12:20:38 -0500
commite975ce77408f5995213cc1b85f61e806152ba3a2 (patch)
treea4a33d6c3b0cbb1bd6fbde63e18c11344f2d5562 /lib/dashing/cli.rb
parentfbc9497dbb8ece970f21bc67164557bba8db2db7 (diff)
light refactoring for better test coverage
Diffstat (limited to 'lib/dashing/cli.rb')
-rw-r--r--lib/dashing/cli.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/dashing/cli.rb b/lib/dashing/cli.rb
index 001a92e..27d8f6b 100644
--- a/lib/dashing/cli.rb
+++ b/lib/dashing/cli.rb
@@ -10,7 +10,7 @@ module Dashing
class << self
attr_accessor :auth_token
- def CLI.hyphenate(str)
+ def hyphenate(str)
return str.downcase if str =~ /^[A-Z-]+$/
str.gsub('_', '-').gsub(/\B[A-Z]/, '-\&').squeeze('-').downcase
end
@@ -43,16 +43,7 @@ module Dashing
gist = Downloader.get_gist(gist_id)
public_url = "https://gist.github.com/#{gist_id}"
- gist['files'].each do |file, details|
- if file =~ /\.(html|coffee|scss)\z/
- widget_name = File.basename(file, '.*')
- new_path = File.join(Dir.pwd, 'widgets', widget_name, file)
- create_file(new_path, details['content'])
- elsif file.end_with?('.rb')
- new_path = File.join(Dir.pwd, 'jobs', file)
- create_file(new_path, details['content'])
- end
- end
+ install_widget_from_gist(gist)
print set_color("Don't forget to edit the ", :yellow)
print set_color("Gemfile ", :yellow, :bold)
@@ -98,6 +89,19 @@ module Dashing
system(command)
end
+ def install_widget_from_gist(gist)
+ gist['files'].each do |file, details|
+ if file =~ /\.(html|coffee|scss)\z/
+ widget_name = File.basename(file, '.*')
+ new_path = File.join(Dir.pwd, 'widgets', widget_name, file)
+ create_file(new_path, details['content'])
+ elsif file.end_with?('.rb')
+ new_path = File.join(Dir.pwd, 'jobs', file)
+ create_file(new_path, details['content'])
+ end
+ end
+ end
+
def require_file(file)
require file
end