linknew 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +0 -1
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/Rakefile +18 -4
- data/bin/linknew +27 -11
- data/features/linknew.feature +13 -0
- data/features/step_definitions/linknew_steps.rb +1 -0
- data/features/support/env.rb +18 -0
- data/lib/linknew.rb +8 -3
- data/lib/linknew/database.rb +19 -3
- data/lib/linknew/version.rb +2 -1
- data/linknew.gemspec +8 -2
- data/spec/spec_helper.rb +21 -0
- metadata +83 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36510999112b009ba352a5d2973b854f716f1b16
|
4
|
+
data.tar.gz: b6d6c9c6469533ac8e065b6ceb94dc211f248d17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489226b608ed6671ec8eeb26e5887dc8aaf8904910e60e909acad3800f9d79b2450c1e1070cd02e2b53d21fe9b30a49617031584ab49212572396c16c989ccff
|
7
|
+
data.tar.gz: 4c1b9e2062d52a2caa76e3929148a57baab17bf8767139255e92b50434737315159bcc5a8d65cb4b44a789ba171e4b55ba6c9da4ba5422ae20e6e9ca90ca2f08
|
data/.rubocop.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Metrics/LineLength:
|
2
|
-
Max:
|
2
|
+
Max: 100
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/linknew.png)](http://rubygems.org/gems/linknew)
|
2
2
|
[![Build Status](https://secure.travis-ci.org/voidus/linknew.png?branch=master)](https://travis-ci.org/voidus/linknew)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/voidus/linknew.png)](https://codeclimate.com/github/voidus/linknew)
|
4
|
-
[![Coverage Status](https://
|
4
|
+
[![Coverage Status](https://img.shields.io/coveralls/voidus/linknew.svg)](https://coveralls.io/r/voidus/linknew?branch=master)
|
5
5
|
[![Dependencies](https://gemnasium.com/voidus/linknew.png)](https://gemnasium.com/voidus/linknew)
|
6
6
|
[![Documentation](http://inch-ci.org/github/voidus/linknew.svg?branch=master)](http://inch-ci.org/github/voidus/linknew)
|
7
7
|
[![PullReview stats](https://www.pullreview.com/github/voidus/linknew/badges/master.svg?)](https://www.pullreview.com/github/voidus/linknew/reviews/master)
|
@@ -22,7 +22,7 @@ $ gem install linknew
|
|
22
22
|
|
23
23
|
## Contributing
|
24
24
|
|
25
|
-
1. Fork it ( https://github.com/
|
25
|
+
1. Fork it ( https://github.com/voidus/linknew/fork )
|
26
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
27
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
+
|
2
3
|
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
|
+
task.verbose = false
|
6
|
+
task.rspec_opts = '-w'
|
7
|
+
end
|
5
8
|
|
6
|
-
|
9
|
+
require 'rubocop/rake_task'
|
7
10
|
RuboCop::RakeTask.new { |config| config.fail_on_error = false }
|
11
|
+
|
12
|
+
require 'reek/rake/task'
|
8
13
|
Reek::Rake::Task.new { |config| config.fail_on_error = false }
|
9
14
|
|
10
|
-
task
|
15
|
+
require 'cucumber/rake/task'
|
16
|
+
Cucumber::Rake::Task.new(:features)
|
17
|
+
|
18
|
+
require 'yard'
|
19
|
+
YARD::Rake::YardocTask.new(:doc) do |yard|
|
20
|
+
yard.files = ['bin/**/*.rb', 'lib/**/*.rb']
|
21
|
+
yard.options = ['--readme', 'README.md', '--files', 'CHANGELOG.md,LICENSE.txt']
|
22
|
+
end
|
23
|
+
|
24
|
+
task default: [:spec, :features, :rubocop, :reek]
|
data/bin/linknew
CHANGED
@@ -1,17 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'linknew'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require 'linknew.rb'
|
6
6
|
|
7
|
-
|
7
|
+
# The command-line application for linknew
|
8
|
+
class App
|
9
|
+
include Methadone::Main
|
10
|
+
include Methadone::CLILogging
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
CONFIG_FILE = '.linknew'
|
13
|
+
|
14
|
+
main do # Add args you want: |like,so|
|
15
|
+
# your program code here
|
16
|
+
# You can access CLI options via
|
17
|
+
# the options Hash
|
18
|
+
|
19
|
+
help_now! 'Put a target location in .linknew and run the script' unless File.exist? CONFIG_FILE
|
20
|
+
|
21
|
+
folder = IO.read(CONFIG_FILE).strip
|
22
|
+
help_now! "The folder \"#{folder}\" does not exist" unless File.exist? folder
|
23
|
+
help_now! "The folder \"#{folder}\" is not a directory" unless File.directory? folder
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
abort "The folder \"#{folder}\" is not a directory" unless File.directory? folder
|
25
|
+
Linknew::Linknew.new(folder).execute
|
26
|
+
end
|
16
27
|
|
17
|
-
Linknew::
|
28
|
+
version Linknew::VERSION
|
29
|
+
|
30
|
+
use_log_level_option toggle_debug_on_signal: 'USR1'
|
31
|
+
|
32
|
+
go!
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
2
|
+
In order to get going on coding my awesome app
|
3
|
+
I want to have aruba and cucumber setup
|
4
|
+
So I don't have to do it myself
|
5
|
+
|
6
|
+
Scenario: App just runs
|
7
|
+
When I get help for "linknew"
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the banner should be present
|
10
|
+
And the banner should document that this app takes options
|
11
|
+
And the following options should be documented:
|
12
|
+
|--version|
|
13
|
+
And the banner should document that this app takes no arguments
|
@@ -0,0 +1 @@
|
|
1
|
+
# Put your step definitions here
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'methadone/cucumber'
|
3
|
+
|
4
|
+
binpath = File.expand_path(File.dirname(__FILE__) + '/../../bin')
|
5
|
+
ENV['PATH'] = "#{binpath}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
6
|
+
# extra library dir to use in feature tests
|
7
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib')
|
8
|
+
|
9
|
+
Before do
|
10
|
+
# Using "announce" causes massive warnings on 1.9.2
|
11
|
+
@puts = true
|
12
|
+
@original_rubylib = ENV['RUBYLIB']
|
13
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
After do
|
17
|
+
ENV['RUBYLIB'] = @original_rubylib
|
18
|
+
end
|
data/lib/linknew.rb
CHANGED
@@ -10,6 +10,11 @@ require 'linknew/database'
|
|
10
10
|
module Linknew
|
11
11
|
# The main linknew class
|
12
12
|
class Linknew
|
13
|
+
include Methadone::CLILogging
|
14
|
+
|
15
|
+
# Initializes the applicatioin
|
16
|
+
#
|
17
|
+
# @param folder [String] The name of the folder to which links wil be created
|
13
18
|
def initialize(folder)
|
14
19
|
@folder = folder
|
15
20
|
abort('Target folder does not exist') unless File.exist? folder
|
@@ -17,7 +22,7 @@ module Linknew
|
|
17
22
|
|
18
23
|
# Runs the program
|
19
24
|
def execute
|
20
|
-
|
25
|
+
warn MTIME_WARNING_MESSAGE unless CAN_SET_MTIME
|
21
26
|
|
22
27
|
Database.new do |db|
|
23
28
|
scan_files(db)
|
@@ -27,7 +32,7 @@ module Linknew
|
|
27
32
|
private
|
28
33
|
|
29
34
|
MTIME_WARNING_MESSAGE = 'WARNING: Not running on linux, will not set mtime of symbolic links.'
|
30
|
-
CAN_SET_MTIME = RUBY_PLATFORM =~ /linux/
|
35
|
+
CAN_SET_MTIME = RUBY_PLATFORM =~ /linux/
|
31
36
|
|
32
37
|
def scan_files(db)
|
33
38
|
Dir.foreach(@folder) do |file|
|
@@ -40,7 +45,7 @@ module Linknew
|
|
40
45
|
|
41
46
|
def process_file(file, db)
|
42
47
|
linkname = File.basename(file)
|
43
|
-
|
48
|
+
info "Linking #{linkname}"
|
44
49
|
File.symlink(file, linkname)
|
45
50
|
`touch -h #{linkname.shellescape} -r #{file.shellescape}` if CAN_SET_MTIME
|
46
51
|
db.enter(file)
|
data/lib/linknew/database.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'digest'
|
2
|
+
require 'methadone/cli_logging'
|
2
3
|
|
3
4
|
module Linknew
|
4
5
|
# Encapsules the linknew database
|
5
6
|
class Database
|
7
|
+
include ::Methadone::CLILogging
|
8
|
+
|
9
|
+
# Opens (and possibly creates) the database. If no block is given, ensure that #close is called.
|
10
|
+
#
|
11
|
+
# For a block { |db| ... }
|
12
|
+
# @yield |db| Gives self to the block
|
13
|
+
# @yieldparam db [Database] self
|
6
14
|
def initialize(&block)
|
7
15
|
@db = SQLite3::Database.new '.linknew.db'
|
8
16
|
creates_tables_if_not_exist
|
@@ -16,21 +24,29 @@ module Linknew
|
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
27
|
+
# Closes the connection to the database. The object is invalid after the call.
|
19
28
|
def close
|
20
29
|
@db.close
|
21
30
|
end
|
22
31
|
|
32
|
+
# Checks if the file is in the database
|
33
|
+
#
|
34
|
+
# @param file [String] The file name to check for
|
35
|
+
# @return [Boolean] Whether the file is in the database.
|
23
36
|
def known?(file)
|
24
37
|
hash = Database.filehash(file)
|
25
|
-
|
38
|
+
debug "Querying file #{file} with hash #{hash}"
|
26
39
|
ret = @db.execute(HAS_FILE_STMT, hash)[0][0] == 1
|
27
|
-
|
40
|
+
debug "-> Returning #{ret}"
|
28
41
|
ret
|
29
42
|
end
|
30
43
|
|
44
|
+
# Enters the file in the database
|
45
|
+
#
|
46
|
+
# @param file [String] The filename to enter
|
31
47
|
def enter(file)
|
32
48
|
hash = Database.filehash(file)
|
33
|
-
|
49
|
+
debug "Entering file #{file} with hash #{hash}"
|
34
50
|
@db.execute(ENTER_FILE_STMT, hash)
|
35
51
|
end
|
36
52
|
|
data/lib/linknew/version.rb
CHANGED
data/linknew.gemspec
CHANGED
@@ -22,10 +22,16 @@ HERE
|
|
22
22
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.
|
25
|
+
spec.add_runtime_dependency 'sqlite3', '~> 1.3'
|
26
|
+
spec.add_runtime_dependency 'methadone', '~> 1.5'
|
27
|
+
|
26
28
|
spec.add_development_dependency 'bundler'
|
27
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
30
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
29
31
|
spec.add_development_dependency 'rubocop', '~> 0.27.1'
|
30
|
-
spec.add_development_dependency 'reek'
|
32
|
+
spec.add_development_dependency 'reek', '~> 1.5'
|
33
|
+
spec.add_development_dependency 'cucumber', '~> 1.3'
|
34
|
+
spec.add_development_dependency 'aruba', '~> 0.6'
|
35
|
+
spec.add_development_dependency 'simplecov', '~> 0.9'
|
36
|
+
spec.add_development_dependency 'yard', '~> 0.8'
|
31
37
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,23 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter '/spec/'
|
9
|
+
add_filter '/features/'
|
10
|
+
end
|
11
|
+
|
1
12
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
13
|
+
require 'methadone/cli_logger'
|
14
|
+
require 'methadone/cli_logging'
|
15
|
+
require 'logger'
|
16
|
+
|
17
|
+
Class.new do
|
18
|
+
include Methadone::CLILogging
|
19
|
+
change_logger Methadone::CLILogger.new unless logger
|
20
|
+
logger.level = Logger::ERROR
|
21
|
+
end
|
22
|
+
|
2
23
|
require 'linknew'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linknew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Kohlmeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: methadone
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +98,72 @@ dependencies:
|
|
84
98
|
name: reek
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '1.5'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '1.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: cucumber
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.3'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: aruba
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.6'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.6'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: yard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.8'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.8'
|
97
167
|
description: |
|
98
168
|
Linknew creates links to all files in another directory once.
|
99
169
|
You can use it to keep track of which files in a shared directory you already
|
@@ -116,6 +186,9 @@ files:
|
|
116
186
|
- README.md
|
117
187
|
- Rakefile
|
118
188
|
- bin/linknew
|
189
|
+
- features/linknew.feature
|
190
|
+
- features/step_definitions/linknew_steps.rb
|
191
|
+
- features/support/env.rb
|
119
192
|
- lib/linknew.rb
|
120
193
|
- lib/linknew/database.rb
|
121
194
|
- lib/linknew/version.rb
|
@@ -147,5 +220,9 @@ signing_key:
|
|
147
220
|
specification_version: 4
|
148
221
|
summary: Links to files in a directory once
|
149
222
|
test_files:
|
223
|
+
- features/linknew.feature
|
224
|
+
- features/step_definitions/linknew_steps.rb
|
225
|
+
- features/support/env.rb
|
150
226
|
- spec/linknew_spec.rb
|
151
227
|
- spec/spec_helper.rb
|
228
|
+
has_rdoc:
|