gritano 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Gritano v0.1.1
1
+ = Gritano v0.1.2
2
2
 
3
3
  Gritano is the simplest way to configure a git server over ssh. You can create repositories and manage user access using this practical tool.
4
4
 
@@ -25,7 +25,7 @@ After that you can add users:
25
25
 
26
26
  add user's public keys:
27
27
 
28
- $ gritano user +key mykey id_rsa.pub
28
+ $ gritano user +key igorbonadio mykey id_rsa.pub
29
29
 
30
30
  create bare repositories:
31
31
 
data/TODO CHANGED
@@ -0,0 +1 @@
1
+ - melhorar mensagens de retorno
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/bin/gritano CHANGED
@@ -46,6 +46,13 @@ def check_git
46
46
  end
47
47
  end
48
48
 
49
+ def check_gritano
50
+ unless File.exist?(File.join(Etc.getpwuid.dir, '.gritano'))
51
+ puts "Error: First run 'gritano install'"
52
+ exit
53
+ end
54
+ end
55
+
49
56
  check_git
50
57
  if ARGV.length == 1
51
58
  if ARGV[0] =='install'
@@ -58,15 +65,17 @@ if ARGV.length == 1
58
65
  elsif ARGV.length == 2 or ARGV.length == 0
59
66
  help
60
67
  else
68
+ check_gritano
61
69
  ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(Etc.getpwuid.dir, '.gritano', 'database.yml'))))
62
70
  console = Gritano::Console.new
63
71
  console.repo_path = Etc.getpwuid.dir
64
72
  console.ssh_path = File.join(Etc.getpwuid.dir, '.ssh')
65
73
  begin
66
- if console.execute(ARGV)
67
- puts "command executed successfully"
74
+ cmd_return = console.execute(ARGV)
75
+ if cmd_return[0]
76
+ puts "success: #{cmd_return[1]}"
68
77
  else
69
- puts "an error occurred"
78
+ puts "error: #{cmd_return[1]}"
70
79
  end
71
80
  rescue NoMethodError
72
81
  puts help
@@ -10,5 +10,5 @@ end
10
10
  Then /^I should see a (success|error) message$/ do |ret|
11
11
  expected_output = true if ret == 'success'
12
12
  expected_output = false if ret == 'error'
13
- @output.should be == expected_output
13
+ @output[0].should be == expected_output
14
14
  end
data/gritano.gemspec ADDED
@@ -0,0 +1,114 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "gritano"
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Igor Bonadio"]
12
+ s.date = "2012-09-22"
13
+ s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
14
+ s.email = "igorbonadio@gmail.com"
15
+ s.executables = ["gritano", "gritano-check"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc",
19
+ "TODO"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/gritano",
31
+ "bin/gritano-check",
32
+ "db/database.yml",
33
+ "db/migrate/001_create_users.rb",
34
+ "db/migrate/002_create_repositories.rb",
35
+ "db/migrate/003_create_permissions.rb",
36
+ "db/migrate/004_create_keys.rb",
37
+ "features/command.feature",
38
+ "features/console.feature",
39
+ "features/data/keys/full_authorized_keys",
40
+ "features/data/keys/igorbonadio.pub",
41
+ "features/data/keys/igorbonadio_authorized_keys",
42
+ "features/data/keys/jessicaeto.pub",
43
+ "features/data/keys/jessicaeto_authorized_keys",
44
+ "features/keys.feature",
45
+ "features/polices.feature",
46
+ "features/step_definitions/command_step.rb",
47
+ "features/step_definitions/console_step.rb",
48
+ "features/step_definitions/keys_steps.rb",
49
+ "features/step_definitions/polices_steps.rb",
50
+ "features/support/database_cleaner.rb",
51
+ "features/support/env.rb",
52
+ "gritano.gemspec",
53
+ "lib/gritano.rb",
54
+ "lib/gritano/command.rb",
55
+ "lib/gritano/console.rb",
56
+ "lib/gritano/models.rb",
57
+ "lib/gritano/models/key.rb",
58
+ "lib/gritano/models/permission.rb",
59
+ "lib/gritano/models/repository.rb",
60
+ "lib/gritano/models/user.rb",
61
+ "spec/command_spec.rb",
62
+ "spec/console_spec.rb",
63
+ "spec/model_key_spec.rb",
64
+ "spec/model_repository_spec.rb",
65
+ "spec/model_user_spec.rb",
66
+ "spec/spec_helper.rb",
67
+ "tmp/.gitignore"
68
+ ]
69
+ s.homepage = "http://github.com/igorbonadio/gritano"
70
+ s.licenses = ["MIT"]
71
+ s.require_paths = ["lib"]
72
+ s.rubygems_version = "1.8.24"
73
+ s.summary = "Gritano is a tool to configure your git server over ssh"
74
+
75
+ if s.respond_to? :specification_version then
76
+ s.specification_version = 3
77
+
78
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
79
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
80
+ s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
81
+ s.add_runtime_dependency(%q<grit>, [">= 0"])
82
+ s.add_development_dependency(%q<rspec>, [">= 0"])
83
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
84
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
85
+ s.add_development_dependency(%q<bundler>, [">= 0"])
86
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
87
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
88
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
89
+ else
90
+ s.add_dependency(%q<activerecord>, [">= 0"])
91
+ s.add_dependency(%q<sqlite3>, [">= 0"])
92
+ s.add_dependency(%q<grit>, [">= 0"])
93
+ s.add_dependency(%q<rspec>, [">= 0"])
94
+ s.add_dependency(%q<rdoc>, [">= 0"])
95
+ s.add_dependency(%q<cucumber>, [">= 0"])
96
+ s.add_dependency(%q<bundler>, [">= 0"])
97
+ s.add_dependency(%q<jeweler>, [">= 0"])
98
+ s.add_dependency(%q<simplecov>, [">= 0"])
99
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
100
+ end
101
+ else
102
+ s.add_dependency(%q<activerecord>, [">= 0"])
103
+ s.add_dependency(%q<sqlite3>, [">= 0"])
104
+ s.add_dependency(%q<grit>, [">= 0"])
105
+ s.add_dependency(%q<rspec>, [">= 0"])
106
+ s.add_dependency(%q<rdoc>, [">= 0"])
107
+ s.add_dependency(%q<cucumber>, [">= 0"])
108
+ s.add_dependency(%q<bundler>, [">= 0"])
109
+ s.add_dependency(%q<jeweler>, [">= 0"])
110
+ s.add_dependency(%q<simplecov>, [">= 0"])
111
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
112
+ end
113
+ end
114
+
@@ -16,8 +16,8 @@ module Gritano
16
16
  def user_add(argv)
17
17
  login, = argv
18
18
  user = User.new(login: login)
19
- return true if user.save
20
- return false
19
+ return [true, "User #{login} added."] if user.save
20
+ return [false, "#{user.errors.full_messages.join(", ")}."]
21
21
  end
22
22
 
23
23
  def user_rm(argv)
@@ -25,17 +25,17 @@ module Gritano
25
25
  user = User.find_by_login(login)
26
26
  if user
27
27
  if user.destroy
28
- return true
28
+ return [true, "User #{login} removed."]
29
29
  end
30
30
  end
31
- return false
31
+ return [false, "User #{login} could not be removed."]
32
32
  end
33
33
 
34
34
  def repo_add(argv)
35
35
  name, = argv
36
36
  repo = Repository.new(name: name, path: @repo_path)
37
- return true if repo.save
38
- return false
37
+ return [true, "Repository #{name} created successfully."] if repo.save
38
+ return [false, "Repository #{name} could not be created."]
39
39
  end
40
40
 
41
41
  def repo_rm(argv)
@@ -43,10 +43,10 @@ module Gritano
43
43
  repo = Repository.find_by_name(name)
44
44
  if repo
45
45
  if repo.destroy
46
- return true
46
+ return [true, "Repository #{name} removed successfully."]
47
47
  end
48
48
  end
49
- return false
49
+ return [false, "Repository #{name} could not be removed."]
50
50
  end
51
51
 
52
52
  def repo_add_read(argv)
@@ -54,9 +54,9 @@ module Gritano
54
54
  user = User.find_by_login(login)
55
55
  repo = Repository.find_by_name(repo_name)
56
56
  if repo and user
57
- return user.add_access(repo, :read)
57
+ return [true, "User #{login} has read access to #{repo_name}."] if user.add_access(repo, :read)
58
58
  end
59
- return false
59
+ return [false, "An error occurred. Permissions was not modified."]
60
60
  end
61
61
 
62
62
  def repo_add_write(argv)
@@ -64,9 +64,9 @@ module Gritano
64
64
  user = User.find_by_login(login)
65
65
  repo = Repository.find_by_name(repo_name)
66
66
  if repo and user
67
- return user.add_access(repo, :write)
67
+ return [true, "User #{login} has write access to #{repo_name}."] if user.add_access(repo, :write)
68
68
  end
69
- return false
69
+ return [false, "An error occurred. Permissions was not modified."]
70
70
  end
71
71
 
72
72
  def repo_remove_read(argv)
@@ -74,9 +74,9 @@ module Gritano
74
74
  user = User.find_by_login(login)
75
75
  repo = Repository.find_by_name(repo_name)
76
76
  if repo and user
77
- return user.remove_access(repo, :read)
77
+ return [true, "User #{login} has not read access to #{repo_name}."] if user.remove_access(repo, :read)
78
78
  end
79
- return false
79
+ return [false, "An error occurred. Permissions was not modified."]
80
80
  end
81
81
 
82
82
  def repo_remove_write(argv)
@@ -84,9 +84,9 @@ module Gritano
84
84
  user = User.find_by_login(login)
85
85
  repo = Repository.find_by_name(repo_name)
86
86
  if repo and user
87
- return user.remove_access(repo, :write)
87
+ return [true, "User #{login} has not write access to #{repo_name}."] if user.remove_access(repo, :write)
88
88
  end
89
- return false
89
+ return [false, "An error occurred. Permissions was not modified."]
90
90
  end
91
91
 
92
92
  def user_add_key(argv)
@@ -97,11 +97,11 @@ module Gritano
97
97
  key = user.keys.create(name: key_name, key: File.open(key_file).readlines.join)
98
98
  if key.valid?
99
99
  File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
100
- return true
100
+ return [true, "Key added successfully."]
101
101
  end
102
102
  end
103
103
  end
104
- return false
104
+ return [false, "Key could not be added."]
105
105
  end
106
106
 
107
107
  def user_remove_key(argv)
@@ -110,10 +110,10 @@ module Gritano
110
110
  if key
111
111
  if key.destroy
112
112
  File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
113
- return true
113
+ return [true, "Key removed successfully."]
114
114
  end
115
115
  end
116
- return false
116
+ return [false, "Key could not be removed."]
117
117
  end
118
118
  end
119
119
  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: 0.1.2
4
+ version: 0.1.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-09-15 00:00:00.000000000 Z
12
+ date: 2012-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -213,6 +213,7 @@ files:
213
213
  - features/step_definitions/polices_steps.rb
214
214
  - features/support/database_cleaner.rb
215
215
  - features/support/env.rb
216
+ - gritano.gemspec
216
217
  - lib/gritano.rb
217
218
  - lib/gritano/command.rb
218
219
  - lib/gritano/console.rb
@@ -244,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
245
  version: '0'
245
246
  segments:
246
247
  - 0
247
- hash: 3868573402934525831
248
+ hash: 4053165706733328578
248
249
  required_rubygems_version: !ruby/object:Gem::Requirement
249
250
  none: false
250
251
  requirements: