code-rubygists 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.txt +3 -0
- data/lib/rubygists.rb +56 -0
- metadata +55 -0
data/README.txt
ADDED
data/lib/rubygists.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
class RubyGists
|
|
5
|
+
|
|
6
|
+
GIST_SRC = 'git://gist.github.com'
|
|
7
|
+
GIST_DIR = File.join('tmp', 'gist')
|
|
8
|
+
|
|
9
|
+
def self.init
|
|
10
|
+
FileUtils.mkdir_p GIST_DIR
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.exists?(gist)
|
|
14
|
+
dir = File.join(GIST_DIR, gist.to_s)
|
|
15
|
+
File.exists?(dir)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.git_clone(gist, force=false)
|
|
19
|
+
dir = File.join(GIST_DIR, gist.to_s)
|
|
20
|
+
FileUtils.rm_r dir if force and File.exists?(dir)
|
|
21
|
+
system "cd #{GIST_DIR} && git clone #{GIST_SRC}/#{gist}.git"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.list(gist, filter='*.rb')
|
|
25
|
+
Dir[File.join(GIST_DIR, gist.to_s, filter)]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.get(gist, force=false)
|
|
29
|
+
git_clone(gist.to_s, force) if force or !exists?(gist.to_s)
|
|
30
|
+
list(gist)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.clear
|
|
34
|
+
FileUtils.rm_r GIST_DIR
|
|
35
|
+
init
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
RubyGists.init
|
|
41
|
+
|
|
42
|
+
module Kernel
|
|
43
|
+
|
|
44
|
+
def gist_require(gist, force=false)
|
|
45
|
+
RubyGists.get(gist.to_s, force).each do |file|
|
|
46
|
+
return false unless require file
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Usage: example of using password generator
|
|
53
|
+
# require 'rubygems'
|
|
54
|
+
# require 'rubygists'
|
|
55
|
+
# gist_require 21812
|
|
56
|
+
# puts PasswordGenerator.random_password
|
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: code-rubygists
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Luke Hubbard
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-11-03 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Like rubygems but just for gists! No dependency management, no versioning. Dead simple.
|
|
17
|
+
email: luke@codegent.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
|
|
24
|
+
files:
|
|
25
|
+
- README.txt
|
|
26
|
+
- lib/rubygists.rb
|
|
27
|
+
has_rdoc: false
|
|
28
|
+
homepage: http://github.com/code/rubygists
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options:
|
|
31
|
+
- --main
|
|
32
|
+
- README.txt
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: "0"
|
|
40
|
+
version:
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: "0"
|
|
46
|
+
version:
|
|
47
|
+
requirements: []
|
|
48
|
+
|
|
49
|
+
rubyforge_project:
|
|
50
|
+
rubygems_version: 1.2.0
|
|
51
|
+
signing_key:
|
|
52
|
+
specification_version: 2
|
|
53
|
+
summary: Like rubygems but for gists, dead simple.
|
|
54
|
+
test_files: []
|
|
55
|
+
|