7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/github_organizations_scraper/cli.rb', line 7
def self.execute(stdout, arguments=[])
options = {}
parser = OptionParser.new do |opts|
opts.banner = " Display the members of an organisation account on GitHub.\n\n Usage: \#{File.basename($0)} [options]\n\n Options are:\n BANNER\n opts.separator \"\"\n opts.on(\"-j\", \"--json\",\n \"Display results in JSON format\") { options[:json] = true }\n opts.on(\"-h\", \"--help\",\n \"Show this help message.\") { stdout.puts opts; exit }\n opts.parse!(arguments)\n\n end\n \n account = arguments.shift\n html = Net::HTTP.get(URI.parse(\"http://github.com/\#{account}\"))\n doc = Nokogiri::HTML(html)\n members = doc.search(\"ul.org-members li\").map do |member|\n login = member.search(\"h4 a\").text\n if member.search(\"h4 em\").text =~ /\\((.*)\\)/\n name = $1\n end\n repo_summary = member.search(\"p\").text\n { :login => login, :name => name, :repo_summary => repo_summary }\n end\n \n if options[:json]\n display_members_json(stdout, members)\n else\n display_members_tty(stdout, members)\n end\nend\n".gsub(/^ /,'')
|