dissect 0.1.0pre → 0.1.1pre

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: c1b18e052c8694d0856f43ab81a15c13201987cf
4
- data.tar.gz: eb9c6ed81637ef765a0778ef0c41e90237ec303f
3
+ metadata.gz: d7ead41a217cfd49b5a6ecb1ab7e8de0fa05ab50
4
+ data.tar.gz: c5ae819d6d09de484058f0aa659cb1300f69fb5b
5
5
  SHA512:
6
- metadata.gz: 02ec23c0f9a2751feed840bb821a8561dc7ea9008d14b2a129cdd493a0be595fc8680d8ce43ed495133fe875d124902be647f3b0bf6e233bc679b5c2f9a6a8de
7
- data.tar.gz: a77c6b7d0ba90d1c2d33e8e421d8eb3a60623ce69b6e8ec2ea915714a758bd3e09182477b0e07b0c4638b0c65061c7f72131391d084a2b05a9f1619d5d00a6c0
6
+ metadata.gz: b65b43998c97673c197bdc9a597786b1358afe47015f24963c80a65a69764c2a6bd3528e0e7c11c0132fa8dcf604977fb21f7c6e3ea0832a96c5519f981f3591
7
+ data.tar.gz: 30499cd34de4c31c574139ed84774a08fac0904a11d90bdb59217540847c1ddaa0f5477a0b81308bd11b883acddbd458c961ba18c57429e2100308e60e2c1be4
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/README.md CHANGED
@@ -1,14 +1,23 @@
1
- [travis]: https://travis-ci.org/blacktangent/dissect
1
+ [travis]: https://travis-ci.org/olejrosendahl/dissect
2
+ [codeclimate]: https://codeclimate.com/github/olejrosendahl/dissect
3
+ [coveralls]: https://coveralls.io/r/olejrosendahl/dissect
4
+ [rubygems]: https://rubygems.org/gems/dissect
2
5
 
3
6
  # Dissect
4
7
 
5
- [![Build Status](https://travis-ci.org/blacktangent/dissect.svg?branch=master)][travis]
8
+ [![Build Status](https://travis-ci.org/olejrosendahl/dissect.svg?branch=master)][travis]
9
+ [![Code Climate](https://codeclimate.com/github/olejrosendahl/dissect/badges/gpa.svg)][codeclimate]
10
+ [![Test Coverage](http://img.shields.io/coveralls/olejrosendahl/dissect/master.svg)][coveralls]
11
+ [![Gem Version](http://img.shields.io/gem/v/dissect.svg)][rubygems]
6
12
 
7
- Problem: Known Gems have has good or bad documentation, examples or
8
- Wikies, but what often lacks is examples of the features used in the wild.
13
+ *EXPERIMENTAL*
9
14
 
10
- Solution: Find Open Source projects for the Gems to see how the
11
- libraries API's are being used in the wild to find good examples.
15
+ Problem: Libraries are often well documented, but what often lacks to
16
+ get started is to see examples of their features used in the wild.
17
+
18
+ Solution: Find Open Source projects on Github where the libraries are
19
+ used. Learn their API's and see how other programmers use them and
20
+ explore possibilities.
12
21
 
13
22
  ## Installation
14
23
 
@@ -28,19 +37,23 @@ Or install it yourself as:
28
37
 
29
38
  ## API
30
39
 
31
- # search organization for given gem name
32
- code_search(gem_name, organization, options = {})
40
+ ```ruby
41
+ # search organization for given library name
42
+ find(organization, name)
43
+ ```
33
44
 
34
45
  ## Usage
35
46
 
36
- dissect = Dissect::Client.new
37
- findings = dissect.code_search("rails", "thoughtbot", "ruby")
38
- findings.each do |f|
39
- puts f.name
40
- puts f.path
41
- puts f.html_url
42
- puts f.repository_name
43
- end
47
+ ```ruby
48
+ dissect = Dissect::Finders::GemFinder.new
49
+ findings = dissect.find("thoughtbot", "devise")
50
+ findings.each do |f|
51
+ puts f.name
52
+ puts f.path
53
+ puts f.html_url
54
+ puts f.repository_name
55
+ end
56
+ ```
44
57
 
45
58
  ## Development
46
59
 
data/dissect.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rspec"
28
28
  spec.add_development_dependency "vcr"
29
29
  spec.add_development_dependency "webmock"
30
+ spec.add_development_dependency "coveralls"
30
31
  end
data/lib/dissect.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "dissect/version"
2
- require "dissect/client"
3
2
  require "dissect/formatters/json"
4
3
  require "dissect/models/finding"
4
+ require "dissect/finders/base_finder"
5
+ require "dissect/finders/gem_finder"
5
6
  require "octokit"
@@ -0,0 +1,29 @@
1
+ module Dissect
2
+ module Finders
3
+ class BaseFinder
4
+
5
+ def initialize
6
+ @connection = Octokit::Client.new
7
+ end
8
+
9
+ def find(organization, name, language)
10
+ findings = []
11
+ patterns.each do |pattern|
12
+ query = "#{sprintf(pattern["pattern"], name)} filename:#{pattern["filename"]} path:#{pattern["path"]} user:#{organization} language:#{language}"
13
+ result = @connection.get("/search/code", q: query)
14
+ result[:items].each do |item|
15
+ findings << Models::Finding.new(item, pattern["description"])
16
+ end
17
+ end
18
+ findings
19
+ end
20
+
21
+ private
22
+
23
+ def patterns
24
+ JSON.parse(File.read("#{File.dirname(__FILE__)}/../../../patterns.json"))
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module Dissect
2
+ module Finders
3
+ class GemFinder < BaseFinder
4
+
5
+ def find(organization, name)
6
+ super(organization, name, "ruby")
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,10 +1,10 @@
1
1
  module Dissect
2
2
  module Models
3
3
  class Finding
4
- attr_accessor :item
4
+ attr_accessor :item, :description
5
5
 
6
- def initialize(item)
7
- @item = item
6
+ def initialize(item, description)
7
+ @item, @description = item, description
8
8
  end
9
9
 
10
10
  def name
@@ -1,3 +1,3 @@
1
1
  module Dissect
2
- VERSION = "0.1.0pre"
2
+ VERSION = "0.1.1pre"
3
3
  end
data/patterns.json ADDED
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "pattern": "gem %s",
4
+ "filename": "Gemfile",
5
+ "path": "/",
6
+ "description": "Gemfile"
7
+ }
8
+ ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dissect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0pre
4
+ version: 0.1.1pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole J. Rosendahl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-26 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
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'
97
111
  description: Simple wrapper around Octokit.rb's code search to find Gems in Gemfiles
98
112
  email:
99
113
  - ole.johnny.rosendahl@gmail.com
@@ -101,6 +115,7 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".coveralls.yml"
104
119
  - ".gitignore"
105
120
  - ".rspec"
106
121
  - ".travis.yml"
@@ -114,11 +129,13 @@ files:
114
129
  - bin/setup
115
130
  - dissect.gemspec
116
131
  - lib/dissect.rb
117
- - lib/dissect/client.rb
132
+ - lib/dissect/finders/base_finder.rb
133
+ - lib/dissect/finders/gem_finder.rb
118
134
  - lib/dissect/formatters/console.rb
119
135
  - lib/dissect/formatters/json.rb
120
136
  - lib/dissect/models/finding.rb
121
137
  - lib/dissect/version.rb
138
+ - patterns.json
122
139
  homepage: https://github.com/olejrosendahl/dissect
123
140
  licenses:
124
141
  - MIT
@@ -1,31 +0,0 @@
1
- module Dissect
2
- class Client
3
-
4
- PATTERNS = [
5
- "gem '%s' filename:Gemfile path:/",
6
- "gem \"%s\" filename:Gemfile path:/",
7
- ]
8
-
9
- def initialize
10
- @connection = Octokit::Client.new
11
- end
12
-
13
- def code_search(gem, organisation, language)
14
- findings = []
15
- PATTERNS.each do |pattern|
16
- result = @connection.get("/search/code", q: query_string(pattern, gem, organisation, language))
17
- result[:items].each do |item|
18
- findings << Models::Finding.new(item)
19
- end
20
- end
21
- findings
22
- end
23
-
24
- private
25
-
26
- def query_string(pattern, gem, user, language)
27
- sprintf(pattern, gem) + " user:#{user} language:#{language}"
28
- end
29
-
30
- end
31
- end