gritano 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/gritano +12 -1
- data/gritano.gemspec +11 -2
- data/lib/gritano/console/remote.rb +1 -1
- data/lib/gritano/helpers.rb +5 -5
- data/lib/gritano/renderer.rb +31 -21
- data/lib/gritano.rb +3 -0
- data/spec/gritano/helpers_spec.rb +5 -5
- metadata +51 -3
data/Gemfile
CHANGED
@@ -4,6 +4,9 @@ gem "thor", "~> 0.18.1"
|
|
4
4
|
gem "terminal-table", "~> 1.4.5"
|
5
5
|
gem "gritano-core", "~> 2.0.0"
|
6
6
|
gem "sqlite3", "~> 1.3.7"
|
7
|
+
gem "rainbow", "~> 1.1.4"
|
8
|
+
gem "highline", "~> 1.6.19"
|
9
|
+
gem 'activesupport', "~> 4.0.0.rc1"
|
7
10
|
|
8
11
|
group :development do
|
9
12
|
gem "rspec", "~> 2.13.0"
|
data/Gemfile.lock
CHANGED
@@ -40,6 +40,7 @@ GEM
|
|
40
40
|
guard-rspec (3.0.2)
|
41
41
|
guard (>= 1.8)
|
42
42
|
rspec (~> 2.13)
|
43
|
+
highline (1.6.19)
|
43
44
|
i18n (0.6.4)
|
44
45
|
jeweler (1.8.4)
|
45
46
|
bundler (~> 1.0)
|
@@ -61,6 +62,7 @@ GEM
|
|
61
62
|
coderay (~> 1.0.5)
|
62
63
|
method_source (~> 0.8)
|
63
64
|
slop (~> 3.4)
|
65
|
+
rainbow (1.1.4)
|
64
66
|
rake (10.0.4)
|
65
67
|
rb-fsevent (0.9.3)
|
66
68
|
rb-inotify (0.9.0)
|
@@ -93,9 +95,12 @@ PLATFORMS
|
|
93
95
|
ruby
|
94
96
|
|
95
97
|
DEPENDENCIES
|
98
|
+
activesupport (~> 4.0.0.rc1)
|
96
99
|
gritano-core (~> 2.0.0)
|
97
100
|
guard-rspec
|
101
|
+
highline (~> 1.6.19)
|
98
102
|
jeweler (~> 1.8.4)
|
103
|
+
rainbow (~> 1.1.4)
|
99
104
|
rdoc (~> 4.0.0)
|
100
105
|
rspec (~> 2.13.0)
|
101
106
|
simplecov (~> 0.7.0)
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "gritano"
|
18
|
-
gem.homepage = "http://
|
18
|
+
gem.homepage = "http://gritano.org"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = %Q{Gritano is a tool to configure git servers over ssh}
|
21
21
|
gem.description = %Q{Gritano is a tool to configure git servers over ssh}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/bin/gritano
CHANGED
@@ -5,10 +5,21 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
5
5
|
require 'gritano'
|
6
6
|
require 'etc'
|
7
7
|
|
8
|
+
def line(text, cols)
|
9
|
+
"% #{text}#{' ' * (cols - (text.length + 3))}%"
|
10
|
+
end
|
11
|
+
|
12
|
+
def table(lines)
|
13
|
+
cols = HighLine.new.output_cols
|
14
|
+
(['%' * cols] + lines.map { |l| line(l, cols) } + ['%' * cols]).join("\n")
|
15
|
+
end
|
16
|
+
|
8
17
|
begin
|
9
18
|
load File.join(Etc.getpwuid.dir, '.gritano/local.gritano')
|
10
19
|
rescue LoadError => e
|
11
|
-
|
20
|
+
unless ARGV[0] == 'init'
|
21
|
+
puts table(['WARNING!', 'GRITANO IS NOT INSTALLED']).color(:yellow)
|
22
|
+
end
|
12
23
|
end
|
13
24
|
|
14
25
|
Gritano::CLI::Console::Local.start
|
data/gritano.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gritano"
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Igor Bonadio"]
|
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
"templates/local.gritano",
|
56
56
|
"templates/remote.gritano"
|
57
57
|
]
|
58
|
-
s.homepage = "http://
|
58
|
+
s.homepage = "http://gritano.org"
|
59
59
|
s.licenses = ["MIT"]
|
60
60
|
s.require_paths = ["lib"]
|
61
61
|
s.rubygems_version = "1.8.25"
|
@@ -69,6 +69,9 @@ Gem::Specification.new do |s|
|
|
69
69
|
s.add_runtime_dependency(%q<terminal-table>, ["~> 1.4.5"])
|
70
70
|
s.add_runtime_dependency(%q<gritano-core>, ["~> 2.0.0"])
|
71
71
|
s.add_runtime_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
72
|
+
s.add_runtime_dependency(%q<rainbow>, ["~> 1.1.4"])
|
73
|
+
s.add_runtime_dependency(%q<highline>, ["~> 1.6.19"])
|
74
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 4.0.0.rc1"])
|
72
75
|
s.add_development_dependency(%q<rspec>, ["~> 2.13.0"])
|
73
76
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0.0"])
|
74
77
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
@@ -79,6 +82,9 @@ Gem::Specification.new do |s|
|
|
79
82
|
s.add_dependency(%q<terminal-table>, ["~> 1.4.5"])
|
80
83
|
s.add_dependency(%q<gritano-core>, ["~> 2.0.0"])
|
81
84
|
s.add_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
85
|
+
s.add_dependency(%q<rainbow>, ["~> 1.1.4"])
|
86
|
+
s.add_dependency(%q<highline>, ["~> 1.6.19"])
|
87
|
+
s.add_dependency(%q<activesupport>, ["~> 4.0.0.rc1"])
|
82
88
|
s.add_dependency(%q<rspec>, ["~> 2.13.0"])
|
83
89
|
s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
|
84
90
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
@@ -90,6 +96,9 @@ Gem::Specification.new do |s|
|
|
90
96
|
s.add_dependency(%q<terminal-table>, ["~> 1.4.5"])
|
91
97
|
s.add_dependency(%q<gritano-core>, ["~> 2.0.0"])
|
92
98
|
s.add_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
99
|
+
s.add_dependency(%q<rainbow>, ["~> 1.1.4"])
|
100
|
+
s.add_dependency(%q<highline>, ["~> 1.6.19"])
|
101
|
+
s.add_dependency(%q<activesupport>, ["~> 4.0.0.rc1"])
|
93
102
|
s.add_dependency(%q<rspec>, ["~> 2.13.0"])
|
94
103
|
s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
|
95
104
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
data/lib/gritano/helpers.rb
CHANGED
@@ -6,7 +6,7 @@ module Gritano
|
|
6
6
|
if instance.save
|
7
7
|
render_text "#{model.name.split(':')[-1].downcase} was successfully created."
|
8
8
|
else
|
9
|
-
render_text "an error occurred."
|
9
|
+
render_text "an error occurred.", :error
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ module Gritano
|
|
14
14
|
if instance.update_attributes(params)
|
15
15
|
render_text "#{instance.class.name.split(':')[-1].downcase} was successfully updated."
|
16
16
|
else
|
17
|
-
render_text "an error occurred."
|
17
|
+
render_text "an error occurred.", :error
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,7 @@ module Gritano
|
|
24
24
|
instance.destroy
|
25
25
|
render_text "#{model.name.split(':')[-1].downcase} was successfully destroyed."
|
26
26
|
else
|
27
|
-
render_text "#{model.name.split(':')[-1].downcase} doens't exist."
|
27
|
+
render_text "#{model.name.split(':')[-1].downcase} doens't exist.", :error
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ module Gritano
|
|
32
32
|
unless variables.index(nil)
|
33
33
|
block.call(*variables)
|
34
34
|
else
|
35
|
-
render_text "an error occurred"
|
35
|
+
render_text "an error occurred", :error
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,7 +40,7 @@ module Gritano
|
|
40
40
|
if user.send("#{add_or_rm}_access", repo, read_or_write)
|
41
41
|
render_text "done"
|
42
42
|
else
|
43
|
-
render_text "an error occurred"
|
43
|
+
render_text "an error occurred", :error
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
data/lib/gritano/renderer.rb
CHANGED
@@ -1,35 +1,45 @@
|
|
1
1
|
module Gritano
|
2
2
|
module CLI
|
3
3
|
module Renderer
|
4
|
-
def render_text(text)
|
5
|
-
|
4
|
+
def render_text(text, level = :success)
|
5
|
+
if level == :success
|
6
|
+
puts text.color(:green)
|
7
|
+
elsif level == :warning
|
8
|
+
puts text.color(:yellow)
|
9
|
+
else
|
10
|
+
puts text.color(:red)
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
def render_table(elements, *attributes)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
if elements.count > 0
|
16
|
+
attributes_hash = {}
|
17
|
+
attributes.each do |a|
|
18
|
+
if a.respond_to?(:keys)
|
19
|
+
attributes_hash = attributes_hash.merge(a)
|
20
|
+
else
|
21
|
+
attributes_hash[a] = nil
|
22
|
+
end
|
15
23
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
table = Terminal::Table.new do |t|
|
25
|
+
t << attributes_hash.map { |key, value| key }
|
26
|
+
t << :separator
|
27
|
+
elements.each do |element|
|
28
|
+
row = []
|
29
|
+
attributes_hash.each do |attribute, params|
|
30
|
+
if params
|
31
|
+
row << element.send(attribute, params)
|
32
|
+
else
|
33
|
+
row << element.send(attribute)
|
34
|
+
end
|
27
35
|
end
|
36
|
+
t.add_row row
|
28
37
|
end
|
29
|
-
t.add_row row
|
30
38
|
end
|
39
|
+
render_text table.to_s
|
40
|
+
else
|
41
|
+
render_text "there aren't #{elements.model.name.split(':')[-1].pluralize.downcase}", :warning
|
31
42
|
end
|
32
|
-
render_text table
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
data/lib/gritano.rb
CHANGED
@@ -2,6 +2,9 @@ root_path = File.expand_path(File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
require "gritano-core"
|
4
4
|
require 'terminal-table'
|
5
|
+
require 'rainbow'
|
6
|
+
require "highline/import"
|
7
|
+
require 'active_support/inflector'
|
5
8
|
|
6
9
|
require File.join(root_path, 'gritano/thor')
|
7
10
|
require File.join(root_path, 'gritano/renderer')
|
@@ -27,7 +27,7 @@ module Gritano::CLI
|
|
27
27
|
model.should_receive(:new).with(params).and_return(instance)
|
28
28
|
model.stub(:name).and_return("Module::Class")
|
29
29
|
instance.should_receive(:save).and_return(false)
|
30
|
-
@object.should_receive(:render_text).with(/an error occurred
|
30
|
+
@object.should_receive(:render_text).with(/an error occurred/, :error)
|
31
31
|
@object.create_model(model, params)
|
32
32
|
end
|
33
33
|
end
|
@@ -45,7 +45,7 @@ module Gritano::CLI
|
|
45
45
|
instance = double("Instance")
|
46
46
|
params = {param: 'value'}
|
47
47
|
instance.should_receive(:update_attributes).with(params).and_return(false)
|
48
|
-
@object.should_receive(:render_text).with(/an error occurred
|
48
|
+
@object.should_receive(:render_text).with(/an error occurred/, :error)
|
49
49
|
@object.update_model(instance, params)
|
50
50
|
end
|
51
51
|
end
|
@@ -67,7 +67,7 @@ module Gritano::CLI
|
|
67
67
|
params = {param: 'value'}
|
68
68
|
model.should_receive(:where).with(params).and_return([])
|
69
69
|
model.stub(:name).and_return("Module::Class")
|
70
|
-
@object.should_receive(:render_text).with(/doens't exist
|
70
|
+
@object.should_receive(:render_text).with(/doens't exist/, :error)
|
71
71
|
@object.destroy_model(model, params)
|
72
72
|
end
|
73
73
|
end
|
@@ -82,7 +82,7 @@ module Gritano::CLI
|
|
82
82
|
it "should not use nil objects" do
|
83
83
|
obj = double("Nil")
|
84
84
|
obj.should_not_receive(:touch)
|
85
|
-
@object.should_receive(:render_text).with(/an error occurred
|
85
|
+
@object.should_receive(:render_text).with(/an error occurred/, :error)
|
86
86
|
@object.use_if_not_nil(nil) { obj.touch }
|
87
87
|
end
|
88
88
|
end
|
@@ -100,7 +100,7 @@ module Gritano::CLI
|
|
100
100
|
user = double("User")
|
101
101
|
repo = double("Repo")
|
102
102
|
user.should_receive(:send).and_return(false)
|
103
|
-
@object.should_receive(:render_text).with(/an error occurred
|
103
|
+
@object.should_receive(:render_text).with(/an error occurred/, :error)
|
104
104
|
@object.try_change_access(user, repo, :add, :read)
|
105
105
|
end
|
106
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gritano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,6 +75,54 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.3.7
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rainbow
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.1.4
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.1.4
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: highline
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.6.19
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.6.19
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: activesupport
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.0.0.rc1
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 4.0.0.rc1
|
78
126
|
- !ruby/object:Gem::Dependency
|
79
127
|
name: rspec
|
80
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,7 +250,7 @@ files:
|
|
202
250
|
- templates/local.gritano
|
203
251
|
- templates/remote.gritano
|
204
252
|
- TODO
|
205
|
-
homepage: http://
|
253
|
+
homepage: http://gritano.org
|
206
254
|
licenses:
|
207
255
|
- MIT
|
208
256
|
post_install_message:
|
@@ -217,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
265
|
version: '0'
|
218
266
|
segments:
|
219
267
|
- 0
|
220
|
-
hash: -
|
268
|
+
hash: -420660352722020068
|
221
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
270
|
none: false
|
223
271
|
requirements:
|