thor-install-gist 0.2.0

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in thor-install-gist.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Uchio KONDO
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # thor-install-gist
2
+
3
+ A thor sub-command to install thor tasks from gists
4
+
5
+ ## Installation
6
+
7
+ Just install it yourself as:
8
+
9
+ $ gem install thor-install-gist
10
+
11
+ Then run below as guide:
12
+
13
+ $ thor-install-gist-init
14
+
15
+ Command will be installed into your `$HOME/.thor`.
16
+
17
+ ## Usage
18
+
19
+ If you have installed then run below:
20
+
21
+ $ thor install:gist GIST_ID
22
+
23
+ `GIST_ID` should be a Gist's ID (your `123456`),
24
+ or URL can be used (`https://gist.github.com/123456`) for copying and pasting
25
+
26
+ Options `--as` and `--force` can be used as you do `thor install`
27
+
28
+ ## License
29
+
30
+ See LICENSE.txt
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require 'thor-install-gist'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ gem 'thor-install-gist'
3
+ require 'thor-install-gist/initialize'
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require "rubygems/installer"
3
+ require 'thor-install-gist/hook'
@@ -0,0 +1,41 @@
1
+ require 'thor/runner'
2
+ require 'open-uri'
3
+ require 'json'
4
+
5
+ class Thor
6
+ class InstallGist < ::Thor
7
+ class ThorTaskNotFound < StandardError
8
+ end
9
+
10
+ namespace 'install'
11
+ desc 'gist GIST_ID', 'install a thor task from the specified gist id'
12
+ method_options :as => :string, :force => :boolean
13
+ def gist(gist_id)
14
+ @gist_id = case gist_id
15
+ when /^\d+$/
16
+ gist_id
17
+ when %r|^https?://gist\.github\.com/\d+|
18
+ URI.parse(gist_id).path.scan(/\d+/).first
19
+ when %r|^gist?:(//)?\d+|
20
+ gist = URI.parse(gist_id)
21
+ gist.opaque || gist.host
22
+ else
23
+ raise "Invalid gist uri scheme: #{gist_id}"
24
+ end
25
+
26
+ json = JSON.parse open(api_path).read
27
+ if file_info = json["files"].find {|f| f[0] =~ /(thor|\.rb$)/i }
28
+ raw_url = file_info[1]["raw_url"]
29
+ Thor::Runner.new(["install", raw_url], options).install raw_url
30
+ else
31
+ raise ThorTaskNotFound, "Cannot find thor task file in your gist"
32
+ end
33
+ end
34
+
35
+ private
36
+ def api_path
37
+ "https://api.github.com/gists/#{@gist_id}"
38
+ end
39
+ end
40
+ end
41
+ require "thor-install-gist/version"
@@ -0,0 +1,18 @@
1
+ require 'thor/runner'
2
+
3
+ Gem.pre_uninstall do |uninstalled|
4
+ if uninstalled.instance_variable_get(:@gem) == "thor-install-gist"
5
+ $stderr.puts "[I] uninstalling thor tasks for thor-install-gist"
6
+ begin
7
+ Thor::Runner.new.uninstall('install-gist')
8
+ rescue Thor::Error => e
9
+ if e.message =~ /Can't find module/
10
+ $stderr.puts "[W] uninstalling thor tasks failed! you just have uninstalled by yourself?"
11
+ $stderr.puts "[W] skip uninstall"
12
+ true
13
+ else
14
+ raise e
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ require 'thor/runner'
2
+
3
+ $stderr.puts "[I] installing thor tasks for thor-install-gist"
4
+ bin = File.expand_path(File.dirname(__FILE__) + '/../../bin/install-gist.rb')
5
+ installer = Thor::Runner.new([], as: 'install-gist', force: true)
6
+ installer.install(bin)
7
+ $stderr.puts "[I] install done!"
8
+
9
+ exit 0
@@ -0,0 +1,6 @@
1
+ require 'thor-install-gist'
2
+ class Thor
3
+ class InstallGist
4
+ VERSION = "0.2.0"
5
+ end
6
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'thor-install-gist/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "thor-install-gist"
8
+ gem.version = Thor::InstallGist::VERSION
9
+ gem.authors = ["Uchio KONDO"]
10
+ gem.email = ["udzura@udzura.jp"]
11
+ gem.description = %q{A thor sub-command to install thor tasks from gists}
12
+ gem.summary = %q{A thor sub-command to install thor tasks from gists}
13
+ gem.homepage = "https://github.com/udzura/thor-install-gist"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.post_install_message = (<<-EOM).gsub(/^ /, '')
21
+
22
+ \e[37mThank you for installing thor-install-gist!
23
+ You can use a task `thor install:gist' after you run:
24
+
25
+ \e[1m\e[33m$ \e[36mthor-install-gist-init
26
+
27
+ \e[0m\e[37mThen the command will be installed into your `$HOME/.thor'
28
+ Enjoy!\e[0m
29
+
30
+ EOM
31
+
32
+ gem.add_runtime_dependency 'thor', '>= 0'
33
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thor-install-gist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Uchio KONDO
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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: '0'
30
+ description: A thor sub-command to install thor tasks from gists
31
+ email:
32
+ - udzura@udzura.jp
33
+ executables:
34
+ - install-gist.rb
35
+ - thor-install-gist-init
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/install-gist.rb
45
+ - bin/thor-install-gist-init
46
+ - lib/rubygems_plugin.rb
47
+ - lib/thor-install-gist.rb
48
+ - lib/thor-install-gist/hook.rb
49
+ - lib/thor-install-gist/initialize.rb
50
+ - lib/thor-install-gist/version.rb
51
+ - thor-install-gist.gemspec
52
+ homepage: https://github.com/udzura/thor-install-gist
53
+ licenses: []
54
+ post_install_message: ! "\n\e[37mThank you for installing thor-install-gist!\nYou
55
+ can use a task `thor install:gist' after you run:\n\n \e[1m\e[33m$ \e[36mthor-install-gist-init\n\n\e[0m\e[37mThen
56
+ the command will be installed into your `$HOME/.thor'\nEnjoy!\e[0m\n\n"
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.24
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: A thor sub-command to install thor tasks from gists
78
+ test_files: []