gistribute 0.0.1.pre1

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.
Files changed (6) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +5 -0
  3. data/Rakefile +5 -0
  4. data/bin/gistribute +75 -0
  5. data/gistribute.gemspec +24 -0
  6. metadata +100 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 Vinny Diehl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Gistribute
2
+
3
+ Gistribute is a simple file distribution system based on GitHub's Gist service.
4
+
5
+ More coming soon.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task dist: :build
5
+ task default: :build
data/bin/gistribute ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "json"
4
+ require "open-uri"
5
+ require "colorize"
6
+ require "nutella"
7
+
8
+ print "Downloading data..."
9
+
10
+ begin
11
+ # TODO: Let the user paste the entire Gist URL and parse out the ID.
12
+ gist = JSON.parse open("https://api.github.com/gists/#{ARGV.first}").read
13
+ rescue OpenURI::HTTPError => msg
14
+ puts <<-EOS.heredoc.red
15
+
16
+
17
+ There was an error downloading the requested Gist.
18
+ The error is as follows:
19
+ EOS
20
+
21
+ puts msg
22
+
23
+ exit -1
24
+ end
25
+
26
+ # The JSON data contains a lot of information. The information that is
27
+ # relevant to this program is as follows:
28
+ #
29
+ # {
30
+ # "html_url" => "Link to the Gist",
31
+ # "description" => "The description for the Gist",
32
+ #
33
+ # "user" => nil, # IF ANONYMOUS
34
+ # "user" => { # IF TIED TO A USER
35
+ # "login" => "username"
36
+ # },
37
+ #
38
+ # "files" => {
39
+ # "filename of first file" => {
40
+ # "content" => "entire contents of the file"
41
+ # }
42
+ # # Repeat the above for every file in the Gist.
43
+ # }
44
+ # }
45
+
46
+ user = gist["user"] ? "user #{gist["user"]["login"]}" : "an anonymous user"
47
+
48
+ puts <<-EOS.heredoc
49
+
50
+
51
+ Finished downloading Gist from: #{gist["html_url"]}
52
+ Gist uploaded by #{user}.
53
+
54
+ Beginning install...
55
+ EOS
56
+
57
+ gist["files"].each do |filename, data|
58
+ lines = data["content"].split "\n"
59
+
60
+ # Parse out all metadata after %% on the first two lines, strip out
61
+ # (lead|trail)ing whitespace while we're at it.
62
+ metadata = lines[0..1].map { |line| line[/%%\s*(.*\S)\s*/, 1] }
63
+
64
+ # Skip non-Gistribute files.
65
+ next if metadata.first.nil?
66
+
67
+ puts " #{"*".green} Installing #{metadata[1] || filename}..."
68
+
69
+ # TODO: Handle ~ better. Also, handle EOF newlines.
70
+ File.open(metadata.first.gsub(/~/, Dir.home), "w") do |f|
71
+ # Remove all lines with metadata- lines that don't match will return nil,
72
+ # so compact it and drop that many off the top of the file.
73
+ f << lines[metadata.compact.size..-1].join("\n")
74
+ end
75
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = "gistribute"
3
+ gem.version = File.read(File.expand_path("../VERSION", __FILE__)).strip
4
+
5
+ gem.author = "Vinny Diehl"
6
+ gem.email = "vinny.diehl@gmail.com"
7
+ gem.homepage = "https://github.com/gbchaosmaster/gistribute"
8
+
9
+ gem.license = "MIT"
10
+
11
+ gem.summary = "GitHub Gist based file distribution."
12
+ gem.description = "Distribute files simply using GitHub Gist."
13
+
14
+ gem.bindir = "bin"
15
+ gem.executables = %w[gistribute]
16
+
17
+ gem.files = Dir["bin/**/*"] + %w[
18
+ LICENSE Rakefile README.md gistribute.gemspec
19
+ ]
20
+
21
+ gem.add_dependency "json", "~> 1.7"
22
+ gem.add_dependency "nutella", "~> 0.10"
23
+ gem.add_dependency "colorize", "~> 0.5"
24
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gistribute
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Vinny Diehl
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nutella
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.10'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.10'
46
+ - !ruby/object:Gem::Dependency
47
+ name: colorize
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.5'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.5'
62
+ description: Distribute files simply using GitHub Gist.
63
+ email: vinny.diehl@gmail.com
64
+ executables:
65
+ - gistribute
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - bin/gistribute
70
+ - LICENSE
71
+ - Rakefile
72
+ - README.md
73
+ - gistribute.gemspec
74
+ homepage: https://github.com/gbchaosmaster/gistribute
75
+ licenses:
76
+ - MIT
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>'
91
+ - !ruby/object:Gem::Version
92
+ version: 1.3.1
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.24
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: GitHub Gist based file distribution.
99
+ test_files: []
100
+ has_rdoc: