backgem 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.markdown +15 -0
  2. data/bin/backgem +32 -1
  3. metadata +11 -11
  4. data/README +0 -1
data/README.markdown ADDED
@@ -0,0 +1,15 @@
1
+ INFO
2
+ ====
3
+ Backgem is dead simple tool for backing up and restoring installed gems.
4
+
5
+ Usage
6
+ =====
7
+ > $ backgem backup - create gems.txt file, including names of all installed gems
8
+
9
+ > $ backgem restore - install all gems listed in gems.txt
10
+
11
+ > $ backgem make_gist - create a gist with list of installed gems
12
+
13
+ Instalation
14
+ ===========
15
+ > $ gem install backgem --source=http://gemcutter.org
data/bin/backgem CHANGED
@@ -2,6 +2,7 @@
2
2
  # Author: Mitko Kostov
3
3
  # http://mitkokostov.info | mitko.kostov@gmail.com
4
4
  # LICENSE: MIT
5
+ require "net/http"
5
6
 
6
7
  class Backgem
7
8
 
@@ -28,15 +29,45 @@ class Backgem
28
29
  save_list
29
30
  end
30
31
 
32
+ def make_gist
33
+ get_list
34
+ write_to_gist(@list)
35
+ end
36
+
37
+ private
31
38
 
32
39
  def method_missing(name)
33
40
  puts "Undefined command #{name}. Availble commands: backup and restore"
34
41
  end
42
+
43
+ def write_to_gist(content)
44
+ url = URI.parse('http://gist.github.com/gists')
45
+ gist_name = "backgem-#{Time.new.strftime("%Y-%m-%d")}"
46
+ req = Net::HTTP.post_form(url, data(gist_name,"txt", content))
47
+ puts req['Location']
48
+ end
49
+
50
+
51
+ def data(name, ext, content)
52
+ return {
53
+ 'file_ext[gistfile1]' => ext,
54
+ 'file_name[gistfile1]' => name,
55
+ 'file_contents[gistfile1]' => content
56
+ }.merge(auth)
57
+ end
58
+
59
+ def auth
60
+ user = `git config --global github.user`.strip
61
+ token = `git config --global github.token`.strip
62
+
63
+ user.empty? ? {} : { :login => user, :token => token }
64
+ end
65
+
35
66
  end
36
67
 
37
68
  if ARGV[0]
38
69
  action = Backgem.new
39
70
  action.send(ARGV[0].to_sym)
40
71
  else
41
- puts "Usage: ./backgem.rb command"
72
+ puts "Usage: backgem backup or backgem restore"
42
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitko Kostov
@@ -9,29 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-25 00:00:00 +03:00
13
- default_executable: backgem
12
+ date: 2009-12-04 00:00:00 +02:00
13
+ default_executable: bin/backgem
14
14
  dependencies: []
15
15
 
16
- description:
16
+ description: Back up your installed gems list into a file/gist
17
17
  email: mitko.kostov@gmail.com
18
18
  executables:
19
19
  - backgem
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files:
23
- - LICENSE
24
- - README
22
+ extra_rdoc_files: []
23
+
25
24
  files:
26
25
  - LICENSE
27
- - README
26
+ - README.markdown
27
+ - bin/backgem
28
28
  has_rdoc: true
29
29
  homepage: http://github.com/mitkok/backgem
30
30
  licenses: []
31
31
 
32
32
  post_install_message:
33
- rdoc_options:
34
- - --charset=UTF-8
33
+ rdoc_options: []
34
+
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -52,6 +52,6 @@ rubyforge_project:
52
52
  rubygems_version: 1.3.5
53
53
  signing_key:
54
54
  specification_version: 3
55
- summary: Backgem is dead simple tool for backing up and restoring installed gems
55
+ summary: Back up your installed gems list into a file/gist
56
56
  test_files: []
57
57
 
data/README DELETED
@@ -1 +0,0 @@
1
- Backgem is dead simple tool for backing up and restoring installed gems