yorobot 0.1.0 → 0.1.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: 2252541ead5305b3472d0f371e1040461290ad82
4
- data.tar.gz: f13e3073fdbcdae51a68c294d3edb3ee5b64e518
3
+ metadata.gz: ff39fbdd396b74922570f25786f43d20133b2a20
4
+ data.tar.gz: 8620855698674cb3096cb0e2b1e2efdaec7aa9d3
5
5
  SHA512:
6
- metadata.gz: 6310b01adc581ad48a71b93e86c5b76525417a4cc1392787f310db7ba52ee1c92f0e85a5fba176c8285def710fe2d9c42a25cafec59b7d89d429de4c2c8126ba
7
- data.tar.gz: 43866b4d8e30d64dfa9c232569c46a44dcb0466cfcb32bd70b7898754111f9fd3c3f4217d753d17e4ed64395b0eaeaa8eb92fd8394a0d20c9da36481d6836229
6
+ metadata.gz: 99d9ae051dcc691573b571d5927ce0081f1700266e98ce47a51949c8609e8ec86c72be0a1748c4d04f4fe7731d648a457669da98b29d2315d3298e98b4cd2dba
7
+ data.tar.gz: 1f8f29ac8e02cc3e207136aa7567fb5e98761b22ab548006a4eb8f69095dbb025e1c4cfe95f7ab900fdb8b869bef6a6fd61785aa178275d68f2ad4fcf508c29f
@@ -7,5 +7,6 @@ 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
11
  lib/yorobot/list.rb
11
12
  lib/yorobot/version.rb
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ Hoe.spec 'yorobot' do
19
19
 
20
20
  self.extra_deps = [
21
21
  ['gitti', '>= 0.5.0' ],
22
+ ['hubba', '>= 1.0.0' ],
22
23
  ]
23
24
 
24
25
  self.licenses = ['Public Domain']
@@ -1,23 +1,21 @@
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
13
6
  require 'gitti'
7
+ require 'hubba'
14
8
 
15
9
 
16
10
  # our own code
11
+ require 'yorobot/version' # note: let version always go first
17
12
  require 'yorobot/base'
18
13
  require 'yorobot/echo'
19
14
  require 'yorobot/list'
20
15
 
16
+ require 'yorobot/github'
17
+
18
+
21
19
 
22
20
  module Yorobot
23
21
  class Tool
@@ -32,3 +30,5 @@ module Yorobot
32
30
  end # class Tool
33
31
  end # module Yorobot
34
32
 
33
+
34
+ puts YorobotCore.banner # say hello
@@ -3,17 +3,68 @@ module Yorobot
3
3
 
4
4
  class Step
5
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
+
6
34
  def self.run( args=[] )
7
35
  step = new
8
- puts "--> (#{step.name}) #{args.join('·')}"
9
36
 
10
- step.call( args ) ## use run - why? why not?
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
11
58
  end
12
59
 
60
+
13
61
  def self.step_name
14
62
  ## note: cut-off leading Yorobot:: for now in class name!!!
63
+ ## note: always remove _ for now too!!!
15
64
  ## note: do NOT use @@name!!! - one instance variable per class needed!!
16
- @name ||= self.name.downcase.sub( /^yorobot::/, '' )
65
+ @name ||= self.name.downcase
66
+ .sub( /^yorobot::/, '' )
67
+ .gsub( /[_-]/, '' )
17
68
  @name
18
69
  end
19
70
 
@@ -49,12 +100,19 @@ end
49
100
  def self.run( args=[] )
50
101
  step_name = args.shift
51
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
+
52
109
  step = steps[ step_name ]
53
110
  if step.nil?
54
111
  puts "!! ERROR: no step definition found for >#{step_name}<; known steps include:"
55
112
  List.run
56
113
  exit 1
57
114
  end
115
+
58
116
  step.run( args )
59
117
  end
60
118
 
@@ -3,7 +3,7 @@ module Yorobot
3
3
 
4
4
  class Echo < Step
5
5
 
6
- def call( args )
6
+ def call( *args )
7
7
  puts args.join( ' ' )
8
8
  end
9
9
 
@@ -0,0 +1,40 @@
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
+
@@ -3,7 +3,7 @@ module Yorobot
3
3
 
4
4
  class List < Step
5
5
 
6
- def call( args )
6
+ def call
7
7
  ## list all know steps
8
8
  steps = Yorobot.steps
9
9
  puts "#{steps.size} step(s):"
@@ -6,7 +6,7 @@
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
8
  MINOR = 1
9
- PATCH = 0
9
+ PATCH = 1
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
@@ -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,7 +1,7 @@
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.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: hubba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rdoc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +93,7 @@ files:
79
93
  - lib/yorobot.rb
80
94
  - lib/yorobot/base.rb
81
95
  - lib/yorobot/echo.rb
96
+ - lib/yorobot/github.rb
82
97
  - lib/yorobot/list.rb
83
98
  - lib/yorobot/version.rb
84
99
  homepage: https://github.com/rubycoco/git