Skip to content

Commit

Permalink
Bump version to 0.1.3
Browse files Browse the repository at this point in the history
- Simplify the CLI usage
- Cleanup style with rubocop
  • Loading branch information
agilecreativity committed May 16, 2014
1 parent 9cea664 commit 2ba0b76
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 127 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ spec/reports
test/tmp
test/version_tmp
tmp

# custom generated files
index.html
rubocop-todo.yml
.ruby-version
100 changes: 93 additions & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,96 @@
# This is the configuration used to check the rubocop source code.
AllCops:
Include:
- '**/Rakefile'
- '**/Gemfile'
- lib/**/*
- Gemfile
- Rakefile
- bin/*
Exclude:
- .rubocop.yml
inherit_from: rubocop-todo.yml
- index_html.gemspec
- lib/**/*.rb
- spec/index_html/**/*.rb
- spec/spec_helper.rb
# Avoid long parameter lists
ParameterLists:
Max: 5
CountKeywordArgs: true

MethodLength:
CountComments: false
Max: 15

# Avoid more than `Max` levels of nesting.
BlockNesting:
Max: 4

# Align with the style guide.
CollectionMethods:
PreferredMethods:
collect: 'map'
inject: 'reduce'
find: 'detect'
find_all: 'select'

# Do not force public/protected/private keyword to be indented at the same
# level as the def keyword. My personal preference is to outdent these keywords
# because I think when scanning code it makes it easier to identify the
# sections of code and visually separate them. When the keyword is at the same
# level I think it sort of blends in with the def keywords and makes it harder
# to scan the code and see where the sections are.
AccessModifierIndentation:
Enabled: false

# Limit line length
LineLength:
Enabled: false

# Disable documentation checking until a class needs to be documented once
Documentation:
Enabled: false

# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
Enabled: true

# No spaces inside hash literals
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

# Allow dots at the end of lines
DotPosition:
Enabled: false

# Don't require magic comment at the top of every file
Encoding:
Enabled: false

# Enforce outdenting of access modifiers (i.e. public, private, protected)
AccessModifierIndentation:
EnforcedStyle: outdent

EmptyLinesAroundAccessModifier:
Enabled: true

# Align ends correctly
EndAlignment:
AlignWith: variable

# Indentation of when/else
CaseIndentation:
IndentWhenRelativeTo: end
IndentOneStep: false

DoubleNegation:
Enabled: false

PercentLiteralDelimiters:
PreferredDelimiters:
'%': ()
'%i': ()
'%q': ()
'%Q': ()
'%r': '{}'
'%s': ()
'%w': '[]'
'%W': '[]'
'%x': ()

StringLiterals:
EnforcedStyle: double_quotes
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.1
- 2.1.2
6 changes: 6 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### Changelogs

#### 0.1.3

- Simplify the CLI usage
- Cleanup style with rubocop
- Add `coveralls` badges

#### 0.1.2

- First release based on the [Semantic Versioning][] convention.
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in file_indexer.gemspec
gemspec

gem "coveralls", require: false
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
[![Gem Version](https://badge.fury.io/rb/index_html.svg)][gem]
[![Dependency Status](https://gemnasium.com/agilecreativity/index_html.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/agilecreativity/index_html.png)][codeclimate]
[![Build Status](https://secure.travis-ci.org/agilecreativity/index_html.png)][travis-ci]
[![Coverage Status](https://coveralls.io/repos/agilecreativity/index_html/badge.png)][coveralls]

[gem]: http://badge.fury.io/rb/index_html
[gemnasium]: https://gemnasium.com/agilecreativity/index_html
[codeclimate]: https://codeclimate.com/github/agilecreativity/index_html
[travis-ci]: http://travis-ci.org/agilecreativity/index_html
[coveralls]: https://coveralls.io/r/agilecreativity/index_html

Quickly generate the index.html files based on your simple criteria.

Expand Down Expand Up @@ -37,10 +41,10 @@ that have the specific word 'Android' in the title you could perhap try somethin
```sh
gem install index_html
cd ~/Dropbox/ebooks/
index_html generate --base-dir . \
--exts epub pdf mobi \
--inc-words android \
--recursive
index_html --base-dir . \
--exts epub pdf mobi \
--inc-words android \
--recursive
```

### Help/Usage:
Expand Down Expand Up @@ -80,7 +84,7 @@ This will generate the file `index.html` that you can open from your favourite b
- Sample list of files from a given directory

```shell
$index_html generate --base-dir=spec/fixtures --exts=rb java --recursive
$index_html --base-dir=spec/fixtures --exts=rb java --recursive
```
The output file `index.html` should be generated with something like

Expand All @@ -105,7 +109,7 @@ The output file `index.html` should be generated with something like
- Run with simple prefix option

```shell
index_html generate --base-dir spec/fixtures --exts rb java --recursive --prefix http://localhost
index_html --base-dir spec/fixtures --exts rb java --recursive --prefix http://localhost
```

The output file `index.html` should be something like
Expand Down
20 changes: 15 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
require 'bundler/gem_tasks'
require "bundler/gem_tasks"
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task default: :spec

task :pry do
require 'pry'
require 'awesome_print'
require 'index_html'
require "pry"
require "awesome_print"
require "index_html"
include IndexHtml
ARGV.clear
Pry.start
end

require "rubocop/rake_task"
desc "Run RuboCop on the lib directory"
Rubocop::RakeTask.new(:rubocop) do |task|
task.patterns = ["lib/**/*.rb"]
# only show the files with failures
task.formatters = ["files"]
# don't abort rake on failure
task.fail_on_error = false
end
10 changes: 7 additions & 3 deletions bin/index_html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env ruby
require 'code_lister'
require_relative '../lib/index_html'
require "code_lister"
require_relative "../lib/index_html"
include IndexHtml
IndexHtml::CLI.start(ARGV)
if ARGV.empty?
IndexHtml::CLI.start(%w[usage])
else
IndexHtml::CLI.start(%w[generate].concat(ARGV))
end
48 changes: 24 additions & 24 deletions index_html.gemspec
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'index_html/version'
require "index_html/version"

Gem::Specification.new do |spec|
spec.name = 'index_html'
spec.name = "index_html"
spec.version = IndexHtml::VERSION
spec.authors = ['Burin Choomnuan']
spec.email = ['agilecreativity@gmail.com']
spec.description = %q{Generate the index.html from list of files}
spec.summary = %q{Generate simple index.html from list of files based on simple criteria}
spec.homepage = 'https://github.com/agilecreativity/index_html'
spec.license = 'MIT'
spec.files = Dir.glob('{bin,lib}/**/*') + %w(Gemfile
spec.authors = ["Burin Choomnuan"]
spec.email = ["agilecreativity@gmail.com"]
spec.description = %q(Generate the index.html from list of files)
spec.summary = %q(Generate simple index.html from list of files based on simple criteria)
spec.homepage = "https://github.com/agilecreativity/index_html"
spec.license = "MIT"
spec.files = Dir.glob("{bin,lib}/**/*") + %w[Gemfile
Rakefile
index_html.gemspec
README.md
CHANGELOGS.md
LICENSE
.rubocop.yml
.gitignore
rubocop-todo.yml)
.gitignore]
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.add_runtime_dependency 'thor', '~> 0.19'
spec.add_runtime_dependency 'agile_utils', '~> 0.1'
spec.add_runtime_dependency 'code_lister', '~> 0.1'
spec.add_development_dependency 'awesome_print', '~> 1.2'
spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'fuubar', '~> 1.3'
spec.add_development_dependency 'guard-rspec', '~> 4.2'
spec.add_development_dependency 'pry', '~> 0.9'
spec.add_development_dependency 'rake', '~> 10.3'
spec.add_development_dependency 'rspec', '~> 2.14'
spec.add_development_dependency 'rubocop', '~> 0.20'
spec.require_paths = ["lib"]
spec.add_runtime_dependency "thor", "~> 0.19"
spec.add_runtime_dependency "agile_utils", "~> 0.1"
spec.add_runtime_dependency "code_lister", "~> 0.1"
spec.add_development_dependency "awesome_print", "~> 1.2"
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "fuubar", "~> 1.3"
spec.add_development_dependency "guard-rspec", "~> 4.2"
spec.add_development_dependency "pry", "~> 0.9"
spec.add_development_dependency "rake", "~> 10.3"
spec.add_development_dependency "rspec", "~> 2.14"
spec.add_development_dependency "rubocop", "~> 0.20"
spec.add_development_dependency "coveralls", "~> 0.7"
end
26 changes: 13 additions & 13 deletions lib/index_html.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
require 'uri'
require 'code_lister'
require_relative './index_html/version'
require_relative './index_html/cli'
require "uri"
require "code_lister"
require_relative "./index_html/version"
require_relative "./index_html/cli"
module IndexHtml
CustomError = Class.new(StandardError)
class << self
# Create html links to list of files
def htmlify(file_list, args = {})
header = <<-END.gsub(/^\s+\|/, '')
header = <<-END.gsub(/^\s+\|/, "")
|<html>
|<title>File Listing</title>
|<header>File List</header>
| <body>
| <ol>
END

footer = <<-END.gsub(/^\s+\|/, '')
footer = <<-END.gsub(/^\s+\|/, "")
| </ol>
| </body>
|</html>
END

prefix = args.fetch(:prefix, '.')
prefix = args.fetch(:prefix, ".")
indent = args.fetch(:indent, 6)
output = args.fetch(:output, 'index.html')
output = args.fetch(:output, "index.html")

File.open(output, 'w') do |f|
File.open(output, "w") do |f|
f.write(header)
links = make_links file_list, prefix: prefix, base_dir: args[:base_dir]
links.each { |i| f.write("#{' ' * indent}#{i}\n") }
links.each { |i| f.write("#{" " * indent}#{i}\n") }
f.write(footer)
end
end
Expand Down Expand Up @@ -58,15 +58,15 @@ def escape_uris!(file_list, args = {})
#
# @return [Array<String>] the list of valid <li> tags
def make_links(file_list, args)
prefix = args.fetch(:prefix, '.')
prefix = args.fetch(:prefix, ".")
result = []

file_list.each do |i|
path = File.absolute_path(i).gsub(Dir.pwd, '')
path = File.absolute_path(i).gsub(Dir.pwd, "")
if prefix
link = %Q(<li><a href="#{prefix}#{path}" target='_blank'>#{prefix}#{path}</li>)
else
link = %Q(<li><a href=".#{path}" target='_blank'>#{path.gsub(/^\//, '')}</li>)
link = %Q(<li><a href=".#{path}" target='_blank'>#{path.gsub(/^\//, "")}</li>)
end
result << link
end
Expand Down

0 comments on commit 2ba0b76

Please sign in to comment.