yorobot 0.2.0 → 1.0.1

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: 503913587cfe3eb47d27dfbea06bbc851f672e3d
4
- data.tar.gz: 2ea249106e91274f5d93cc5ea86bf70846f96fca
3
+ metadata.gz: 3d0b68e2fa622f386f77265d661601408d63372c
4
+ data.tar.gz: 9458fff448ed8c13ca42ef41b2bf08f1b7b81f3c
5
5
  SHA512:
6
- metadata.gz: 3e3754ff5eff7bce1d987423fe28ec8641c9a8d7cf6624338b548457750d01e89892cde5ab20883ad5e783dfacda6172e970c319c9a48913f31682cbdad272b9
7
- data.tar.gz: 7fc891e0e027c9b14b1af691728558a22a5fd88ddbcd88d4c1891a67616863beab897a31c9c2d6ebc24877bd01378fcce2892c69651146005eca59302cb7b602
6
+ metadata.gz: 21fe561989ef2734338e7df4e261104d9e7a43c35a23e00065a45f95e4c2b2d00317b942c4cae6dbaa342dd26339eb4d5758cc1beeb6cdd1aaa7a7bbb2238209
7
+ data.tar.gz: bf4a93aceb011f00a0be6f8f0482abf0563e9aec5bbdd7f77a498e639efdbf965d74239321fb47904f09f51f68b0830ac971f0c0dc9d13f11b24f49fe5653b5d
@@ -5,9 +5,4 @@ Rakefile
5
5
  bin/yo
6
6
  bin/yorobot
7
7
  lib/yorobot.rb
8
- lib/yorobot/base.rb
9
- lib/yorobot/echo.rb
10
- lib/yorobot/github/git.rb
11
- lib/yorobot/github/github.rb
12
- lib/yorobot/list.rb
13
8
  lib/yorobot/version.rb
data/Rakefile CHANGED
@@ -18,8 +18,10 @@ Hoe.spec 'yorobot' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['gitti', '>= 0.5.0' ],
22
- ['hubba', '>= 1.0.0' ],
21
+ ['flow-lite', '>= 1.0.0'],
22
+ ['gitti', '>= 0.6.1'],
23
+ ['hubba', '>= 1.0.0'],
24
+ ['monos', '>= 1.0.0'],
23
25
  ]
24
26
 
25
27
  self.licenses = ['Public Domain']
@@ -1,34 +1,97 @@
1
+ require 'flow-lite'
2
+
3
+
1
4
  ####
2
- # 3rd party gems / libs
5
+ # add more 3rd party gems / libs to flow "prologue / prelude"
3
6
  #
4
7
  # require 'computer' # add shell run/call etc. machinery
5
8
  # add via gitti & hubba
6
9
  require 'gitti'
7
10
  require 'hubba'
11
+ require 'mono'
8
12
 
9
13
 
10
14
  # our own code
11
15
  require 'yorobot/version' # note: let version always go first
12
- require 'yorobot/base'
13
- require 'yorobot/echo'
14
- require 'yorobot/list'
15
16
 
16
- require 'yorobot/github/git'
17
- require 'yorobot/github/github'
18
17
 
19
18
 
19
+ #### add predefined steps
20
+ module Flow
21
+ class Base
20
22
 
21
- module Yorobot
22
- class Tool
23
- def self.main( args=ARGV )
24
- if args.size > 0
25
- Yorobot.run( args )
26
- else
27
- # list all known steps
28
- List.run
29
- end
23
+ =begin
24
+ # check ssh
25
+ if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi
26
+ echo "$SSH_KEY" > ~/.ssh/id_rsa
27
+ chmod 600 ~/.ssh/id_rsa
28
+ echo "ssh directory - ~/.ssh:"
29
+ ls -la ~/.ssh
30
+ # ssh -vT git@github.com
31
+
32
+ # check git
33
+ git --version
34
+ git config --global user.name "Yo Robot"
35
+ git config --global user.email "gerald.bauer+yorobot@gmail.com"
36
+ git config -l --show-origin
37
+ =end
38
+ def setup
39
+ ##############
40
+ ## setup ssh
41
+
42
+ ssh_key = ENV['SSH_KEY']
43
+
44
+ if ssh_key.nil?
45
+ STDERR.puts "!! ERROR - required SSH_KEY env(ironment) variable missing"
46
+ exit 1
30
47
  end
31
- end # class Tool
48
+
49
+ ssh_path = File.expand_path( '~/.ssh' )
50
+
51
+ if File.exist?( "#{ssh_path}/id_rsa" )
52
+ STDERR.puts "!! ERROR - ssh key >#{ssh_path}/id_rsa< already exists"
53
+ exit 1
54
+ end
55
+
56
+ ## make sure path exists
57
+ FileUtils.mkdir_p( ssh_path ) unless Dir.exist?( ssh_path )
58
+ puts "--> writing ssh key to >#{ssh_path}/id_rsa<..."
59
+ File.open( "#{ssh_path}/id_rsa", 'w:utf-8' ) do |f|
60
+ f.write( ssh_key )
61
+ end
62
+ ## note: ssh key must be "private" only access by owner (otherwise) WILL NOT work
63
+ ## res = File.chmod( 0600, "#{ssh_path}/id_rsa" )
64
+ ## puts res ## returns number of files processed; should be 1 - assert - why? why not?
65
+ Computer::Shell.run( %Q{chmod 600 #{ssh_path}/id_rsa} )
66
+
67
+ Computer::Shell.run( %Q{ls -la #{ssh_path}} )
68
+ # ssh -vT git@github.com
69
+
70
+
71
+ #####
72
+ ## setup git
73
+ ## git --version
74
+ Git.version
75
+
76
+ user_name = ENV['YOROBOT_NAME'] || ENV['YO_NAME'] || 'Yo Robot'
77
+ user_email = ENV['YOROBOT_EMAIL'] || ENV['YO_EMAIL'] || 'gerald.bauer+yorobot@gmail.com'
78
+
79
+ Computer::Shell.run( %Q{git config --global user.name "#{user_name}"} )
80
+ Computer::Shell.run( %Q{git config --global user.email "#{user_email}"} )
81
+
82
+ Computer::Shell.run( %Q{git config -l --show-origin} )
83
+ end
84
+ alias_method :step_setup, :setup
85
+
86
+ end # class Base
87
+ end # module Flow
88
+
89
+
90
+
91
+
92
+
93
+ module Yorobot
94
+ Tool = ::Flow::Tool
32
95
  end # module Yorobot
33
96
 
34
97
 
@@ -4,9 +4,9 @@
4
4
 
5
5
 
6
6
  module YorobotCore ## todo/check: rename GittiBase or GittiMeta or such - why? why not?
7
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 2
9
- PATCH = 0
7
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
8
+ MINOR = 0
9
+ PATCH = 1
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yorobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.1
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-21 00:00:00.000000000 Z
11
+ date: 2020-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: flow-lite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: gitti
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: 0.5.0
33
+ version: 0.6.1
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 0.5.0
40
+ version: 0.6.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: hubba
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: monos
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rdoc
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -91,11 +119,6 @@ files:
91
119
  - bin/yo
92
120
  - bin/yorobot
93
121
  - lib/yorobot.rb
94
- - lib/yorobot/base.rb
95
- - lib/yorobot/echo.rb
96
- - lib/yorobot/github/git.rb
97
- - lib/yorobot/github/github.rb
98
- - lib/yorobot/list.rb
99
122
  - lib/yorobot/version.rb
100
123
  homepage: https://github.com/rubycoco/git
101
124
  licenses:
@@ -1,124 +0,0 @@
1
- module Yorobot
2
-
3
-
4
- class Step
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
-
14
-
15
-
16
- def options
17
- @options ||= {}
18
- end
19
-
20
- def parse!( args )
21
- ### todo/check - cache option parser!!!! - why? why not?
22
- OptionParser.new do |parser|
23
- ## add default banner - overwrite if needed/to customize
24
- parser.banner = <<TXT
25
-
26
- Usage: #{name} [OPTIONS] ARGUMENTS
27
-
28
- TXT
29
-
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
35
- end.parse!( args )
36
- end
37
-
38
-
39
-
40
- def self.run( args=[] )
41
- step = new
42
-
43
- puts "--> (#{step.name}) #{args.join('·')}"
44
-
45
- ## check for options
46
- step.parse!( args )
47
-
48
- puts " #{step.options.size} opt(s): #{step.options.pretty_inspect}"
49
- puts " #{args.size} arg(s):"
50
- args.each_with_index do |arg,i|
51
- puts " #{[i]} >#{arg}<"
52
- end
53
-
54
-
55
- if args.size > 0
56
- ## todo/check: check/verify arity of run - why? why not?
57
- step.call( *args ) ## use run - why? why not?
58
- else
59
- step. call
60
- end
61
- end
62
-
63
-
64
- def self.step_name
65
- ## note: cut-off leading Yorobot:: for now in class name!!!
66
- ## note: always remove _ for now too!!!
67
- ## note: do NOT use @@name!!! - one instance variable per class needed!!
68
- @name ||= self.name.downcase
69
- .sub( /^yorobot::/, '' )
70
- .gsub( /[_-]/, '' )
71
- @name
72
- end
73
-
74
- def name() self.class.step_name; end
75
-
76
-
77
-
78
-
79
-
80
- def self.inherited( klass )
81
- # puts klass.class.name #=> Class
82
- ## auto-register steps for now - why? why not?
83
- Yorobot.register( klass )
84
- end
85
-
86
- end # class Step
87
-
88
-
89
-
90
- def self.steps ## todo/check: change to registry or such - why? why not?
91
- @@register ||= {}
92
- end
93
-
94
- def self.register( klass )
95
- raise ArgumentError, "class MUST be a Yorobot::Step" unless klass.ancestors.include?( Step )
96
-
97
- h = steps
98
- h[ klass.step_name] = klass
99
- h
100
- end
101
-
102
-
103
- def self.run( args=[] )
104
- step_name = args.shift
105
-
106
- ## 1) downcase e.g. GithubStats
107
- ## 2) remove - to _ ## treat them the same e.g. github-stats => github_stats
108
- step_name = step_name
109
- .gsub( /[_-]/, '' )
110
- .downcase
111
-
112
- step = steps[ step_name ]
113
- if step.nil?
114
- puts "!! ERROR: no step definition found for >#{step_name}<; known steps include:"
115
- List.run
116
- exit 1
117
- end
118
-
119
- step.run( args )
120
- end
121
-
122
-
123
-
124
- end # module Yorobot
@@ -1,13 +0,0 @@
1
- module Yorobot
2
-
3
-
4
- class Echo < Step
5
-
6
- def call( *args )
7
- puts args.join( ' ' )
8
- end
9
-
10
- end # class Echo
11
-
12
- end # module Yorobot
13
-
@@ -1,98 +0,0 @@
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
@@ -1,30 +0,0 @@
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
-
@@ -1,25 +0,0 @@
1
- module Yorobot
2
-
3
-
4
- class List < Step
5
-
6
- def call
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}"
12
- end
13
- end
14
- end
15
-
16
- end # module Yorobot
17
-
18
-
19
- #####
20
- #
21
- #
22
- # -- add "shortcut why? why not?"
23
- # step [:list, :ls] do |args|
24
- # ....
25
- # end