git-flattr 0.0.2 → 0.0.3
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/Gemfile.lock +5 -1
- data/README.md +1 -1
- data/bin/git-flattr +94 -46
- data/git-flattr.gemspec +4 -1
- data/lib/version.rb +1 -0
- metadata +19 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git-flattr (0.0.
|
4
|
+
git-flattr (0.0.2)
|
5
|
+
commander
|
5
6
|
flattr
|
6
7
|
launchy
|
7
8
|
|
@@ -9,11 +10,14 @@ GEM
|
|
9
10
|
remote: http://rubygems.org/
|
10
11
|
specs:
|
11
12
|
addressable (2.2.8)
|
13
|
+
commander (4.1.2)
|
14
|
+
highline (~> 1.6.11)
|
12
15
|
faraday (0.8.0)
|
13
16
|
multipart-post (~> 1.1)
|
14
17
|
flattr (0.3.5)
|
15
18
|
faraday (~> 0.7)
|
16
19
|
multi_json (~> 1.0)
|
20
|
+
highline (1.6.11)
|
17
21
|
launchy (2.1.0)
|
18
22
|
addressable (~> 2.2.6)
|
19
23
|
multi_json (1.3.4)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
git-flattr
|
2
2
|
==========
|
3
3
|
|
4
|
-
This is a gem that makes it easy to Flattr GitHub repositories from the command line. It's still in early development.
|
4
|
+
This is a gem that makes it easy to Flattr GitHub repositories and commits from the command line. It's still in early development and currently you can only flattr repositories.
|
data/bin/git-flattr
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
3
|
+
require 'version'
|
3
4
|
require 'flattr'
|
4
5
|
require 'launchy'
|
6
|
+
require 'commander/import'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
program :name, "git flattr"
|
9
|
+
program :description, "Easily flattr GitHub repositories from the CLI"
|
10
|
+
program :version, VERSION
|
11
|
+
program :help, 'Author', 'Simon Gate <simon@smgt.me>'
|
12
|
+
default_command :help
|
10
13
|
|
11
14
|
def error message
|
12
15
|
puts "Error: #{message}"
|
@@ -57,59 +60,104 @@ class Git
|
|
57
60
|
end
|
58
61
|
return @github_url
|
59
62
|
end
|
63
|
+
|
64
|
+
def valid?
|
65
|
+
|
66
|
+
git_opts = {
|
67
|
+
:dir => "#{Dir.pwd}/.git",
|
68
|
+
:config => "#{Dir.pwd}/.git/config"
|
69
|
+
}
|
70
|
+
|
71
|
+
unless File.exists?(git_opts[:dir])
|
72
|
+
error "Don't seem to be a git repository"
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
|
76
|
+
unless File.exists?(git_opts[:config])
|
77
|
+
error "Git .config file not found"
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
81
|
+
unless Git.github_repository?
|
82
|
+
error "Not a GitHub repository"
|
83
|
+
exit 1
|
84
|
+
end
|
85
|
+
end
|
60
86
|
end
|
61
87
|
end
|
62
88
|
|
63
|
-
|
89
|
+
module Auth
|
90
|
+
class <<self
|
91
|
+
def is_authed?
|
92
|
+
Git.config('flattr.token') != ""
|
93
|
+
end
|
64
94
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
95
|
+
def do!
|
96
|
+
begin
|
97
|
+
Launchy.open("https://git-flattr.herokuapp.com/")
|
98
|
+
token = ask("Token: ")
|
99
|
+
rescue Exception => e
|
100
|
+
puts e.message
|
101
|
+
puts "Seems like you are missing a Flattr access token."
|
102
|
+
puts "Browse to http://git-flattr.herokuapp.com and follow the instructions"
|
103
|
+
token = ask("Token: ")
|
104
|
+
end
|
105
|
+
if token.nil?
|
106
|
+
error "Invalid access token"
|
107
|
+
exit 1
|
108
|
+
end
|
69
109
|
|
70
|
-
|
71
|
-
|
72
|
-
exit 1
|
110
|
+
Git.set_config "flattr.token", token.chomp
|
111
|
+
end
|
73
112
|
end
|
113
|
+
end
|
114
|
+
|
115
|
+
Flattr.configure do |config|
|
116
|
+
config.access_token = Git.config 'flattr.token'
|
117
|
+
end
|
118
|
+
|
119
|
+
command :repo do |c|
|
74
120
|
|
75
|
-
unless Git.github_repository?
|
76
|
-
error "Not a GitHub repository"
|
77
|
-
exit 1
|
78
|
-
end
|
79
121
|
|
80
|
-
|
122
|
+
c.syntax = "git flattr repo"
|
123
|
+
c.description = "Flattr the repository"
|
124
|
+
c.action do |args, options|
|
81
125
|
begin
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
126
|
+
|
127
|
+
Git.valid?
|
128
|
+
|
129
|
+
if !Auth.is_authed?
|
130
|
+
Auth.do!
|
131
|
+
end
|
132
|
+
|
133
|
+
flattr = Flattr.new
|
134
|
+
flattr.flattr Git.github_url
|
135
|
+
thing = flattr.thing_lookup Git.github_url
|
136
|
+
puts "Flattred #{Git.github_url} (#{thing.link})!"
|
137
|
+
exit 0
|
138
|
+
|
139
|
+
rescue Flattr::Error::Unauthorized => e
|
140
|
+
error e.message
|
141
|
+
exit 1
|
142
|
+
rescue Flattr::Error::Forbidden => e
|
143
|
+
error e.message
|
94
144
|
exit 1
|
95
145
|
end
|
96
|
-
Git.set_config "flattr.token", token.chomp
|
97
146
|
end
|
147
|
+
end
|
98
148
|
|
99
|
-
|
100
|
-
|
101
|
-
|
149
|
+
command :commit do |c|
|
150
|
+
c.syntax = "git flattr commit [commit]"
|
151
|
+
c.description = "Flattr a commit"
|
152
|
+
c.action do |args, opts|
|
153
|
+
begin
|
154
|
+
Git.valid?
|
102
155
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
error e.message
|
111
|
-
exit 1
|
112
|
-
rescue Flattr::Error::Forbidden => e
|
113
|
-
error e.message
|
114
|
-
exit 1
|
156
|
+
if !Auth.is_authed?
|
157
|
+
Auth.do!
|
158
|
+
end
|
159
|
+
|
160
|
+
ARGV.shift
|
161
|
+
end
|
162
|
+
end
|
115
163
|
end
|
data/git-flattr.gemspec
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib/", __FILE__)
|
3
|
+
require "version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = 'git-flattr'
|
5
|
-
s.version =
|
7
|
+
s.version = VERSION
|
6
8
|
s.authors = ['Simon Gate']
|
7
9
|
s.email = ['simon@smgt.me']
|
8
10
|
s.summary = %q{Flattr GitHub repositories from the cli}
|
@@ -13,4 +15,5 @@ Gem::Specification.new do |s|
|
|
13
15
|
|
14
16
|
s.add_runtime_dependency "flattr"
|
15
17
|
s.add_runtime_dependency "launchy"
|
18
|
+
s.add_runtime_dependency "commander"
|
16
19
|
end
|
data/lib/version.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
VERSION="0.0.3"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-flattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: flattr
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: commander
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description:
|
47
63
|
email:
|
48
64
|
- simon@smgt.me
|
@@ -58,6 +74,7 @@ files:
|
|
58
74
|
- Rakefile
|
59
75
|
- bin/git-flattr
|
60
76
|
- git-flattr.gemspec
|
77
|
+
- lib/version.rb
|
61
78
|
homepage:
|
62
79
|
licenses: []
|
63
80
|
post_install_message:
|