amanogawa 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 09435433fda9bf071cd3ffd16bc73a6efca72c89
4
+ data.tar.gz: d9f99f5a8597fc931f434cbcfa3a4fff41e06ba7
5
+ SHA512:
6
+ metadata.gz: e9ba0b97b91ea2a2d2bce7b03d78398354f7f1738acc66724b878c6525cf700bb0d4e28cf5f67dfd49746f80a4b6df7f0d297a495e91a4b140a148ef03dc87e8
7
+ data.tar.gz: ff33dfa5a202ac0713c49f5c38c9634eadc7ff1430966c9ddf374a9ae0f4b760144acce06ec07263a667e3789ef51fc5ea8674afdf3df09f3daac7559fec660b
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in amanogawa.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 joker1007
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # Amanogawa
2
+
3
+ Listing GitHub repositories which you starred.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'amanogawa'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install amanogawa
20
+
21
+ ## Usage
22
+
23
+ ### Sync
24
+ First, sync your starred repositories.
25
+ ```sh
26
+ $ amanogawa --sync -t <your auth token>
27
+
28
+ # or
29
+
30
+ $ amanogawa --sync -u <your github username> -p <your github password>
31
+
32
+ # or
33
+
34
+ $ amanogawa --sync # use .netrc (cf. https://github.com/octokit/octokit.rb)
35
+
36
+ # => Write to ~/.cache/amanogawa.dump
37
+ ```
38
+
39
+ ### Simple Listing
40
+
41
+ ```sh
42
+ $ amanogawa
43
+ jquense/react-widgets - set of stateless ui widgets for React
44
+ geraintluff/uri-templates - JavaScript utility for RFC 6570: URI Templates
45
+ ismasan/oat - Adapters-based API serializers with Hypermedia support for Ruby apps.
46
+ k0kubun/activerecord-precount - N+1 count query killer for ActiveRecord
47
+ ko1/pretty_backtrace - Pretty your exception backtrace.
48
+ jhudson8/react-backbone - backbone-aware mixins for react
49
+ # ...
50
+ ```
51
+
52
+ ### Fetch current starred and Listing
53
+
54
+ ```sh
55
+ $ amanogawa --fetch -t <your auth token>
56
+ ```
57
+
58
+ ### Use Format
59
+
60
+ ```sh
61
+ $ amanogawa -f "%f - %u"
62
+ jquense/react-widgets - set of stateless ui widgets for React
63
+ jquense/react-widgets - https://api.github.com/repos/jquense/react-widgets
64
+ geraintluff/uri-templates - https://api.github.com/repos/geraintluff/uri-templates
65
+ ismasan/oat - https://api.github.com/repos/ismasan/oat
66
+ k0kubun/activerecord-precount - https://api.github.com/repos/k0kubun/activerecord-precount
67
+ ko1/pretty_backtrace - https://api.github.com/repos/ko1/pretty_backtrace
68
+ jhudson8/react-backbone - https://api.github.com/repos/jhudson8/react-backbone
69
+ ```
70
+
71
+ ### Format table
72
+
73
+ ```ruby
74
+ FORMAT_TABLE = {
75
+ "%i" => "id",
76
+ "%n" => "name",
77
+ "%f" => "full_name",
78
+ "%d" => "description",
79
+ "%u" => "url",
80
+ "%s" => "ssh_url",
81
+ "%g" => "git_url",
82
+ "%C" => "created_at",
83
+ "%P" => "pushed_at",
84
+ "%U" => "updated_at",
85
+ }
86
+ ```
87
+
88
+ And, convert `%t` to Tab.
89
+
90
+
91
+ ## Contributing
92
+
93
+ 1. Fork it ( https://github.com/joker1007/amanogawa/fork )
94
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
95
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
96
+ 4. Push to the branch (`git push origin my-new-feature`)
97
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/amanogawa.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'amanogawa/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "amanogawa"
8
+ spec.version = Amanogawa::VERSION
9
+ spec.authors = ["joker1007"]
10
+ spec.email = ["kakyoin.hierophant@gmail.com"]
11
+ spec.summary = %q{Listing GitHub repositories which you starred.}
12
+ spec.description = %q{Listing GitHub repositories which you starred.}
13
+ spec.homepage = "https://github.com/joker1007/amanogawa"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "octokit", "~> 3.0"
22
+ spec.add_runtime_dependency "netrc"
23
+ spec.add_runtime_dependency "oj"
24
+ spec.add_runtime_dependency "slop", "~> 4.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec"
29
+ end
data/bin/amanogawa ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'slop'
4
+ require 'amanogawa'
5
+
6
+ opts = Slop.parse do |o|
7
+ o.string '-t' , '--token' , 'oauth access token'
8
+ o.string '-u' , '--username' , 'github username'
9
+ o.string '-p' , '--password' , 'github password'
10
+ o.string '-f' , '--format' , 'output format', default: "%f - %d"
11
+ o.bool '--sync' , 'Sync starred repositories'
12
+ o.bool '--fetch' , 'Fetch GitHub API actually, No use local cache'
13
+ end
14
+
15
+ if opts[:sync]
16
+ if opts[:token]
17
+ Amanogawa::Client.new(opts[:token]).sync
18
+ elsif opts[:username] && opts[:password]
19
+ Amanogawa::Client.new(opts[:username], opts[:password]).sync
20
+ else
21
+ Amanogawa::Client.new.sync
22
+ end
23
+
24
+ puts "Sync Complete !!"
25
+ exit 0
26
+ end
27
+
28
+ if opts[:fetch]
29
+ if opts[:token]
30
+ Amanogawa.fetch_output(opts[:format], opts[:token])
31
+ elsif opts[:username] && opts[:password]
32
+ Amanogawa.fetch_output(opts[:format], opts[:username], opts[:password])
33
+ else
34
+ Amanogawa.fetch_output(opts[:format])
35
+ end
36
+ else
37
+ Amanogawa.output(opts[:format])
38
+ end
data/lib/amanogawa.rb ADDED
@@ -0,0 +1,75 @@
1
+ require 'octokit'
2
+ require 'oj'
3
+ require 'fileutils'
4
+ require "amanogawa/version"
5
+
6
+ class Amanogawa
7
+ FORMAT_TABLE = {
8
+ "%i" => "id",
9
+ "%n" => "name",
10
+ "%f" => "full_name",
11
+ "%d" => "description",
12
+ "%u" => "url",
13
+ "%s" => "ssh_url",
14
+ "%g" => "git_url",
15
+ "%C" => "created_at",
16
+ "%P" => "pushed_at",
17
+ "%U" => "updated_at",
18
+ }
19
+
20
+ class << self
21
+ def cache_file
22
+ cache_dir = File.expand_path("~/.cache")
23
+ FileUtils.mkdir(cache_dir) unless File.exists?(cache_dir)
24
+ File.join(cache_dir, "amanogawa.dump")
25
+ end
26
+
27
+ def output(format)
28
+ do_output(load_cache, format)
29
+ end
30
+
31
+ def fetch_output(format, *args)
32
+ client = Client.new(*args)
33
+ do_output(client.fetch, format)
34
+ end
35
+
36
+ def load_cache
37
+ Marshal.load(File.read(cache_file))
38
+ end
39
+
40
+ private
41
+
42
+ def do_output(data, format)
43
+ data.each do |s|
44
+ line = FORMAT_TABLE.inject(format) do |l, (k, v)|
45
+ l.gsub(/#{k}/, s.send(v).to_s)
46
+ end
47
+ puts line.gsub(/%t/, " ")
48
+ end
49
+ end
50
+ end
51
+
52
+ class Client
53
+ def initialize(*args)
54
+ case args.length
55
+ when 0
56
+ @client = Octokit::Client.new(netrc: true)
57
+ when 1
58
+ @client = Octokit::Client.new(access_token: args[0])
59
+ when 2
60
+ @client = Octokit::Client.new(login: args[0], password: args[1])
61
+ else
62
+ raise ArgumentError
63
+ end
64
+ end
65
+
66
+ def fetch
67
+ @client.auto_paginate = true
68
+ @client.starred
69
+ end
70
+
71
+ def sync
72
+ File.open(Amanogawa.cache_file, "w") { |f| f.write(Marshal.dump(fetch)) }
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ class Amanogawa
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amanogawa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - joker1007
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: netrc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: slop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Listing GitHub repositories which you starred.
112
+ email:
113
+ - kakyoin.hierophant@gmail.com
114
+ executables:
115
+ - amanogawa
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - amanogawa.gemspec
127
+ - bin/amanogawa
128
+ - lib/amanogawa.rb
129
+ - lib/amanogawa/version.rb
130
+ homepage: https://github.com/joker1007/amanogawa
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Listing GitHub repositories which you starred.
154
+ test_files: []