yorobot 0.1.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2252541ead5305b3472d0f371e1040461290ad82
4
- data.tar.gz: f13e3073fdbcdae51a68c294d3edb3ee5b64e518
3
+ metadata.gz: 2e9d56ead6d7473f8ad0d0677bf7008343b8b240
4
+ data.tar.gz: edfb052a9634b6644439118e7866e259276ba4ec
5
5
  SHA512:
6
- metadata.gz: 6310b01adc581ad48a71b93e86c5b76525417a4cc1392787f310db7ba52ee1c92f0e85a5fba176c8285def710fe2d9c42a25cafec59b7d89d429de4c2c8126ba
7
- data.tar.gz: 43866b4d8e30d64dfa9c232569c46a44dcb0466cfcb32bd70b7898754111f9fd3c3f4217d753d17e4ed64395b0eaeaa8eb92fd8394a0d20c9da36481d6836229
6
+ metadata.gz: f2db7acdf2aa0c7630e02514fe407f952c946b155e48342774a76138a19c90617a2e9425a193da40f357388eb5929d62a4eaaf5c2765308d75b069ef3b8991eb
7
+ data.tar.gz: b3964edb4092a54e3e4391fdc4c4e3a4e27a737681ada66bd214d6005d3968cee2cf8fb42978cc28b7f6abc40c4caa5c11706ac142b0716bb0457e1a9feb03b6
@@ -5,7 +5,8 @@ Rakefile
5
5
  bin/yo
6
6
  bin/yorobot
7
7
  lib/yorobot.rb
8
- lib/yorobot/base.rb
9
8
  lib/yorobot/echo.rb
9
+ lib/yorobot/github/git.rb
10
+ lib/yorobot/github/github.rb
10
11
  lib/yorobot/list.rb
11
12
  lib/yorobot/version.rb
data/Rakefile CHANGED
@@ -18,7 +18,9 @@ Hoe.spec 'yorobot' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['gitti', '>= 0.5.0' ],
21
+ ['commands-lite', '>= 0.1.0'],
22
+ ['gitti', '>= 0.5.0'],
23
+ ['hubba', '>= 1.0.0'],
22
24
  ]
23
25
 
24
26
  self.licenses = ['Public Domain']
@@ -1,34 +1,39 @@
1
- #####
2
- # say hello
3
- require 'yorobot/version' # note: let version always go first
4
- puts YorobotCore.banner
5
-
6
-
7
-
8
1
  ####
9
2
  # 3rd party gems / libs
10
3
  #
11
- # require 'yorobot/shell' # add shell run/call etc. machinery
12
- # add via gitti
4
+ # require 'computer' # add shell run/call etc. machinery
5
+ # add via gitti & hubba
6
+ require 'commands-lite'
13
7
  require 'gitti'
8
+ require 'hubba'
14
9
 
15
10
 
16
11
  # our own code
17
- require 'yorobot/base'
12
+ require 'yorobot/version' # note: let version always go first
18
13
  require 'yorobot/echo'
19
14
  require 'yorobot/list'
20
15
 
16
+ require 'yorobot/github/git'
17
+ require 'yorobot/github/github'
18
+
19
+
21
20
 
22
21
  module Yorobot
22
+ def self.run( args ) Commands.run( args ); end
23
+ def self.list() List.run; end
24
+
25
+
23
26
  class Tool
24
27
  def self.main( args=ARGV )
25
28
  if args.size > 0
26
29
  Yorobot.run( args )
27
30
  else
28
- # list all known steps
29
- List.run
31
+ # list all known commands
32
+ Yorobot.list
30
33
  end
31
34
  end
32
35
  end # class Tool
33
36
  end # module Yorobot
34
37
 
38
+
39
+ puts YorobotCore.banner # say hello
@@ -1,12 +1,9 @@
1
1
  module Yorobot
2
2
 
3
-
4
- class Echo < Step
5
-
6
- def call( args )
3
+ class Echo < Command
4
+ def call( *args )
7
5
  puts args.join( ' ' )
8
6
  end
9
-
10
7
  end # class Echo
11
8
 
12
9
  end # module Yorobot
@@ -0,0 +1,109 @@
1
+ module Yorobot
2
+
3
+
4
+ class Setup < Command
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
+ # ssh -vT git@github.com
14
+
15
+ # check git
16
+ git --version
17
+ git config --global user.name "Yo Robot"
18
+ git config --global user.email "gerald.bauer+yorobot@gmail.com"
19
+ git config -l --show-origin
20
+ =end
21
+
22
+ def call
23
+ ##############
24
+ ## setup ssh
25
+
26
+ ssh_key = ENV['SSH_KEY']
27
+
28
+ if ssh_key.nil?
29
+ STDERR.puts "!! ERROR - required SSH_KEY env(ironment) variable missing"
30
+ exit 1
31
+ end
32
+
33
+ ssh_path = File.expand_path( '~/.ssh' )
34
+
35
+ if File.exist?( "#{ssh_path}/id_rsa" )
36
+ STDERR.puts "!! ERROR - ssh key >#{ssh_path}/id_rsa< already exists"
37
+ exit 1
38
+ end
39
+
40
+ ## make sure path exists
41
+ FileUtils.mkdir_p( ssh_path ) unless Dir.exist?( ssh_path )
42
+ puts "--> writing ssh key to >#{ssh_path}/id_rsa<..."
43
+ File.open( "#{ssh_path}/id_rsa", 'w:utf-8' ) do |f|
44
+ f.write( ssh_key )
45
+ end
46
+ ## note: ssh key must be "private" only access by owner (otherwise) WILL NOT work
47
+ ## res = File.chmod( 0600, "#{ssh_path}/id_rsa" )
48
+ ## puts res ## returns number of files processed; should be 1 - assert - why? why not?
49
+ Computer::Shell.run( %Q{chmod 600 #{ssh_path}/id_rsa} )
50
+
51
+ Computer::Shell.run( %Q{ls -la #{ssh_path}} )
52
+ # ssh -vT git@github.com
53
+
54
+
55
+ #####
56
+ ## setup git
57
+ ## git --version
58
+ Git.version
59
+
60
+ user_name = ENV['YOROBOT_NAME'] || ENV['YO_NAME']
61
+ user_email = ENV['YOROBOT_EMAIL'] || ENV['YO_EMAIL']
62
+
63
+ Computer::Shell.run( %Q{git config --global user.name "#{user_name}"} )
64
+ Computer::Shell.run( %Q{git config --global user.email "#{user_email}"} )
65
+
66
+ Computer::Shell.run( %Q{git config -l --show-origin} )
67
+ end
68
+ end # class Setup
69
+
70
+
71
+
72
+ class Clone < Command ## change to SshClone(r) or such - why? why not?
73
+ option :depth, "--depth DEPTH", Integer, "shallow clone depth"
74
+
75
+ def call( *repos )
76
+ repos.each do |repo|
77
+ if options[:depth]
78
+ ### shallow "fast clone" - support libraries
79
+ ### use https:// instead of ssh - why? why not?
80
+ Git.clone( "git@github.com:#{repo}.git", depth: options[:depth] )
81
+ else
82
+ ### "deep" standard/ regular clone
83
+ Git.clone( "git@github.com:#{repo}.git" )
84
+ end
85
+ end
86
+ end
87
+ end # class Clone
88
+
89
+
90
+
91
+ class Push < Command ## change to SshPush(r) or such - why? why not?
92
+
93
+ def call( *paths ) ## e.g. "./cache.github" etc.
94
+ msg = "auto-update week #{Date.today.cweek}"
95
+
96
+ paths.each do |path|
97
+ GitProject.open( path ) do |proj|
98
+ if proj.changes?
99
+ proj.add( "." )
100
+ proj.commit( msg )
101
+ proj.push
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end # class Push
107
+
108
+
109
+ end # module Yorobot
@@ -0,0 +1,30 @@
1
+ module Yorobot
2
+
3
+ class Github < Command ## 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
+
@@ -1,14 +1,14 @@
1
1
  module Yorobot
2
2
 
3
-
4
- class List < Step
5
-
6
- def call( args )
7
- ## list all know steps
8
- steps = Yorobot.steps
9
- puts "#{steps.size} step(s):"
10
- steps.each do |name, step|
11
- puts " #{name} | #{step.class.name}"
3
+ class List < Command
4
+ def call
5
+ ## list all known commands
6
+ commands = Commands.commands
7
+ puts "#{commands.size} command(s):"
8
+ commands.each do |name, command|
9
+ print " %-10s" % name
10
+ print " | #{command.class.name} (#{command.name})"
11
+ print "\n"
12
12
  end
13
13
  end
14
14
  end
@@ -16,10 +16,4 @@ end
16
16
  end # module Yorobot
17
17
 
18
18
 
19
- #####
20
- #
21
- #
22
- # -- add "shortcut why? why not?"
23
- # step [:list, :ls] do |args|
24
- # ....
25
- # end
19
+
@@ -5,7 +5,7 @@
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
8
+ MINOR = 3
9
9
  PATCH = 0
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
@@ -18,7 +18,7 @@ module YorobotCore ## todo/check: rename GittiBase or GittiMeta or such - why
18
18
  end
19
19
 
20
20
  def self.root
21
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
22
22
  end
23
23
  end # module YorobotCore
24
24
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yorobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.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-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commands-lite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: gitti
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: hubba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rdoc
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -77,8 +105,9 @@ files:
77
105
  - bin/yo
78
106
  - bin/yorobot
79
107
  - lib/yorobot.rb
80
- - lib/yorobot/base.rb
81
108
  - lib/yorobot/echo.rb
109
+ - lib/yorobot/github/git.rb
110
+ - lib/yorobot/github/github.rb
82
111
  - lib/yorobot/list.rb
83
112
  - lib/yorobot/version.rb
84
113
  homepage: https://github.com/rubycoco/git
@@ -1,63 +0,0 @@
1
- module Yorobot
2
-
3
-
4
- class Step
5
-
6
- def self.run( args=[] )
7
- step = new
8
- puts "--> (#{step.name}) #{args.join('·')}"
9
-
10
- step.call( args ) ## use run - why? why not?
11
- end
12
-
13
- def self.step_name
14
- ## note: cut-off leading Yorobot:: for now in class name!!!
15
- ## note: do NOT use @@name!!! - one instance variable per class needed!!
16
- @name ||= self.name.downcase.sub( /^yorobot::/, '' )
17
- @name
18
- end
19
-
20
- def name() self.class.step_name; end
21
-
22
-
23
-
24
-
25
-
26
- def self.inherited( klass )
27
- # puts klass.class.name #=> Class
28
- ## auto-register steps for now - why? why not?
29
- Yorobot.register( klass )
30
- end
31
-
32
- end # class Step
33
-
34
-
35
-
36
- def self.steps ## todo/check: change to registry or such - why? why not?
37
- @@register ||= {}
38
- end
39
-
40
- def self.register( klass )
41
- raise ArgumentError, "class MUST be a Yorobot::Step" unless klass.ancestors.include?( Step )
42
-
43
- h = steps
44
- h[ klass.step_name] = klass
45
- h
46
- end
47
-
48
-
49
- def self.run( args=[] )
50
- step_name = args.shift
51
-
52
- step = steps[ step_name ]
53
- if step.nil?
54
- puts "!! ERROR: no step definition found for >#{step_name}<; known steps include:"
55
- List.run
56
- exit 1
57
- end
58
- step.run( args )
59
- end
60
-
61
-
62
-
63
- end # module Yorobot