awesome_bot 0.1.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd7f4c9d4a4ef27387f5be98562f0f639678e8ff
4
- data.tar.gz: 490ef9bdb314344c878e2eb0954c7182db6eb0be
3
+ metadata.gz: 1aa43c6f8d790d1333e7777dbd1794552c1f5b51
4
+ data.tar.gz: ab95e39072c0bc07dce439e09baaba53feac1776
5
5
  SHA512:
6
- metadata.gz: d78425a7f1b3b074532c45962ff28f75a321d9e38cc2c018b62765243b883cd8f7bd329af6ab83a1439a720cf819365fdaf8b2a494519660828f2cb4ab0d3375
7
- data.tar.gz: af9d27a79f04c2b457335cff51fba1454eb16d744d8ea05ce75c63beb926512390a74f803eab61b6b9cbb9f69f204783daded626e0a1093f14d57daac214f02e
6
+ metadata.gz: bd052b6b4b58b4cfd60c148aa8f79158aa523e71c8403a5dfa6ff0fea57bc2503a10bd4a4e9e772daf8eebe8ae3a2944ad159d746587840b6cc3a06ce8aa7d19
7
+ data.tar.gz: 2a95a657d668d72ea67fba69f19a400323d9669938230a9cdee1468f3c01e15de8f0504b7bfcceb00c8f3472eb3850cd900a5588efe38829e62aa7607e390dcb
@@ -2,11 +2,10 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2
4
4
  before_script:
5
- - export PATH=$PATH:$PWD/bin/
6
- - bundle install
5
+ - rake install
7
6
  script:
8
7
  - awesome_bot
9
8
  - awesome_bot bin/assets/test-no-issues
10
9
  - awesome_bot bin/assets/test-no-links
11
10
  - awesome_bot bin/assets/test-dupe --allow-dupe
12
- - awesome_bot README.md --allow-dupe --white-list gph.is,bot.svg
11
+ - awesome_bot README.md --allow-dupe --white-list gph.is,bot.svg,codeload,badge
@@ -0,0 +1,19 @@
1
+ # awesome_bot
2
+
3
+ ## 0.1.0
4
+
5
+ - initial version
6
+
7
+ ## 1.0.0
8
+
9
+ - correct failure logic
10
+ - rename `run` to `check`
11
+ - isolate cli
12
+ - [cli] simply usage, output version
13
+ - [gemspec] update
14
+ - [travis] simplify
15
+
16
+ ## Contact
17
+
18
+ - [github.com/dkhamsing](https://github.com/dkhamsing)
19
+ - [twitter.com/dkhamsing](https://twitter.com/dkhamsing)
data/README.md CHANGED
@@ -7,14 +7,13 @@
7
7
  `awesome_bot` checks for valid URLs in a file, it can be used to verify pull requests to update a README with [Travis](#travis).
8
8
 
9
9
  [![Build Status](https://travis-ci.org/dkhamsing/awesome_bot.svg)](https://travis-ci.org/dkhamsing/awesome_bot)
10
+ [![Gem Version](https://badge.fury.io/rb/awesome_bot.svg)](https://badge.fury.io/rb/awesome_bot)
10
11
 
11
12
  ## Installation
12
13
 
13
14
  Add this line to your application's Gemfile:
14
15
 
15
- ```ruby
16
- gem 'awesome_bot'
17
- ```
16
+ gem 'awesome_bot', '~> 0.1'
18
17
 
19
18
  And then execute:
20
19
 
@@ -26,9 +25,25 @@ Or install it yourself as:
26
25
 
27
26
  ## Usage
28
27
 
28
+ ### Library
29
+
30
+ ```ruby
31
+ irb(main):001:0> require 'awesome_bot'
32
+ => true
33
+ irb(main):002:0> c = File.read 'README.md'
34
+ => "..."
35
+ irb(main):003:0> AwesomeBot.check c
36
+ => [false, [{"url"=>"http://gph.is/1gU5itl", "status"=>301},..]
37
+ # returning false, statuses and dupes if there are errors
38
+ # otherwise returning true
29
39
  ```
30
- awesome_bot <file> [--allow-dupe] [--white-list item1,item2,..]
31
- ```
40
+
41
+ More information at [rubydoc](http://www.rubydoc.info/gems/awesome_bot/0.1.0).
42
+
43
+ ### Command Line
44
+
45
+ awesome_bot <file> [--allow-dupe] [--white-list item1,item2,..]
46
+
32
47
 
33
48
  ```shell
34
49
  $ awesome_bot README.md
@@ -95,13 +110,13 @@ language: ruby
95
110
  rvm:
96
111
  - 2.2
97
112
  before_script:
98
- - wget https://codeload.github.com/dkhamsing/awesome_bot/tar.gz/wip -O /tmp/temp.tar.gz
113
+ - wget https://codeload.github.com/dkhamsing/awesome_bot/tar.gz/master -O /tmp/temp.tar.gz
99
114
  - tar -xvf /tmp/temp.tar.gz
100
- - export PATH=$PATH:$PWD/awesome_bot-wip/bin/
101
- - cd awesome_bot-wip
115
+ - export PATH=$PATH:$PWD/awesome_bot-master/bin/
116
+ - cd awesome_bot-master
102
117
  - bundle install
103
118
  script:
104
- - awesome_bot ../README.md
119
+ - awesome_bot ../README.md
105
120
  ```
106
121
 
107
122
  ## Credits
@@ -9,15 +9,17 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Daniel Khamsing']
10
10
  spec.email = ['dkhamsing8@gmail.com']
11
11
 
12
- spec.summary = 'Validate awesome project URLs.'
12
+ spec.summary = AwesomeBot::PROJECT_DESCRIPTION
13
13
  spec.description = AwesomeBot::PROJECT_DESCRIPTION
14
14
  spec.homepage = AwesomeBot::PROJECT_URL
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
18
+ spec.bindir = 'bin'
19
+ spec.executables = [AwesomeBot::PROJECT]
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = '>= 2.0.0'
21
23
 
22
24
  spec.add_runtime_dependency 'faraday', '~> 0.9.2' # validate urls
23
25
  spec.add_runtime_dependency 'uri', '~> 4.4.29' # get urls
@@ -1,4 +1,5 @@
1
- require 'awesome_bot/command'
1
+ require 'awesome_bot/cli'
2
+ require 'awesome_bot/check'
2
3
 
3
4
  # Validate awesome project URLs
4
5
  module AwesomeBot
@@ -1,64 +1,16 @@
1
1
  require 'awesome_bot/links'
2
2
  require 'awesome_bot/statuses'
3
- require 'awesome_bot/version'
4
3
  require 'awesome_bot/white_list'
5
4
 
6
- # Command
5
+ # Check links
7
6
  module AwesomeBot
8
7
  NUMBER_OF_THREADS = 10
9
8
 
10
- OPTION_DUPE = 'allow-dupe'
11
- OPTION_WHITE_LIST = 'white-list'
12
-
13
9
  STATUS_OK = '✓'
14
10
  STATUS_OTHER = 'x'
15
11
 
16
- USAGE = "\t"
17
-
18
12
  class << self
19
- def cli
20
- option_d = "--#{OPTION_DUPE}"
21
- option_w = "--#{OPTION_WHITE_LIST}"
22
-
23
- if ARGV.count == 0
24
- puts "#{PROJECT_DESCRIPTION} \n"\
25
- "Usage: #{PROJECT} <file> [#{option_d}] "\
26
- "[#{option_w} item1,item2,..]\n"\
27
- "#{USAGE} file \t\t Path to file \n"\
28
- "#{USAGE} #{option_d} \t Skip checking for duplicate URLs \n"\
29
- "#{USAGE} #{option_w} \t Comma separated URLs to white list \n"\
30
- "\nSee #{PROJECT_URL} for more information"
31
-
32
- exit
33
- end
34
-
35
- filename = ARGV[0]
36
- puts "> Checking links in #{filename}"
37
-
38
- if ARGV.count > 1
39
- options = ARGV.drop 1
40
-
41
- skip_dupe = options.include? option_d
42
-
43
- if options.include? option_w
44
- i = options.find_index(option_w) + 1
45
- white_listed = options[i].split ','
46
- end
47
- end
48
-
49
- begin
50
- content = File.read filename
51
- rescue => error
52
- puts "File open error: #{error}"
53
- exit 1
54
- end
55
-
56
- exit 1 if run(content, white_listed, skip_dupe, true) == false
57
-
58
- exit
59
- end
60
-
61
- def run(content, white_listed = nil, skip_dupe = false, verbose = false)
13
+ def check(content, white_listed = nil, skip_dupe = false, verbose = false)
62
14
  dupe_success = skip_dupe
63
15
 
64
16
  puts '> Will not check for duplicate links' if skip_dupe && verbose
@@ -0,0 +1,51 @@
1
+ require 'awesome_bot/version'
2
+
3
+ # Command line interface
4
+ module AwesomeBot
5
+ OPTION_DUPE = 'allow-dupe'
6
+ OPTION_WHITE_LIST = 'white-list'
7
+
8
+ USAGE = "\t"
9
+
10
+ class << self
11
+ def cli
12
+ option_d = "--#{OPTION_DUPE}"
13
+ option_w = "--#{OPTION_WHITE_LIST}"
14
+
15
+ if ARGV.count == 0
16
+ puts "Usage: #{PROJECT} <file> [#{option_d}] "\
17
+ "[#{option_w} item1,item2,..]\n"\
18
+ "#{USAGE} file \t\t Path to file \n"\
19
+ "#{USAGE} #{option_d} \t Skip checking for duplicate URLs \n"\
20
+ "#{USAGE} #{option_w} \t Comma separated URLs to white list \n"\
21
+ "\nVersion #{VERSION}, see #{PROJECT_URL} for more information"
22
+ exit
23
+ end
24
+
25
+ filename = ARGV[0]
26
+ puts "> Checking links in #{filename}"
27
+
28
+ if ARGV.count > 1
29
+ options = ARGV.drop 1
30
+
31
+ skip_dupe = options.include? option_d
32
+
33
+ if options.include? option_w
34
+ i = options.find_index(option_w) + 1
35
+ white_listed = options[i].split ','
36
+ end
37
+ end
38
+
39
+ begin
40
+ content = File.read filename
41
+ rescue => error
42
+ puts "File open error: #{error}"
43
+ exit 1
44
+ end
45
+
46
+ exit 1 unless check(content, white_listed, skip_dupe, true) == true
47
+
48
+ exit
49
+ end
50
+ end # class
51
+ end
@@ -1,8 +1,9 @@
1
1
  # Project version and constants
2
2
  module AwesomeBot
3
3
  PROJECT = 'awesome_bot'
4
- PROJECT_DESCRIPTION = 'Check for valid and duplicate URLs in a file'
4
+ PROJECT_DESCRIPTION = 'Check for valid and duplicate URLs in a file. '\
5
+ 'Great for "awesome" projects.'
5
6
  PROJECT_URL = 'https://github.com/dkhamsing/awesome_bot'
6
7
 
7
- VERSION = '0.1.0'
8
+ VERSION = '1.0.0'
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Khamsing
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -66,15 +66,17 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.7'
69
- description: Check for valid and duplicate URLs in a file
69
+ description: Check for valid and duplicate URLs in a file. Great for "awesome" projects.
70
70
  email:
71
71
  - dkhamsing8@gmail.com
72
- executables: []
72
+ executables:
73
+ - awesome_bot
73
74
  extensions: []
74
75
  extra_rdoc_files: []
75
76
  files:
76
77
  - .gitignore
77
78
  - .travis.yml
79
+ - CHANGELOG.md
78
80
  - Gemfile
79
81
  - LICENSE
80
82
  - README.md
@@ -89,7 +91,8 @@ files:
89
91
  - bin/console
90
92
  - bin/setup
91
93
  - lib/awesome_bot.rb
92
- - lib/awesome_bot/command.rb
94
+ - lib/awesome_bot/check.rb
95
+ - lib/awesome_bot/cli.rb
93
96
  - lib/awesome_bot/links.rb
94
97
  - lib/awesome_bot/statuses.rb
95
98
  - lib/awesome_bot/version.rb
@@ -106,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
109
  requirements:
107
110
  - - '>='
108
111
  - !ruby/object:Gem::Version
109
- version: '0'
112
+ version: 2.0.0
110
113
  required_rubygems_version: !ruby/object:Gem::Requirement
111
114
  requirements:
112
115
  - - '>='
@@ -117,5 +120,5 @@ rubyforge_project:
117
120
  rubygems_version: 2.0.14
118
121
  signing_key:
119
122
  specification_version: 4
120
- summary: Validate awesome project URLs.
123
+ summary: Check for valid and duplicate URLs in a file. Great for "awesome" projects.
121
124
  test_files: []