gritano 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -1,14 +1,2 @@
1
- v0.9.1:
2
- ✔ mostrar admin -> gritano user:admin igorbonadio @done (13-03-25 21:28)
3
- ✔ mostrar admin no user:list @done (13-03-25 21:28)
4
-
5
- v0.9.2:
6
- ✔ permitir ao usuario mudar seu email @done (13-03-27 16:30)
7
- ✔ arrumar specs @done (13-03-25 22:08)
8
- ✔ travis-ci @done (13-03-26 12:12)
9
-
10
1
  v0.10.0:
11
- recuperação de senha via email
12
-
13
- v1.0.0:
14
- ☐ refatorar e preparar para o lançamento oficial!!!!
2
+ recuperar e adicionar pub.keys
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
data/gritano.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gritano"
8
- s.version = "0.9.2"
8
+ s.version = "0.9.3"
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"]
12
- s.date = "2013-03-27"
12
+ s.date = "2013-04-02"
13
13
  s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
14
14
  s.email = "igorbonadio@gmail.com"
15
15
  s.executables = ["gritano", "gritano-pub-key", "gritano-remote"]
@@ -236,6 +236,7 @@ Gem::Specification.new do |s|
236
236
  "gritano.gemspec",
237
237
  "lib/gritano.rb",
238
238
  "lib/gritano/cli.rb",
239
+ "lib/gritano/config.rb",
239
240
  "lib/gritano/console.rb",
240
241
  "lib/gritano/console/base.rb",
241
242
  "lib/gritano/console/executor.rb",
@@ -250,6 +251,7 @@ Gem::Specification.new do |s|
250
251
  "lib/gritano/plugin.rb",
251
252
  "lib/gritano/plugin/ssh.rb",
252
253
  "spec/cli_spec.rb",
254
+ "spec/config_spec.rb",
253
255
  "spec/console_base_spec.rb",
254
256
  "spec/console_executor_spec.rb",
255
257
  "spec/console_gritano_spec.rb",
@@ -257,7 +259,6 @@ Gem::Specification.new do |s|
257
259
  "spec/console_remote_spec.rb",
258
260
  "spec/console_spec.rb",
259
261
  "spec/data/help_command_name.txt",
260
- "spec/model_config_spec.rb",
261
262
  "spec/model_key_spec.rb",
262
263
  "spec/model_permission_spec.rb",
263
264
  "spec/model_repository_spec.rb",
data/lib/gritano.rb CHANGED
@@ -5,4 +5,5 @@ require "fileutils"
5
5
  require File.join(ROOT_PATH, '/gritano/models')
6
6
  require File.join(ROOT_PATH, '/gritano/console')
7
7
  require File.join(ROOT_PATH, '/gritano/cli')
8
- require File.join(ROOT_PATH, '/gritano/plugin')
8
+ require File.join(ROOT_PATH, '/gritano/plugin')
9
+ require File.join(ROOT_PATH, '/gritano/config')
@@ -0,0 +1,36 @@
1
+ module Gritano
2
+ class Config
3
+ def initialize(config_file)
4
+ @config_file = config_file
5
+ load
6
+ end
7
+
8
+ def load
9
+ unless File.exist?(@config_file)
10
+ File.open(@config_file, "w").close
11
+ end
12
+ @config = YAML::load(File.open(@config_file))
13
+ unless @config
14
+ @config = Hash.new
15
+ end
16
+ end
17
+
18
+ def remove(parameter)
19
+ @config.delete(parameter.to_s)
20
+ end
21
+
22
+ def save
23
+ File.open(@config_file, "w") do |f|
24
+ f.write(@config.to_yaml)
25
+ end
26
+ end
27
+
28
+ def method_missing(name, *args, &block)
29
+ if name[-1] == '='
30
+ @config[name.to_s[0..-2]] = args[0]
31
+ else
32
+ @config[name.to_s]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -8,14 +8,18 @@ module Gritano
8
8
  end
9
9
 
10
10
  def on_add
11
- File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => true}.to_yaml)
11
+ config = Config.new(File.join(@home_dir, '.gritano', 'config.yml'))
12
+ config.ssh = true
13
+ config.save
12
14
  File.open(File.join(@ssh_path, 'authorized_keys'), "w").write('')
13
15
  gritano_pub_key_path = `which gritano-pub-key`[0..-2]
14
16
  `ln -s #{gritano_pub_key_path} #{File.join(@home_dir, '.gritano', 'gritano-pub-key')}`
15
17
  end
16
18
 
17
19
  def on_remove
18
- File.open(File.join(@home_dir, '.gritano', 'config.yml'), "w").write({'ssh' => false}.to_yaml)
20
+ config = Config.new(File.join(@home_dir, '.gritano', 'config.yml'))
21
+ config.ssh = false
22
+ config.save
19
23
  File.open(File.join(@ssh_path, 'authorized_keys'), 'w').write(Key.authorized_keys)
20
24
  FileUtils.rm(File.join(@home_dir, '.gritano', 'gritano-pub-key')) if File.exist?(File.join(@home_dir, '.gritano', 'gritano-pub-key'))
21
25
  end
@@ -23,10 +27,14 @@ module Gritano
23
27
  def self.check_install
24
28
  home = Etc.getpwuid.dir
25
29
  if File.exist?(File.join(home, '.gritano', 'config.yml'))
26
- config = YAML::load(File.open(File.join(home, '.gritano', 'config.yml')))
27
- return config['ssh']
30
+ config = Config.new(File.join(home, '.gritano', 'config.yml'))
31
+ if config.ssh
32
+ return config.ssh
33
+ else
34
+ return false
35
+ end
28
36
  else
29
- return false
37
+ return false
30
38
  end
31
39
  end
32
40
 
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module Gritano
4
+ describe Config do
5
+ it "should get parameters" do
6
+ config = Config.new(File.join(".gritano", "config.yml"))
7
+ config.ssh.should be == false
8
+ end
9
+
10
+ it "should add parameters" do
11
+ FileUtils.mkdir_p('tmp')
12
+ if File.exist?(File.join("tmp", "config_test.yml"))
13
+ FileUtils.rm(File.join("tmp", "config_test.yml"))
14
+ end
15
+ config = Config.new(File.join("tmp", "config_test.yml"))
16
+ config.ssh.should be == nil
17
+ config.ssh = true
18
+ config.ssh.should be == true
19
+ end
20
+
21
+ it "should remove parameters" do
22
+ FileUtils.mkdir_p('tmp')
23
+ if File.exist?(File.join("tmp", "config_test.yml"))
24
+ FileUtils.rm(File.join("tmp", "config_test.yml"))
25
+ end
26
+ config = Config.new(File.join("tmp", "config_test.yml"))
27
+
28
+ config.ssh = true
29
+ config.ssh.should be == true
30
+
31
+ config.remove(:ssh)
32
+ config.ssh.should be == nil
33
+ end
34
+
35
+ it "should modify parameters" do
36
+ FileUtils.mkdir_p('tmp')
37
+ if File.exist?(File.join("tmp", "config_test.yml"))
38
+ FileUtils.rm(File.join("tmp", "config_test.yml"))
39
+ end
40
+ config = Config.new(File.join("tmp", "config_test.yml"))
41
+ config.ssh.should be == nil
42
+ config.ssh = true
43
+ config.ssh.should be == true
44
+ config.ssh = false
45
+ config.ssh.should be == false
46
+ end
47
+
48
+ it "should save a config file" do
49
+ FileUtils.mkdir_p('tmp')
50
+ if File.exist?(File.join("tmp", "config_test.yml"))
51
+ FileUtils.rm(File.join("tmp", "config_test.yml"))
52
+ end
53
+ config = Config.new(File.join("tmp", "config_test.yml"))
54
+ config.ssh = true
55
+ config.email = {login: 'igor', smtp: 'smtp.igor.com'}
56
+ config.save
57
+
58
+ config2 = Config.new(File.join("tmp", "config_test.yml"))
59
+ config2.ssh.should be == true
60
+ config2.email[:login].should be == "igor"
61
+ config2.email[:smtp].should be == "smtp.igor.com"
62
+ end
63
+ end
64
+ 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.9.2
4
+ version: 0.9.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: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -433,6 +433,7 @@ files:
433
433
  - gritano.gemspec
434
434
  - lib/gritano.rb
435
435
  - lib/gritano/cli.rb
436
+ - lib/gritano/config.rb
436
437
  - lib/gritano/console.rb
437
438
  - lib/gritano/console/base.rb
438
439
  - lib/gritano/console/executor.rb
@@ -447,6 +448,7 @@ files:
447
448
  - lib/gritano/plugin.rb
448
449
  - lib/gritano/plugin/ssh.rb
449
450
  - spec/cli_spec.rb
451
+ - spec/config_spec.rb
450
452
  - spec/console_base_spec.rb
451
453
  - spec/console_executor_spec.rb
452
454
  - spec/console_gritano_spec.rb
@@ -454,7 +456,6 @@ files:
454
456
  - spec/console_remote_spec.rb
455
457
  - spec/console_spec.rb
456
458
  - spec/data/help_command_name.txt
457
- - spec/model_config_spec.rb
458
459
  - spec/model_key_spec.rb
459
460
  - spec/model_permission_spec.rb
460
461
  - spec/model_repository_spec.rb
@@ -478,7 +479,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
478
479
  version: '0'
479
480
  segments:
480
481
  - 0
481
- hash: 3682968172895747783
482
+ hash: 2612279300761584941
482
483
  required_rubygems_version: !ruby/object:Gem::Requirement
483
484
  none: false
484
485
  requirements:
@@ -1,10 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module Gritano
4
- describe "Config" do
5
- it "should have a ssh configuration" do
6
- config = YAML::load(File.open(File.join('.gritano', 'config.yml')))
7
- config['ssh'].should be_false
8
- end
9
- end
10
- end