earthquake 0.6.0 → 0.6.1

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.md CHANGED
@@ -86,6 +86,10 @@ Commands
86
86
 
87
87
  ⚡ :thread $xx
88
88
 
89
+ ### Install Plugins
90
+
91
+ ⚡ :plugin_install https://gist.github.com/899506
92
+
89
93
  And there are more commands!
90
94
 
91
95
  Configuration
@@ -219,7 +223,6 @@ TODO
219
223
  ----
220
224
 
221
225
  * guideline for plugin
222
- * ssl for twitter_oauth
223
226
  * deal proxy
224
227
  * spec
225
228
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
data/earthquake.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{earthquake}
8
- s.version = "0.6.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo"]
@@ -1,4 +1,6 @@
1
1
  # encoding: UTF-8
2
+ require 'uri'
3
+ require 'open-uri'
2
4
  Earthquake.init do
3
5
  command :exit do
4
6
  stop
@@ -194,4 +196,31 @@ Earthquake.init do
194
196
  command :'!' do |m|
195
197
  system m[1]
196
198
  end
199
+
200
+ command :plugin_install do |m|
201
+ uri = URI.parse(m[1])
202
+ unless uri.host == "gist.github.com"
203
+ puts "the host must be gist.github.com".c(41)
204
+ else
205
+ puts "..."
206
+ gist_id = uri.path[/\d+/]
207
+ meta = JSON.parse(open("https://gist.github.com/api/v1/json/#{gist_id}").read)
208
+ filename = meta["gists"][0]["files"][0]
209
+ raw = open("https://gist.github.com/raw/#{gist_id}/#{filename}").read
210
+
211
+ puts '-' * 80
212
+ puts raw.c(36)
213
+ puts '-' * 80
214
+
215
+ filename = "#{meta["gists"][0]["repo"]}.rb" if filename =~ /^gistfile/
216
+ filepath = File.join(config[:plugin_dir], filename)
217
+ if confirm("Install to '#{filepath}'?")
218
+ File.open(File.join(config[:plugin_dir], filename), 'w') do |file|
219
+ file << raw
220
+ file << "\n# #{m[1]}"
221
+ end
222
+ reload
223
+ end
224
+ end
225
+ end
197
226
  end
@@ -42,6 +42,8 @@ module Earthquake
42
42
  loaded = ActiveSupport::Dependencies.loaded.dup
43
43
  ActiveSupport::Dependencies.clear
44
44
  loaded.each { |lib| require_dependency lib }
45
+ rescue Exception => e
46
+ error e
45
47
  ensure
46
48
  _init
47
49
  end
@@ -28,12 +28,7 @@ module Earthquake
28
28
  end
29
29
 
30
30
  def input(text)
31
- begin
32
- reload
33
- rescue Exception => e
34
- error e
35
- end
36
-
31
+ reload
37
32
  return if text.empty?
38
33
 
39
34
  begin
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 0.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo