yorobot 0.1.1 → 1.0.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: ff39fbdd396b74922570f25786f43d20133b2a20
4
- data.tar.gz: 8620855698674cb3096cb0e2b1e2efdaec7aa9d3
3
+ metadata.gz: 744bf1d16ec92d8d24fdface05eaa82468f0cd06
4
+ data.tar.gz: 955a0e8e8efdef32af7b704fe0fe68743f249155
5
5
  SHA512:
6
- metadata.gz: 99d9ae051dcc691573b571d5927ce0081f1700266e98ce47a51949c8609e8ec86c72be0a1748c4d04f4fe7731d648a457669da98b29d2315d3298e98b4cd2dba
7
- data.tar.gz: 1f8f29ac8e02cc3e207136aa7567fb5e98761b22ab548006a4eb8f69095dbb025e1c4cfe95f7ab900fdb8b869bef6a6fd61785aa178275d68f2ad4fcf508c29f
6
+ metadata.gz: 97eb73654cddeaecc7e967ba2e61ef71cdd476fe432696297e4aa9a36c918ae6ee3b14a37fb88d6016c25d407bfed99f89a8f04e95eb0a513b2faaeec0a8c0f4
7
+ data.tar.gz: df1022730ee3ab85a73ec362f91ecd8ef3d5ca7258807ebb96335946558d1dd7fb37d5efafc52191b7cf7e80162e19cc9f19276f1f694fcbb0a3ba1a0aa5af15
@@ -5,8 +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.rb
11
- lib/yorobot/list.rb
12
8
  lib/yorobot/version.rb
data/Rakefile CHANGED
@@ -18,8 +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' ],
22
- ['hubba', '>= 1.0.0' ],
21
+ ['commands-lite', '>= 0.1.0'],
22
+ ['gitti', '>= 0.5.0'],
23
+ ['hubba', '>= 1.0.0'],
23
24
  ]
24
25
 
25
26
  self.licenses = ['Public Domain']
@@ -1,33 +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'
17
17
 
18
18
 
19
+ #### add predefined steps
20
+ module Flow
21
+ class Base
19
22
 
20
- module Yorobot
21
- class Tool
22
- def self.main( args=ARGV )
23
- if args.size > 0
24
- Yorobot.run( args )
25
- else
26
- # list all known steps
27
- List.run
28
- 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
29
47
  end
30
- 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
31
95
  end # module Yorobot
32
96
 
33
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 = 1
9
- PATCH = 1
7
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
8
+ MINOR = 0
9
+ PATCH = 0
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
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.1
4
+ version: 1.0.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-25 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
@@ -91,10 +105,6 @@ files:
91
105
  - bin/yo
92
106
  - bin/yorobot
93
107
  - lib/yorobot.rb
94
- - lib/yorobot/base.rb
95
- - lib/yorobot/echo.rb
96
- - lib/yorobot/github.rb
97
- - lib/yorobot/list.rb
98
108
  - lib/yorobot/version.rb
99
109
  homepage: https://github.com/rubycoco/git
100
110
  licenses:
@@ -1,121 +0,0 @@
1
- module Yorobot
2
-
3
-
4
- class Step
5
-
6
-
7
-
8
- def options
9
- @options ||= {}
10
- end
11
-
12
- def on_parse_options( parser ) ## todo/check: find a better name?
13
- ## do nothing; overwrite
14
- end
15
-
16
-
17
- def parse!( args )
18
- ### cache option parser - why? why not?
19
- OptionParser.new do |parser|
20
- ## add default banner - overwrite if needed/to customize
21
- parser.banner = <<TXT
22
-
23
- Usage: #{name} [OPTIONS] ARGUMENTS
24
-
25
- TXT
26
-
27
- on_parse_options( parser )
28
- end.parse!( args )
29
- end
30
-
31
-
32
-
33
-
34
- def self.run( args=[] )
35
- step = new
36
-
37
- puts "--> (#{step.name}) #{args.join('·')}"
38
-
39
- ## check for options
40
- step.parse!( args )
41
-
42
- puts " #{step.options.size} opt(s): #{step.options.pretty_inspect}"
43
- puts " #{args.size} arg(s):"
44
- args.each_with_index do |arg,i|
45
- puts " #{[i]} >#{arg}<"
46
- end
47
-
48
- #
49
-
50
-
51
-
52
- if args.size > 0
53
- ## todo/check: check/verify arity of run - why? why not?
54
- step.call( *args ) ## use run - why? why not?
55
- else
56
- step. call
57
- end
58
- end
59
-
60
-
61
- def self.step_name
62
- ## note: cut-off leading Yorobot:: for now in class name!!!
63
- ## note: always remove _ for now too!!!
64
- ## note: do NOT use @@name!!! - one instance variable per class needed!!
65
- @name ||= self.name.downcase
66
- .sub( /^yorobot::/, '' )
67
- .gsub( /[_-]/, '' )
68
- @name
69
- end
70
-
71
- def name() self.class.step_name; end
72
-
73
-
74
-
75
-
76
-
77
- def self.inherited( klass )
78
- # puts klass.class.name #=> Class
79
- ## auto-register steps for now - why? why not?
80
- Yorobot.register( klass )
81
- end
82
-
83
- end # class Step
84
-
85
-
86
-
87
- def self.steps ## todo/check: change to registry or such - why? why not?
88
- @@register ||= {}
89
- end
90
-
91
- def self.register( klass )
92
- raise ArgumentError, "class MUST be a Yorobot::Step" unless klass.ancestors.include?( Step )
93
-
94
- h = steps
95
- h[ klass.step_name] = klass
96
- h
97
- end
98
-
99
-
100
- def self.run( args=[] )
101
- step_name = args.shift
102
-
103
- ## 1) downcase e.g. GithubStats
104
- ## 2) remove - to _ ## treat them the same e.g. github-stats => github_stats
105
- step_name = step_name
106
- .gsub( /[_-]/, '' )
107
- .downcase
108
-
109
- step = steps[ step_name ]
110
- if step.nil?
111
- puts "!! ERROR: no step definition found for >#{step_name}<; known steps include:"
112
- List.run
113
- exit 1
114
- end
115
-
116
- step.run( args )
117
- end
118
-
119
-
120
-
121
- 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,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
-
@@ -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