gram 0.2.0 → 0.3.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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gram (0.1.0)
4
+ gram (0.2.0)
5
5
  activesupport
6
6
  i18n
7
7
  rest-client
data/Readme.md CHANGED
@@ -29,7 +29,7 @@ To bootstrap a new gem, type this:
29
29
 
30
30
  $ gram gem create my_gem
31
31
 
32
- By default, the new gem will be using Minitest & Mocha. If you prefer RSpec:
32
+ By default, the new gem will be using Minitest/Spec & Mocha. If you prefer RSpec:
33
33
 
34
34
  $ gram gem create my_gem --rspec
35
35
 
@@ -41,6 +41,23 @@ just use the `--rails` option:
41
41
  This will add the required dependencies and enable the test suite to use
42
42
  ActiveRecord with in-memory sqlite :)
43
43
 
44
+ ##SSH component
45
+
46
+ Put your peers in your `.gramrc`:
47
+
48
+ token: 289347287365872whatever
49
+ peers:
50
+ john: 192.168.1.43
51
+ jimmy: 192.168.1.99
52
+
53
+ To paste your clipboard's content to your peer's:
54
+
55
+ $ gram ssh paste john
56
+
57
+ You can also broadcast your clipboard's content to all your peers:
58
+
59
+ $ gram ssh broadcast
60
+
44
61
  ## Copyright
45
62
 
46
63
  Copyright (c) 2011 Codegram. See LICENSE for details.
@@ -4,6 +4,8 @@ require 'gram/blog/parser'
4
4
  require 'gram/gem'
5
5
  require 'gram/gem/generator'
6
6
 
7
+ require 'gram/ssh'
8
+
7
9
  module Gram
8
- COMPONENTS = %w(blog gem)
10
+ COMPONENTS = %w(blog gem ssh)
9
11
  end
@@ -0,0 +1,62 @@
1
+ module Gram
2
+ module Ssh
3
+
4
+ ACTIONS = { paste: {
5
+ description: "Pastes the current clipboard content to your PEER's clipboard.",
6
+ arguments: %w(PEER),
7
+ },
8
+ broadcast: {
9
+ description: "Pastes the current clipboard content to all your peers.",
10
+ arguments: %w(),
11
+ }
12
+ }
13
+
14
+ class << self
15
+
16
+ def banner
17
+ out = "Available actions:\n"
18
+ ACTIONS.each_pair do |action, metadata|
19
+ out << "\n\t#{action} #{metadata[:arguments].join(' ')}\t\t#{metadata[:description]}"
20
+ end
21
+
22
+ peers = nil
23
+ if File.exists?(File.join(File.expand_path('~'), '.gramrc')) &&
24
+ peers = YAML.load(File.read(File.join(File.expand_path('~'), '.gramrc')))["peers"]
25
+ out << "\nYour peers are currently: #{peers.keys.join(', ')}"
26
+ else
27
+ out << "\nYou don't have any peers on your ~/.gramrc. Please add some!"
28
+ end
29
+
30
+ out
31
+ end
32
+
33
+ # ACTIONS
34
+
35
+ def paste(peer)
36
+ ip = get_peers[peer]
37
+ puts "Gram::SSH posting \"#{`pbpaste`}\" to #{peer} at #{ip}..."
38
+ system("pbpaste | ssh #{peer}@#{ip} pbcopy")
39
+ puts "Ok!"
40
+ end
41
+
42
+ def broadcast
43
+ get_peers.keys.each do |peer|
44
+ paste peer
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def get_peers
51
+ if File.exists?(File.join(File.expand_path('~'), '.gramrc')) &&
52
+ peers = YAML.load(File.read(File.join(File.expand_path('~'), '.gramrc')))["peers"]
53
+ peers
54
+ else
55
+ puts "Can't get Gram SSH peers. Please create a ~/.gramrc YAML file with some peers."
56
+ exit(1)
57
+ end
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module Gram
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module Gram
4
+ describe Ssh do
5
+
6
+ describe ".paste" do
7
+ it 'pastes a post to a peer' do
8
+ subject.stub(:get_peers).and_return({"josepjaume" => "192.168.1.55.55"})
9
+ subject.should_receive(:system).with("pbpaste | ssh josepjaume@192.168.1.55.55 pbcopy")
10
+
11
+ subject.paste 'josepjaume'
12
+ end
13
+ end
14
+
15
+ describe ".broadcast" do
16
+ it 'pastes a post to every peer' do
17
+ subject.stub(:get_peers).and_return({"josepjaume" => "192.168.1.55.55", "oriol" => "192.168.1.55.54"})
18
+
19
+ subject.should_receive(:paste).with("josepjaume")
20
+ subject.should_receive(:paste).with("oriol")
21
+
22
+ subject.broadcast
23
+ end
24
+ end
25
+
26
+ end
27
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gram
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josep M. Bach
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-04-04 00:00:00 +02:00
15
+ date: 2011-04-19 00:00:00 +02:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -134,11 +134,13 @@ files:
134
134
  - lib/gram/gem/templates/rvmrc.tt
135
135
  - lib/gram/gem/templates/spec/minispec_helper.tt
136
136
  - lib/gram/gem/templates/spec/rspec_helper.tt
137
+ - lib/gram/ssh.rb
137
138
  - lib/gram/version.rb
138
139
  - spec/gram/blog/parser_spec.rb
139
140
  - spec/gram/blog_spec.rb
140
141
  - spec/gram/gem/generator_spec.rb
141
142
  - spec/gram/gem_spec.rb
143
+ - spec/gram/ssh_spec.rb
142
144
  - spec/gram_spec.rb
143
145
  - spec/spec_helper.rb
144
146
  has_rdoc: true
@@ -174,5 +176,6 @@ test_files:
174
176
  - spec/gram/blog_spec.rb
175
177
  - spec/gram/gem/generator_spec.rb
176
178
  - spec/gram/gem_spec.rb
179
+ - spec/gram/ssh_spec.rb
177
180
  - spec/gram_spec.rb
178
181
  - spec/spec_helper.rb