css-get 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/css-get +195 -0
- data/lib/css-get.rb +0 -0
- data/test/helper.rb +10 -0
- data/test/test_css-get.rb +7 -0
- metadata +96 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jack Russell Software Company LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= css-get
|
2
|
+
|
3
|
+
== Usage
|
4
|
+
css-get [options] list|install|uninstall css_name
|
5
|
+
|
6
|
+
For help use: css-get --help
|
7
|
+
|
8
|
+
== Options
|
9
|
+
-h, --help Displays help message
|
10
|
+
-v, --version Displays version
|
11
|
+
-q, --quiet Output as little as possible, overrides verbose
|
12
|
+
-V, --verbose Verbose output
|
13
|
+
|
14
|
+
== Note on Patches/Pull Requests
|
15
|
+
|
16
|
+
* Fork the project.
|
17
|
+
* Make your feature addition or bug fix.
|
18
|
+
* Add tests for it. This is important so I don't break it in a
|
19
|
+
future version unintentionally.
|
20
|
+
* Commit, do not mess with rakefile, version, or history.
|
21
|
+
(if you want to have your own version, that is fine but
|
22
|
+
bump version in a commit by itself I can ignore when I pull)
|
23
|
+
* Send me a pull request. Bonus points for topic branches.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2009 Jack Russell Software Company LLC. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "css-get"
|
8
|
+
gem.summary = %Q{css library install}
|
9
|
+
gem.description = %Q{command line interface to install css libraries}
|
10
|
+
gem.email = "andrew@jackrussellsoftware.com"
|
11
|
+
gem.homepage = "http://github.com/akennedy/css-get"
|
12
|
+
gem.authors = ["Tom Wilson", "Andrew Kennedy", "Barrett Little", "Russell Niller"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.add_dependency('rest-client', '>= 1.0.3')
|
15
|
+
gem.add_dependency('crack', '>= 0.1.2')
|
16
|
+
gem.has_rdoc = true
|
17
|
+
gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
|
18
|
+
|
19
|
+
|
20
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
+
end
|
22
|
+
Jeweler::GemcutterTasks.new
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
task :rcov do
|
43
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
task :test => :check_dependencies
|
48
|
+
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rake/rdoctask'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "css-get #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('bin/css-get')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/css-get
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# This is a command line application that helps install css in your app.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# == Examples
|
8
|
+
# This command does install 960 in your public/stylesheets folder.
|
9
|
+
# css-get install 960
|
10
|
+
#
|
11
|
+
# Other examples:
|
12
|
+
# css-get list
|
13
|
+
# css-get uninstall 960
|
14
|
+
#
|
15
|
+
# == Usage
|
16
|
+
# css-get [options] list|install|uninstall css_name
|
17
|
+
#
|
18
|
+
# For help use: css-get --help
|
19
|
+
#
|
20
|
+
# == Options
|
21
|
+
# -h, --help Displays help message
|
22
|
+
# -v, --version Displays version
|
23
|
+
# -q, --quiet Output as little as possible, overrides verbose
|
24
|
+
# -V, --verbose Verbose output
|
25
|
+
# TO DO - add additional options
|
26
|
+
#
|
27
|
+
# == Author
|
28
|
+
# Tom Wilson, Andrew Kennedy, Barrett Little, Russell Niller
|
29
|
+
#
|
30
|
+
# == Copyright
|
31
|
+
# Copyright (c) 2008 Jack Russell Software Company. Licensed under the MIT License:
|
32
|
+
# http://www.opensource.org/licenses/mit-license.php
|
33
|
+
|
34
|
+
|
35
|
+
require 'optparse'
|
36
|
+
require 'rdoc/usage'
|
37
|
+
require 'ostruct'
|
38
|
+
require 'date'
|
39
|
+
require 'rest_client'
|
40
|
+
require 'crack'
|
41
|
+
require 'fileutils'
|
42
|
+
|
43
|
+
class App
|
44
|
+
VERSION = '0.1.0'
|
45
|
+
CSSDIR = ENV['CSSDIR'] || "public/stylesheets"
|
46
|
+
HOST = ENV['CSSGET_HOST'] || "http://css-get.jackhq.com"
|
47
|
+
|
48
|
+
attr_reader :options
|
49
|
+
|
50
|
+
def initialize(arguments, stdin)
|
51
|
+
@arguments = arguments
|
52
|
+
@stdin = stdin
|
53
|
+
|
54
|
+
# Set defaults
|
55
|
+
@options = OpenStruct.new
|
56
|
+
@options.verbose = false
|
57
|
+
@options.quiet = false
|
58
|
+
# TO DO - add additional defaults
|
59
|
+
end
|
60
|
+
|
61
|
+
# Parse options, check arguments, then process the command
|
62
|
+
def run
|
63
|
+
|
64
|
+
if parsed_options? && arguments_valid?
|
65
|
+
|
66
|
+
puts "Start at #{DateTime.now}\n\n" if @options.verbose
|
67
|
+
|
68
|
+
output_options if @options.verbose # [Optional]
|
69
|
+
|
70
|
+
process_arguments
|
71
|
+
process_command
|
72
|
+
|
73
|
+
puts "\nFinished at #{DateTime.now}" if @options.verbose
|
74
|
+
|
75
|
+
else
|
76
|
+
output_usage
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
def parsed_options?
|
84
|
+
|
85
|
+
# Specify options
|
86
|
+
opts = OptionParser.new
|
87
|
+
opts.on('-v', '--version') { output_version ; exit 0 }
|
88
|
+
opts.on('-h', '--help') { output_help }
|
89
|
+
opts.on('-V', '--verbose') { @options.verbose = true }
|
90
|
+
opts.on('-q', '--quiet') { @options.quiet = true }
|
91
|
+
# TO DO - add additional options
|
92
|
+
|
93
|
+
opts.parse!(@arguments) rescue return false
|
94
|
+
|
95
|
+
process_options
|
96
|
+
true
|
97
|
+
end
|
98
|
+
|
99
|
+
# Performs post-parse processing on options
|
100
|
+
def process_options
|
101
|
+
@options.verbose = false if @options.quiet
|
102
|
+
end
|
103
|
+
|
104
|
+
def output_options
|
105
|
+
puts "Options:\n"
|
106
|
+
|
107
|
+
@options.marshal_dump.each do |name, val|
|
108
|
+
puts " #{name} = #{val}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# True if required arguments were provided
|
113
|
+
def arguments_valid?
|
114
|
+
true if ['install','list','uninstall'].include?(@arguments[0])
|
115
|
+
end
|
116
|
+
|
117
|
+
# Setup the arguments
|
118
|
+
def process_arguments
|
119
|
+
# TO DO - place in local vars, etc
|
120
|
+
end
|
121
|
+
|
122
|
+
def output_help
|
123
|
+
output_version
|
124
|
+
RDoc::usage() #exits app
|
125
|
+
end
|
126
|
+
|
127
|
+
def output_usage
|
128
|
+
RDoc::usage('usage') # gets usage from comments above
|
129
|
+
end
|
130
|
+
|
131
|
+
def output_version
|
132
|
+
puts "#{File.basename(__FILE__)} version #{VERSION}"
|
133
|
+
end
|
134
|
+
|
135
|
+
def process_command
|
136
|
+
command = @arguments[0]
|
137
|
+
# Remove First Argument
|
138
|
+
@arguments.slice!(0)
|
139
|
+
|
140
|
+
send(command.to_sym)
|
141
|
+
|
142
|
+
#process_standard_input # [Optional]
|
143
|
+
end
|
144
|
+
|
145
|
+
def install
|
146
|
+
# Install CSS
|
147
|
+
@arguments.each do |css_name|
|
148
|
+
puts "Installing CSS - #{css_name}" if @options.verbose
|
149
|
+
jlib = Crack::JSON.parse(RestClient.get("#{HOST}/scripts/#{css_name}"))
|
150
|
+
FileUtils.mkpath(CSSDIR)
|
151
|
+
File.open([CSSDIR, "#{css_name}.css"].join('/'), 'w') do |f|
|
152
|
+
f.write(RestClient.get(jlib["src_url"]))
|
153
|
+
end
|
154
|
+
puts "Successfully Installed - #{css_name}" if @options.verbose
|
155
|
+
end
|
156
|
+
rescue
|
157
|
+
puts "Could not locate css library on #{HOST}"
|
158
|
+
end
|
159
|
+
|
160
|
+
def list
|
161
|
+
# List Libraries
|
162
|
+
libraries = Crack::JSON.parse(RestClient.get("#{HOST}/scripts.json"))
|
163
|
+
libraries.each do |lib|
|
164
|
+
puts lib["name"]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def uninstall
|
169
|
+
@arguments.each do |css_name|
|
170
|
+
puts "Removing CSS - #{css_name}" if @options.verbose
|
171
|
+
FileUtils.rm [ [CSSDIR,"#{css_name}.css"].join('/') ]
|
172
|
+
puts "Successfully removed css library - #{css_name}" if @options.verbose
|
173
|
+
end
|
174
|
+
rescue
|
175
|
+
puts "Could not remove css library"
|
176
|
+
end
|
177
|
+
|
178
|
+
def process_standard_input
|
179
|
+
input = @stdin.read
|
180
|
+
# TO DO - process input
|
181
|
+
|
182
|
+
# [Optional]
|
183
|
+
#@stdin.each do |line|
|
184
|
+
# # TO DO - process each line
|
185
|
+
#end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
# TO DO - Add your Modules, Classes, etc
|
191
|
+
|
192
|
+
|
193
|
+
# Create and run the application
|
194
|
+
app = App.new(ARGV, STDIN)
|
195
|
+
app.run
|
data/lib/css-get.rb
ADDED
File without changes
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: css-get
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Wilson
|
8
|
+
- Andrew Kennedy
|
9
|
+
- Barrett Little
|
10
|
+
- Russell Niller
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-10-23 00:00:00 -04:00
|
16
|
+
default_executable: css-get
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: thoughtbot-shoulda
|
20
|
+
type: :development
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rest-client
|
30
|
+
type: :runtime
|
31
|
+
version_requirement:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.3
|
37
|
+
version:
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: crack
|
40
|
+
type: :runtime
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.2
|
47
|
+
version:
|
48
|
+
description: command line interface to install css libraries
|
49
|
+
email: andrew@jackrussellsoftware.com
|
50
|
+
executables:
|
51
|
+
- css-get
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- LICENSE
|
56
|
+
- README.rdoc
|
57
|
+
files:
|
58
|
+
- LICENSE
|
59
|
+
- README.rdoc
|
60
|
+
- Rakefile
|
61
|
+
- VERSION
|
62
|
+
- bin/css-get
|
63
|
+
- lib/css-get.rb
|
64
|
+
- test/helper.rb
|
65
|
+
- test/test_css-get.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/akennedy/css-get
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.3.5
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: css library install
|
94
|
+
test_files:
|
95
|
+
- test/helper.rb
|
96
|
+
- test/test_css-get.rb
|