lexhub 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ spec/fixtures/vcr_cassettes
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3@lexhub
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lexhub.gemspec
4
+ gemspec
5
+
6
+ gem 'yard'
7
+ gem 'yard-tomdoc'
8
+ gem 'redcarpet'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Joe Sak
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,47 @@
1
+ # Lexhub
2
+
3
+ Find out your most commonly used words in commits, I guess.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'lexhub'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install lexhub
20
+
21
+ ## Usage
22
+
23
+ You will need a Github Application registered with an auth token.
24
+
25
+ TODO: This step might go away...
26
+
27
+ ```
28
+ export GITHUB_AUTH_TOKEN=abc123...
29
+ ```
30
+
31
+ ```ruby
32
+ repo = Lexhub::Repo.new('github_username', 'repo_name')
33
+
34
+ repo.commits #=> same as using github api gem, .repos.commits.all
35
+ repo.words #=> all words from all commit messages
36
+
37
+ ```
38
+
39
+ TODO: More to come...
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lexhub.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lexhub/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "lexhub"
8
+ gem.version = Lexhub::VERSION
9
+ gem.authors = ["Joe Sak"]
10
+ gem.email = ["joe@joesak.com"]
11
+ gem.description = %q{Hi Haters}
12
+ gem.summary = %q{I'll do this in a bit okay}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'rspec'
21
+ gem.add_development_dependency 'vcr'
22
+ gem.add_development_dependency 'webmock'
23
+
24
+ gem.add_dependency 'github_api'
25
+ end
data/lib/lexhub.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'github_api'
2
+
3
+ require 'lexhub/version'
4
+ require 'lexhub/base'
5
+ require 'lexhub/repo'
6
+
7
+ # Internal: Your application's auth token
8
+ #
9
+ # This will become a config
10
+ GITHUB_AUTH_TOKEN = ENV['GITHUB_AUTH_TOKEN']
11
+
12
+ # Internal: The github object for making API requests
13
+ #
14
+ # This will become a config
15
+ GITHUB = Github.new(:oauth => GITHUB_AUTH_TOKEN)
16
+
17
+ # Find out the most common words in your commit messages
18
+ module Lexhub
19
+ end
@@ -0,0 +1,28 @@
1
+ module Lexhub
2
+ # Base class for API interaction
3
+ class Base
4
+ private
5
+ # Internal: Collect items from API endpoints
6
+ #
7
+ # collection_item - Symbol name of item to collect
8
+ # api_method - String Github method chain
9
+ def _collect(collection_item, api_method)
10
+ results = []
11
+
12
+ response(api_method).each_page do |page|
13
+ results += page.collect(&collection_item)
14
+ end
15
+
16
+ results
17
+ end
18
+
19
+ # Internal: Get a response from the Github API
20
+ #
21
+ # api_method - String Github method chain
22
+ #
23
+ # Returns the response from Github
24
+ def response(api_method)
25
+ @response ||= eval("GITHUB.#{api_method}(@username, @repo_name)")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ module Lexhub
2
+ # Wrapper for Github API Repo
3
+ class Repo < Base
4
+ # Public: Initialize a new Lexhub::Repo
5
+ #
6
+ # username - the github username of the repo owner
7
+ # repo_name - the name of the repo
8
+ #
9
+ # Examples
10
+ #
11
+ # repo = Lexhub::Repo.new('joemsak', 'lexhub')
12
+ #
13
+ def initialize(username, repo_name)
14
+ @username = username
15
+ @repo_name = repo_name
16
+ end
17
+
18
+ # Public: Get the commits of the named repo
19
+ #
20
+ # Examples
21
+ #
22
+ # repo.commits
23
+ # # => [#<Hashie::Mash author=...>, #<Hashie::Mash author...>]
24
+ #
25
+ # # same as if you had done:
26
+ # #
27
+ # # github = Github.new(:oauth_token => 'abc123...')
28
+ # # github.repos.commits.all('joemsak', 'lexhub')
29
+ #
30
+ # Returns Array commits
31
+ def commits
32
+ @commits ||= _collect(:commit, 'repos.commits.all')
33
+ end
34
+
35
+ # Public: Collect the words of all commit messages
36
+ #
37
+ # Examples
38
+ #
39
+ # repo.words
40
+ # # => ['a', 'bunch', 'of', 'words']
41
+ #
42
+ # Returns Array all commit message words
43
+ def words
44
+ @words ||= commits.collect(&:message).join(' ').split(' ')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ module Lexhub
2
+ # Lexhub::VERSION
3
+ VERSION = "0.0.1.alpha"
4
+ end
data/spec/.gitkeep ADDED
File without changes
@@ -0,0 +1,11 @@
1
+ require 'vcr_helper'
2
+ require 'lexhub'
3
+
4
+ describe 'Counting words in all commit messages' do
5
+ it "counts the words" do
6
+ VCR.use_cassette('collect all the words') do
7
+ repo = Lexhub::Repo.new('joemsak', 'lexhub')
8
+ repo.words.count.should == 73
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'vcr_helper'
2
+ require 'lexhub'
3
+
4
+ describe "Read commits from a repo on github" do
5
+ it "returns commits with their messages" do
6
+ VCR.use_cassette('read commits from a repo') do
7
+ repo = Lexhub::Repo.new('joemsak', 'lexhub')
8
+ commit = repo.commits.last
9
+
10
+ commit.message.should == 'Initial commit'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'vcr'
3
+
4
+ VCR.configure do |c|
5
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
6
+ c.hook_into :webmock
7
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lexhub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Joe Sak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: vcr
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: webmock
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: github_api
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Hi Haters
79
+ email:
80
+ - joe@joesak.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - .rvmrc
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - lexhub.gemspec
93
+ - lib/lexhub.rb
94
+ - lib/lexhub/base.rb
95
+ - lib/lexhub/repo.rb
96
+ - lib/lexhub/version.rb
97
+ - spec/.gitkeep
98
+ - spec/count_words_spec.rb
99
+ - spec/read_commits_spec.rb
100
+ - spec/vcr_helper.rb
101
+ homepage: ''
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>'
117
+ - !ruby/object:Gem::Version
118
+ version: 1.3.1
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: I'll do this in a bit okay
125
+ test_files:
126
+ - spec/.gitkeep
127
+ - spec/count_words_spec.rb
128
+ - spec/read_commits_spec.rb
129
+ - spec/vcr_helper.rb
130
+ has_rdoc: