revans-gini 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Code Wranglers, Inc. & Robert R Evans
1
+ Copyright (c) 2009 Robert R Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
@@ -1,49 +1,13 @@
1
1
  # Gini
2
2
 
3
- Gini is a way to grab those files that you are tired of copying and pasting everytime, like the
4
- latest jQuery or Prototype. You tell gini what library you want, that is supported, and where you
5
- want it installed, unless you want it in the current directory and it will go get it for you.
6
-
7
- Additional options is downloading a compressed version, if it exists.
8
-
9
- ## Libraries Currently Supported
10
-
11
- * jQuery
12
- * Prototype
13
- * MooTools
14
- * 960 CSS Framework
3
+ Gini currently supports only jquery, prototype and mootools. I'll be adding CSS frameworks shortly.
15
4
 
16
5
  ## Usage
17
6
 
18
- To choose the directory you want the library installed at (it will create any files that don't already exist)
19
-
20
- gini --install jquery --path /Users/yourname/project/public/javascripts
21
-
22
- To install in your current directory:
23
-
24
- gini --install prototype
25
-
26
- Ask for a compressed version of the library, if it exists
27
-
28
- gini --install jquery -c
29
-
30
- Need some help?
31
-
32
- gini -h
33
-
34
- That will show you all available options.
35
-
36
- ## Install
37
-
38
- git clone git://github.com/revans/gini.git
39
- cd gini
40
- gem build gini.gemspec
41
- sudo gem install gini-0.2.0.gem
7
+ gini jquery
42
8
 
9
+ gini jquery --path /Users/revans/Desktop
43
10
 
44
- ## Future Features
11
+ gini jquery -c
45
12
 
46
- * More Libraries
47
- * Hooks for using Github to grab libraries
48
- * Ability to download zip/tar files and unpack them
49
- * Possible support for your own libraries that live on your local machine in, say, a ~/.templates folder
13
+ The first will install jquery to the current directory that you are in. The second will install jquery to the given path. And the third will pull down a compressed verison of jquery, if it exists (otherwise it will pull the uncompressed version).
data/bin/gini CHANGED
@@ -3,5 +3,6 @@
3
3
  require 'rubygems'
4
4
  require 'gini'
5
5
 
6
- options = Gini::Options.parse(ARGV)
7
- Gini::Fetch.library(options)
6
+
7
+ options = Gini::Options.parse!(ARGV)
8
+ Gini::Fetch.library(options)
@@ -1,20 +1,24 @@
1
1
  module Gini
2
- Version = "0.2.0"
2
+ Version = "0.3.0"
3
3
 
4
+ # Error Classes
5
+ class NoLibraryGiven < StandardError; end
4
6
  class LibraryNotSupported < StandardError; end
5
- class LibraryNotSpecified < StandardError; end
6
7
 
7
- module Supported
8
- Archives = %w[tar tar.gz tar.bz2 zip]
9
- end
8
+
9
+ # Supported Libraries
10
+ Libraries = %w[jquery prototype mootools reset 960]
11
+
10
12
  end
11
13
 
12
14
  # Required Gems
13
- %w[fileutils optparse ostruct uri net/http pathname].each { |library| require library }
15
+ %w[optparse ostruct fileutils uri net/http pathname].each { |library| require library }
16
+
14
17
 
15
18
  # Gem specific Requires
16
- require File.dirname(__FILE__) + "/gini/extensions/string"
17
- require File.dirname(__FILE__) + "/gini/library"
18
- require File.dirname(__FILE__) + "/gini/parser"
19
- require File.dirname(__FILE__) + "/gini/extract"
20
- require File.dirname(__FILE__) + "/gini/fetch"
19
+ require File.dirname(__FILE__) + "/gini/string_extensions"
20
+ require File.dirname(__FILE__) + "/gini/parse"
21
+ require File.dirname(__FILE__) + "/gini/fetch"
22
+ # require File.dirname(__FILE__) + "/gini/ci.rb"
23
+ # require File.dirname(__FILE__) + "/gini/config/libraries.yaml"
24
+ # require File.dirname(__FILE__) + "/gini/"
@@ -0,0 +1,16 @@
1
+ jquery:
2
+ compressed: http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js
3
+ uncompressed: http://jqueryjs.googlecode.com/files/jquery-1.3.1.js
4
+
5
+ prototype:
6
+ uncompressed: http://www.prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js
7
+
8
+ mootools:
9
+ compressed: http://mootools.net/download/get/mootools-1.2.1-core.yc.js
10
+ uncompressed: http://mootools.net/download/get/mootools-1.2.1-core.nc.js
11
+
12
+ reset:
13
+ uncompressed: http://960.gs/css/reset.css
14
+
15
+ 960css:
16
+ uncompressed: http://960.gs/css/960.css
@@ -1,92 +1,50 @@
1
1
  module Gini
2
2
  class Fetch
3
-
4
- attr_reader :options, :url
5
-
6
-
7
- # Initialize
8
- #
9
- # ==== Description
10
- #
11
- # Checks to make sure a library is specified and we support it.
12
- # Maps options and setups up the path, if it is not given.
13
- #
3
+
4
+
14
5
  def initialize(options)
15
- raise LibraryNotSpecified, "You need to specify what Library you want to install" if options.library.nil?
6
+ raise NoLibraryGiven, "You need to specify what Library you want to install." if options.library.nil?
16
7
  raise LibraryNotSupported, "#{options.library} is not supported." unless Gini::Libraries.include?(options.library)
8
+
9
+ @options = options
10
+ library = @options.library == "960" ? "960css" : @options.library
11
+ @options.path = Dir.pwd if @options.path.nil?
12
+ @library = YAML::load( File.open( File.join(File.dirname(__FILE__), "config/libraries.yaml") ) )[library]
13
+ ext = @library["uncompressed"].split('.').last
17
14
 
18
- @options = options
19
- check_library_name
20
- @options.path = @options.path.nil? ? Dir.pwd : @options.path
21
- @options.extension = Gini::Library.const_get(@options.library.capitalize).const_get("Extension")
22
- @options.installation_path = File.join(@options.path, "#{@options.library.downcase}.#{@options.extension}")
15
+ @options.installation_path = File.join(@options.path, "#{@options.library.downcase}.#{ext}")
16
+ @url = get_library_url
23
17
  end
24
-
25
-
26
- # Gini::Fetch.library(options)
27
- #
28
- # ==== Description
18
+
19
+
20
+ # Convience Method
29
21
  #
30
- # A Class method for installing a library
22
+ # ==== Usage
31
23
  #
32
- # ==== Returns
24
+ # Gini::Fetch.library
33
25
  #
34
- # Returns our exit message to let the user
35
- # know what took place and where they can find the library
36
- # on their system.
37
26
  #
38
27
  def self.library(options)
39
28
  init = new(options)
40
- init.install
41
- # init.need_extraction
42
- init.send_exit_message
29
+ init.check_directory
30
+ init.pull
43
31
  end
44
-
45
-
46
- # Install
32
+
33
+
34
+ # Pull a Libarary
47
35
  #
48
36
  # ==== Description
49
37
  #
50
- # Checks for a compressed version and if the user specified a compressed version
51
- # Pulls the cooresponding Repo and downloads it and writes it to a file in the
52
- # specified path, given by the user
38
+ # Pull the given library and install it to the path given.
53
39
  #
54
- def install
55
- check_directory
56
- check_compression
57
- # archived? ? grab_archive : grab_single_file
58
- grab_archive
59
- end
60
-
61
-
62
- # Grab a Single File
63
- #
64
- # ==== Description
65
40
  #
66
- # If it is a single, file, we'll use the traditional Ruby way
67
- # of grabbing a file.
68
- #
69
- def grab_single_file
41
+ def pull
70
42
  File.open(@options.installation_path, "w+") do |f|
71
43
  f.write( Net::HTTP.get( URI.parse(@url) ) )
72
44
  end
73
45
  end
74
-
75
-
76
- # Grab an Archived File
77
- #
78
- # ==== Description
79
- #
80
- # This uses a system call, curl, to grab an archive off of a server.
81
- # It will then un-archive it (zip, tar, tar.gz, tar.bz2)
82
- #
83
- def grab_archive
84
- FileUtils.cd @options.path
85
- system("curl -L -O #{@url}")
86
- extract_archive
87
- end
88
-
89
-
46
+
47
+
90
48
  # Check Directory
91
49
  #
92
50
  # ==== Description
@@ -99,110 +57,23 @@ module Gini
99
57
  FileUtils.mkdir_p(@options.path)
100
58
  end
101
59
  end
102
-
103
-
104
- # Check Compression
60
+
61
+
62
+ # Compression
105
63
  #
106
64
  # ==== Description
107
65
  #
108
- # Checks to see if the user specified a compressed version and then sees if
109
- # a compressed version is available. The url instance variable is instanstiated
110
- # accordingly.
111
- #
112
- # ==== Returns
113
- #
114
- # Returns the @url instance variable with the cooresponding url for the
115
- # specified library repo.
116
- #
117
- def check_compression
118
- if compression_is_used?
119
- @url = Gini::Library.const_get(@options.library.capitalize).const_get("Compressed")
120
- else
121
- @url = Gini::Library.const_get(@options.library.capitalize).const_get("Repo")
122
- end
123
- end
124
-
125
-
126
- # Extract the Archived File
127
- #
128
- # ==== Description
66
+ # Check if the user asked for compression
129
67
  #
130
- # Extracts the archived file into the current directory
131
- # that it was downloaded into.
132
68
  #
133
- def extract_archive
134
- name = Gini::Library.const_get(@options.library.capitalize).const_get("Name")
135
- Gini::Extract.file(@options.path, @options.extension, name)
69
+ def compression?
70
+ !!@options.compress && !!@library["compressed"]
136
71
  end
137
-
138
-
139
- # Archived?
140
- #
141
- # ==== Description
142
- #
143
- # Is this an archived file?
144
- #
145
- # ==== Returns
146
- #
147
- # Returns a boolean value
148
- #
149
- def archived?
150
- Gini::Supported::Archives.include?(@options.extension)
151
- end
152
-
153
-
154
- # Library Compression
155
- #
156
- # ==== Description
157
- #
158
- # Checks to see if we can offer a compressed version of the Library specified.
159
- #
160
- # ==== Returns
161
- #
162
- # A Boolean value
163
- #
164
- def library_compression?
165
- !!Gini::Library.const_get(@options.library.capitalize).const_get("Compressed")
166
- end
167
-
168
-
169
- # Compression is Used?
170
- #
171
- # ==== Description
172
- #
173
- # Boolean method to check if the user has specified compression and the library
174
- # has a compressed version of the library.
175
- #
176
- # ==== Return
177
- #
178
- # Returns a boolean response
179
- #
180
- def compression_is_used?
181
- library_compression? && @options.compress
182
- end
183
-
184
-
185
- # Exit Message to let the User know what took place
186
- #
187
- def send_exit_message
188
- puts "\n#{@options.library.capitalize} was installed at #{@options.installation_path} and compression was #{translate_to_words}.\n\n"
189
- end
190
-
191
-
192
- # Translate to Words
193
- #
194
- def translate_to_words
195
- compression_is_used? ? "used" : "was not used"
196
- end
197
-
198
-
199
- def check_library_name
200
- case @options.library
201
- when "960"
202
- @options.library = "grid960"
203
- else
204
- end
72
+
73
+
74
+ def get_library_url
75
+ compression? ? @library["compressed"] : @library["uncompressed"]
205
76
  end
206
-
77
+
207
78
  end
208
79
  end
@@ -0,0 +1,74 @@
1
+ module Gini
2
+ class Options
3
+
4
+ def self.parse!(args)
5
+ options = OpenStruct.new
6
+ options.library = args.first.sub(/(\s+)/, '-') unless args.first.nil?
7
+
8
+ opts = OptionParser.new do |opts|
9
+
10
+ opts.banner = "\nGini Usage: gini jquery --path /Users/rrevans/Desktop"
11
+ opts.separator ""
12
+ opts.separator "Options"
13
+
14
+ # Specify the location to install the library
15
+ opts.on("--path NAME", "Specify the path to install the library. If not supplied, it will create the gem in the current Directory.") do |ext|
16
+ options.path = ext || Dir.pwd
17
+ end
18
+
19
+ # Show available libraries that Gini supports to install
20
+ opts.on("-l", "--libraries", "Show available libraries to install. Use the names listed as the name to be passed in to install.\n\t\t\t\t e.g. gini jquery") do |lib|
21
+ puts "\nAvailable Libraries:\n\n"
22
+ Gini::Libraries.each { |lib| puts "#{lib}\n" }
23
+ puts "\n"
24
+ exit(0)
25
+ end
26
+
27
+ # Boolean Switch to compression, if supported
28
+ opts.on("-c", "--compress", "Pull a compressed version, if available") do |ext|
29
+ options.compress = ext
30
+ end
31
+
32
+ # Simple Separator
33
+ opts.separator ""
34
+ opts.separator "Helpful Options"
35
+
36
+
37
+ # Help Screen
38
+ opts.on_tail("-h", "--help", "Show the help screen") do
39
+ puts opts
40
+ puts "\n"
41
+ exit(0)
42
+ end
43
+
44
+ # Show Version
45
+ opts.on_tail("-v", "--version", "Show Gini's current version") do
46
+ puts "\nGini is currently at Version #{Gini::Version}\n"
47
+ exit(0)
48
+ end
49
+
50
+ opts.on_tail do
51
+ if options.library.nil? || options.library == ''
52
+ puts "\nYou need to give the name of the library that you want to install."
53
+ puts opts
54
+ puts "\n"
55
+ exit(0)
56
+ end
57
+ end
58
+
59
+ opts.on_tail do
60
+ unless Gini::Libraries.include?(options.library)
61
+ puts "\n#{options.library} is not a supported library."
62
+ puts opts
63
+ puts "\n"
64
+ exit(0)
65
+ end
66
+ end
67
+ end
68
+
69
+ opts.parse!(args)
70
+ options
71
+ end # parse
72
+
73
+ end # Options
74
+ end # Gini
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revans-gini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert R Evans
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 -08:00
12
+ date: 2009-01-27 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: A basic code generator for various existing libraries
16
+ description: A JavaScript/CSS installer
17
17
  email: revans@robertrevans.com
18
18
  executables:
19
19
  - gini
@@ -30,13 +30,12 @@ files:
30
30
  - Rakefile
31
31
  - bin/gini
32
32
  - lib/gini.rb
33
- - lib/gini/extensions/string.rb
34
- - lib/gini/parser.rb
35
- - lib/gini/library.rb
33
+ - lib/gini/string_extensions.rb
34
+ - lib/gini/parse.rb
35
+ - lib/gini/config/libraries.yaml
36
36
  - lib/gini/fetch.rb
37
- - lib/gini/extract.rb
38
37
  has_rdoc: true
39
- homepage: http://www.robertrevans.com
38
+ homepage: http://www.codewranglers.org
40
39
  post_install_message:
41
40
  rdoc_options: []
42
41
 
@@ -60,6 +59,6 @@ rubyforge_project: gini
60
59
  rubygems_version: 1.2.0
61
60
  signing_key:
62
61
  specification_version: 2
63
- summary: A basic code generator for various existing libraries
62
+ summary: A JavaScript/CSS installer
64
63
  test_files: []
65
64
 
@@ -1,16 +0,0 @@
1
-
2
- Version 0.1.4
3
-
4
- * Added Mootools
5
- * Added Prototype
6
- * Added more documentation
7
-
8
- Version 0.1.2
9
-
10
- * Fixed fetch bugs
11
- * Changed some classnames so the read better
12
-
13
- Version 0.1.0
14
-
15
- * Initial Creation
16
- * jQuery is the only library currently supported
@@ -1,41 +0,0 @@
1
- module Gini
2
- class Extract
3
-
4
- def self.file(path, ext, library_name)
5
- f = new
6
- command = f.uncompress_with(ext)
7
- path_to_file = f.search_for_file(path, library_name)
8
-
9
- system("#{command} #{path_to_file}")
10
- end
11
-
12
-
13
- def uncompress_with(extension)
14
- case extension
15
- when "tar" then "tar xvf"
16
- when "tar.gz" then "tar xzvf"
17
- when "tar.bz2" then "tar xvjf"
18
- when "zip" then "unzip"
19
- else
20
- raise Exception, "I don't know that extension" and exit(0)
21
- end
22
- end
23
-
24
-
25
- def search_for_file(path, lib)
26
- path = Pathname.new(path)
27
- path.children.each do |p|
28
- @archive_path = p.to_s if p.to_s =~ /#{lib}/
29
- end
30
- @archive_path
31
- end
32
-
33
- end
34
- end
35
-
36
- # API
37
- #
38
- # Takes the location of archived file and determines what type of un-archiving method should be used and does so.
39
- # That is all this class should do!
40
- #
41
- # Gini::Extract.file(archived_file)
@@ -1,60 +0,0 @@
1
- module Gini
2
-
3
- # Supported Libraries
4
- Libraries = %w[jquery prototype mootools 960]
5
-
6
- module Library
7
-
8
- # jQuery Repository Information
9
- module Jquery
10
- URL = "http://jqueryjs.googlecode.com/files"
11
- Version = "1.2.6"
12
- Repo = "#{URL}/jquery-#{Version}.js"
13
- Compressed = "#{URL}/jquery-#{Version}.min.js"
14
- Extension = "js" # TODO: crappy hack
15
- end
16
-
17
-
18
- # Prototype Repository Information
19
- module Prototype
20
- URL = "http://www.prototypejs.org/assets"
21
- Version = "1.6.0.3"
22
- Repo = "#{URL}/2008/9/29/prototype-#{Version}.js"
23
- Compressed = nil
24
- Extension = "js"
25
- end
26
-
27
-
28
- # MooTools Repository Information
29
- module Mootools
30
- URL = "http://mootools.net/download/get"
31
- Version = "1.2.1"
32
- Repo = "#{URL}/mootools-#{Version}-core-nc.js"
33
- Compressed = "#{URL}/mootools-#{Version}-core-yc.js"
34
- Extension = "js"
35
- end
36
-
37
-
38
- # 960 Grid CSS Framework
39
- module Grid960
40
- URL = "http://960.gs/files/960_download.zip"
41
- Name = "960"
42
- Version = nil
43
- Repo = "#{URL}"
44
- Compressed = nil
45
- Extension = "zip"
46
- end
47
-
48
-
49
- # Blueprint CSS Framework
50
- # module Blueprint
51
- # URL = "http://github.com/joshuaclayton/blueprint-css/tarball/master"
52
- # Name = "blueprint"
53
- # Version = "0.8"
54
- # Repo = "#{URL}"
55
- # Compressed = nil
56
- # Extension = "tar.gz"
57
- # end
58
-
59
- end
60
- end
@@ -1,72 +0,0 @@
1
- module Gini
2
- class Options
3
-
4
- def self.parse(args)
5
- options = OpenStruct.new
6
-
7
- # Parse Options
8
- opts = OptionParser.new do |opts|
9
- opts.banner = "\nGini Usage: gini --install jquery --path /Users/rrevans/Desktop -f"
10
- opts.separator ""
11
- opts.separator "Required Options"
12
-
13
-
14
- # Install a specific library
15
- opts.on("--install NAME", "Install a Library. Use gini -l to see available libraries.") do |ext|
16
- raise Gini::LibraryNotSupported, "#{ext} is not a supported Library" and exit(0) unless Gini::Libraries.include?(ext)
17
- options.library = ext
18
- end
19
-
20
-
21
- # Specify the location to install the library
22
- opts.on("--path NAME", "Specify the path to install the library.") do |ext|
23
- options.path = ext
24
- end
25
-
26
-
27
- # Show available libraries that Gini supports to install
28
- opts.on("-l", "--libraries", "Show available libraries to install. Use the names listed as the name to be passed in to install.\n\t\t\t\t e.g. gini --install 960") do |lib|
29
- puts "\nAvailable Libraries:\n\n"
30
- Gini::Libraries.each { |lib| puts "#{lib}\n" }
31
- puts "\n"
32
- exit(0)
33
- end
34
-
35
-
36
- # Boolean Switch to force overwrite
37
- # opts.on("-f", "--force", "Force an Overwrite of a current file") do |ext|
38
- # options.force = ext
39
- # end
40
-
41
-
42
- # Boolean Switch to compression, if supported
43
- opts.on("-c", "--compress", "Pull a compressed version, if available") do |ext|
44
- options.compress = ext
45
- end
46
-
47
-
48
- # Simple Separator
49
- opts.separator ""
50
- opts.separator "Common Options"
51
-
52
-
53
- # Help Screen
54
- opts.on_tail("-h", "--help", "Show the help screen") do
55
- puts opts
56
- exit(0)
57
- end
58
-
59
-
60
- # Show Version
61
- opts.on_tail("-v", "--version", "Show Gini's current version") do
62
- puts "Gini is currently at Version #{Gini::Version}"
63
- exit(0)
64
- end
65
- end
66
-
67
- opts.parse!(args)
68
- options
69
- end
70
-
71
- end
72
- end