shellcast 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.1.0
data/bin/shellcast CHANGED
@@ -25,7 +25,11 @@ when 'list'
25
25
  ShellCast::Player.list
26
26
  when 'play'
27
27
  if ARGV[1]
28
- ShellCast::Player.play(ARGV[1])
28
+ if ARGV[1] =~ /^http:.*/
29
+ ShellCast::Player.play_remote(ARGV[1])
30
+ else
31
+ ShellCast::Player.play(ARGV[1])
32
+ end
29
33
  else
30
34
  puts "Missing id for shellcast"
31
35
  ShellCast::Player.list
@@ -1,4 +1,9 @@
1
1
  # encoding: utf-8
2
+ require 'net/http'
3
+ require 'tmpdir'
4
+ require 'fileutils'
5
+ require 'pathname'
6
+
2
7
  module ShellCast
3
8
  class Player
4
9
 
@@ -39,6 +44,31 @@ module ShellCast
39
44
  new(id).play
40
45
  end
41
46
 
47
+ def self.play_remote(url)
48
+ puts ".==> Fetching #{url}".white_on_black
49
+ resp = Net::HTTP.get(URI.parse(url))
50
+ parts = JSON.parse(resp)
51
+
52
+ print "| Title:\t".yellow
53
+ puts parts['title']
54
+ print "| Description:\t".yellow
55
+ puts parts['description']
56
+
57
+ Dir.mktmpdir do |dir|
58
+ %w(typescript timing).each do |type|
59
+ File.open(File.join(dir, type), 'w') { |f| f.puts(parts[type]) }
60
+ end
61
+ puts "+==> Playing... ".white_on_black
62
+ system "scriptreplay #{File.join(dir, 'timing')} #{File.join(dir, 'typescript')}"
63
+ puts "+\n+"
64
+ print "| Title:\t".yellow
65
+ puts parts['title']
66
+ print "| Description:\t".yellow
67
+ puts parts['description']
68
+ puts "`==> The end... ".white_on_black
69
+ end
70
+ end
71
+
42
72
  def self.list
43
73
  Dir[File.join(ShellCast::DATA_DIR, "**", 'meta')].each do |path|
44
74
  metadata = JSON.parse(IO.read(path))
@@ -4,17 +4,15 @@ require 'uri'
4
4
  module ShellCast
5
5
  class Publisher
6
6
 
7
- API_URL = ENV['SC_LOCAL'] ? 'http://localhost:3000' : 'http://shell.heroku.com'
8
-
9
7
  def publish(id)
10
- uri = URI.parse(API_URL + '/records')
8
+ uri = URI.parse(ShellCast::API_URL + '/records')
11
9
  params = { 'record' => prepare(id) }
12
10
  params.merge!({'api_key' => ShellCast.api_key}) if api_key
13
11
  res = Net::HTTP.post_form(uri, params)
14
12
  res = JSON.parse(res.body)
15
13
  if res['ok']
16
14
  puts res['message']
17
- puts API_URL + '/records/' + res['id']
15
+ puts ShellCast::API_URL + '/records/' + res['id']
18
16
  else
19
17
  puts res['message']
20
18
  end
data/lib/shellcast.rb CHANGED
@@ -11,6 +11,7 @@ module ShellCast
11
11
  DATA_DIR = File.join(XDG::Data.home, APP_NAME)
12
12
  CONFIG_DIR = File.join(XDG::Config.home, APP_NAME)
13
13
  API_KEY = File.join(CONFIG_DIR, 'api_key')
14
+ API_URL = ENV['SC_LOCAL'] ? 'http://localhost:3000' : 'http://shell.heroku.com'
14
15
 
15
16
  class << self
16
17
  def api_key
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 6
9
- version: 0.0.6
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Antono Vasiljev
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-30 00:00:00 +02:00
17
+ date: 2011-01-15 00:00:00 +02:00
18
18
  default_executable: shellcast
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -152,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- hash: 163170419
155
+ hash: -462718573
156
156
  segments:
157
157
  - 0
158
158
  version: "0"