yorobot 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff39fbdd396b74922570f25786f43d20133b2a20
4
- data.tar.gz: 8620855698674cb3096cb0e2b1e2efdaec7aa9d3
3
+ metadata.gz: 503913587cfe3eb47d27dfbea06bbc851f672e3d
4
+ data.tar.gz: 2ea249106e91274f5d93cc5ea86bf70846f96fca
5
5
  SHA512:
6
- metadata.gz: 99d9ae051dcc691573b571d5927ce0081f1700266e98ce47a51949c8609e8ec86c72be0a1748c4d04f4fe7731d648a457669da98b29d2315d3298e98b4cd2dba
7
- data.tar.gz: 1f8f29ac8e02cc3e207136aa7567fb5e98761b22ab548006a4eb8f69095dbb025e1c4cfe95f7ab900fdb8b869bef6a6fd61785aa178275d68f2ad4fcf508c29f
6
+ metadata.gz: 3e3754ff5eff7bce1d987423fe28ec8641c9a8d7cf6624338b548457750d01e89892cde5ab20883ad5e783dfacda6172e970c319c9a48913f31682cbdad272b9
7
+ data.tar.gz: 7fc891e0e027c9b14b1af691728558a22a5fd88ddbcd88d4c1891a67616863beab897a31c9c2d6ebc24877bd01378fcce2892c69651146005eca59302cb7b602
@@ -7,6 +7,7 @@ bin/yorobot
7
7
  lib/yorobot.rb
8
8
  lib/yorobot/base.rb
9
9
  lib/yorobot/echo.rb
10
- lib/yorobot/github.rb
10
+ lib/yorobot/github/git.rb
11
+ lib/yorobot/github/github.rb
11
12
  lib/yorobot/list.rb
12
13
  lib/yorobot/version.rb
@@ -13,7 +13,8 @@ require 'yorobot/base'
13
13
  require 'yorobot/echo'
14
14
  require 'yorobot/list'
15
15
 
16
- require 'yorobot/github'
16
+ require 'yorobot/github/git'
17
+ require 'yorobot/github/github'
17
18
 
18
19
 
19
20
 
@@ -3,19 +3,22 @@ module Yorobot
3
3
 
4
4
  class Step
5
5
 
6
+ def self.option_defs
7
+ @option_defs ||= {}
8
+ end
9
+
10
+ def self.option( key, *args )
11
+ option_defs[ key ] = args
12
+ end
13
+
6
14
 
7
15
 
8
16
  def options
9
17
  @options ||= {}
10
18
  end
11
19
 
12
- def on_parse_options( parser ) ## todo/check: find a better name?
13
- ## do nothing; overwrite
14
- end
15
-
16
-
17
20
  def parse!( args )
18
- ### cache option parser - why? why not?
21
+ ### todo/check - cache option parser!!!! - why? why not?
19
22
  OptionParser.new do |parser|
20
23
  ## add default banner - overwrite if needed/to customize
21
24
  parser.banner = <<TXT
@@ -24,13 +27,16 @@ Usage: #{name} [OPTIONS] ARGUMENTS
24
27
 
25
28
  TXT
26
29
 
27
- on_parse_options( parser )
30
+ self.class.option_defs.each do | key, on_args|
31
+ parser.on( *on_args ) do |value|
32
+ options[ key ] = value
33
+ end
34
+ end
28
35
  end.parse!( args )
29
36
  end
30
37
 
31
38
 
32
39
 
33
-
34
40
  def self.run( args=[] )
35
41
  step = new
36
42
 
@@ -45,9 +51,6 @@ def self.run( args=[] )
45
51
  puts " #{[i]} >#{arg}<"
46
52
  end
47
53
 
48
- #
49
-
50
-
51
54
 
52
55
  if args.size > 0
53
56
  ## todo/check: check/verify arity of run - why? why not?
@@ -0,0 +1,98 @@
1
+ module Yorobot
2
+
3
+
4
+ class Setup < Step
5
+
6
+ =begin
7
+ # check ssh
8
+ if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi
9
+ echo "$SSH_KEY" > ~/.ssh/id_rsa
10
+ chmod 600 ~/.ssh/id_rsa
11
+ echo "ssh directory - ~/.ssh:"
12
+ ls -la ~/.ssh
13
+
14
+ # check git
15
+ git --version
16
+ git config --global user.name "Yo Robot"
17
+ git config --global user.email "gerald.bauer+yorobot@gmail.com"
18
+ git config -l --show-origin
19
+ =end
20
+
21
+ def call
22
+ ##############
23
+ ## setup ssh
24
+ Dir.mkdir( '~/.ssh' ) unless Dir.exist?( '~/.ssh' )
25
+ ssh_key = ENV['SSH_KEY']
26
+ if ssh_key.nil?
27
+ STDERR.puts "!! ERROR - required SSH_KEY env(ironment) variable missing"
28
+ exit 1
29
+ end
30
+ if File.exist?( '~/.ssh/id_rsa' )
31
+ STDERR.puts "!! ERROR - ssh key >~/.ssh/id_rsa< already exists"
32
+ exit 1
33
+ end
34
+ File.open( '~/.ssh/id_rsa', 'w:utf-8' ) do |f|
35
+ f.write( ssh_key )
36
+ end
37
+ ## note: ssh key must be "private" only access by owner (otherwise) WILL NOT work
38
+ res = File.chmod( 0600, '~/.ssh/id_rsa' )
39
+ puts res ## returns number of files processed; should be 1 - assert - why? why not?
40
+
41
+ Computer::Shell.run( %Q{ls -la ~/.ssh} )
42
+
43
+
44
+ #####
45
+ ## setup git
46
+ ## git --version
47
+ Git.version
48
+
49
+ user_name = ENV['YOROBOT_NAME'] || ENV['YO_NAME']
50
+ user_email = ENV['YOROBOT_EMAIL'] || ENV['YO_EMAIL']
51
+
52
+ Computer::Shell.run( %Q{git config --global user.name "#{user_name}"} )
53
+ Computer::Shell.run( %Q{git config --global user.email "#{user_email}"} )
54
+
55
+ Computer::Shell.run( %Q{git config -l --show-origin} )
56
+ end
57
+ end # class Setup
58
+
59
+
60
+
61
+ class Clone < Step ## change to SshClone(r) or such - why? why not?
62
+ option :depth, "--depth DEPTH", Integer, "shallow clone depth"
63
+
64
+ def call( *repos )
65
+ repos.each do |repo|
66
+ if options[:depth]
67
+ ### shallow "fast clone" - support libraries
68
+ ### use https:// instead of ssh - why? why not?
69
+ Git.clone( "git@github.com:#{repo}.git", depth: options[:depth] )
70
+ else
71
+ ### "deep" standard/ regular clone
72
+ Git.clone( "git@github.com:#{repo}.git" )
73
+ end
74
+ end
75
+ end
76
+ end # class Clone
77
+
78
+
79
+
80
+ class Push < Step ## change to SshPush(r) or such - why? why not?
81
+
82
+ def call( *paths ) ## e.g. "./cache.github" etc.
83
+ msg = "auto-update week #{Date.today.cweek}"
84
+
85
+ paths.each do |path|
86
+ GitProject.open( path ) do |proj|
87
+ if proj.changes?
88
+ proj.add( "." )
89
+ proj.commit( msg )
90
+ proj.push
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end # class Push
96
+
97
+
98
+ end # module Yorobot
@@ -0,0 +1,30 @@
1
+ module Yorobot
2
+
3
+ class Github < Step ## change to GithubStats or such - why? why not?
4
+
5
+ ## todo/check: use --data-dir/--datadir - why? why not?
6
+ option :data_dir, "-d DIR", "--dir DIR",
7
+ "data dir (defaults to #{Hubba.config.data_dir})"
8
+
9
+ ## todo/check: add switch --[no]-traffic - why? why not?
10
+
11
+
12
+ def call( username )
13
+ ## username e.g. geraldb
14
+
15
+ if options[:data_dir] ## e.g. "./cache.github"
16
+ puts " setting data_dir to >#{options[:data_dir]}<"
17
+ Hubba.config.data_dir = options[:data_dir]
18
+ end
19
+
20
+ h = Hubba.reposet( username ) ## note: do NOT include yorobot for now
21
+ pp h
22
+
23
+ Hubba.update_stats( h )
24
+ Hubba.update_traffic( h )
25
+ puts "Done."
26
+ end
27
+
28
+ end # class Github
29
+ end # module Yorobot
30
+
@@ -5,8 +5,8 @@
5
5
 
6
6
  module YorobotCore ## todo/check: rename GittiBase or GittiMeta or such - why? why not?
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 1
9
- PATCH = 1
8
+ MINOR = 2
9
+ PATCH = 0
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yorobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitti
@@ -93,7 +93,8 @@ files:
93
93
  - lib/yorobot.rb
94
94
  - lib/yorobot/base.rb
95
95
  - lib/yorobot/echo.rb
96
- - lib/yorobot/github.rb
96
+ - lib/yorobot/github/git.rb
97
+ - lib/yorobot/github/github.rb
97
98
  - lib/yorobot/list.rb
98
99
  - lib/yorobot/version.rb
99
100
  homepage: https://github.com/rubycoco/git
@@ -1,40 +0,0 @@
1
- module Yorobot
2
-
3
-
4
-
5
- class Github < Step ## change to GithubStats or such - why? why not?
6
-
7
-
8
- def on_parse_options( parser )
9
- ## todo/check: use --data-dir/--datadir - why? why not?
10
- parser.on( "-d DIR",
11
- "--dir DIR",
12
- "data dir (defaults to #{Hubba.config.data_dir}",
13
- ) do |data_dir|
14
- options[:data_dir] = data_dir
15
- end
16
-
17
- ## add switch --[no]-traffic - why? why not?
18
- end
19
-
20
-
21
- def call( username )
22
- ## username e.g. geraldb
23
-
24
- if @options[:data_dir] ## e.g. "./cache.github"
25
- puts " setting data_dir to >#{@options[:data_dir]}<"
26
- Hubba.config.data_dir = @options[:data_dir]
27
- end
28
-
29
- h = Hubba.reposet( username ) ## note: do NOT include yorobot for now
30
- pp h
31
-
32
- Hubba.update_stats( h )
33
- Hubba.update_traffic( h )
34
- puts "Done."
35
- end
36
-
37
- end # class Github
38
-
39
- end # module Yorobot
40
-