catalog 0.1.2 → 0.2.0

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: fbe2e0974fc3a6ebd971be5c8c6840deaddbf31b
4
- data.tar.gz: e60c2f1e768b51932ab231d34677a6bd847509fb
3
+ metadata.gz: 5c141dfe2ef4460a9a78967dc0a9b8efad223d97
4
+ data.tar.gz: 34dd630c49882b358e7653fc4529fa5a1512f7c1
5
5
  SHA512:
6
- metadata.gz: dde4a5fa55fb32c80911bbbd2d3fed24c6836e1944a9fb6037770d0a60a4ea6d268a64fb136c9d2856f88435361e1901a22cb37f88a44beb4cb8b2909e42cd77
7
- data.tar.gz: ad3d8eb200633a8b296c10eaabf71faeab7cadb4985f95e7f8867b162fe4bd058f31ac6e8979babbe45dfaf8d1cbff975db6d67848936e2acb6c64057b2d1b7e
6
+ metadata.gz: c59b050ceeac37790a6d6e0e43441e48e27f66721c6914f01a5c70808583dd1dc9f0f7c1a067e051cc07c9c37a85ab5cbc16e650770c953a90268ec7407b0d01
7
+ data.tar.gz: 6a1d4694cc3890779d40a714e31c1d9817fe1261b0d72e0563e9824057adabe7f9645b934f29c690bf10f9d143697b322071790eb7a1b944c0df0f8e203b096a
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Catalog
2
- *Catalog prevents your download folder from being a mess on Mac Os X.*
2
+ *Catalog prevents your download folder from being a mess on your Mac.*
3
3
 
4
4
  ## The problem
5
5
 
6
- The *Downloads* folder on a Mac is the most clusttered folder there is. Even with the best intentions, we end up not cleaning it as often as we should.
6
+ The *Downloads* folder on a Mac is the most cluttered folder there is. Even with the best intentions, we end up not cleaning it as often as we should.
7
7
 
8
- *Catalog* allow us to create rules to automatically organize your downloads based on its origin (*i.e. http://someurl.com/path/to/file.pdf*).
8
+ *Catalog* allow us to create rules to automatically organize your downloads based on their origin (*i.e. http://someurl.com/path/to/file.pdf*).
9
9
 
10
10
  ## Installation
11
11
 
@@ -19,7 +19,7 @@ $ touch ~/.catalog
19
19
 
20
20
  ## State of project
21
21
 
22
- The current version **doesn't include a CLI**. You'll have to use it through IRB as you can see in the [How to use](#how-to-use) section. The next step will be to provide a CLI using guard and a way to easily deamonize this.
22
+ The current version **doesn't include a CLI**. You'll have to use it through IRB as you can see in the [How to use](#how-to-use) section. The next step will be to provide a CLI and a way to easily deamonize this.
23
23
 
24
24
  ## How to use
25
25
 
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w(.. lib))
3
+
4
+ require 'catalog'
5
+
6
+ Catalog::CLI.new(ARGV).run
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
18
  spec.require_paths = ['lib']
18
19
 
19
20
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -1,10 +1,14 @@
1
1
  require 'yaml'
2
2
  require 'shellwords'
3
+ require 'optparse'
3
4
 
4
5
  # Core
5
6
  require 'catalog/organizer'
6
7
  require 'catalog/config'
7
8
 
9
+ # CLI
10
+ require 'catalog/cli'
11
+
8
12
  # Models
9
13
  require 'catalog/models/document'
10
14
  require 'catalog/models/drawer'
@@ -0,0 +1,23 @@
1
+ module Catalog
2
+ class CLI
3
+ def initialize(args)
4
+ @args = args
5
+ @options = {}
6
+
7
+ parser = OptionParser.new do |opts|
8
+ opts.on('-p', '--path PATH', 'Path of the folder to clean') { |path| @options[:path] = path }
9
+ opts.on('-c', '--config PATH', 'Path of your .catalog file') { |path| @options[:config] = path }
10
+ end
11
+
12
+ parser.parse!(args)
13
+ end
14
+
15
+ def run
16
+ # Override .catalog.yml file location
17
+ Catalog::Config.config_path(@options[:config]) if @options[:config]
18
+
19
+ # Run to organizer
20
+ Catalog::Organizer.new(base_path: @options[:path]).run!
21
+ end
22
+ end
23
+ end
@@ -4,11 +4,21 @@ module Catalog
4
4
  config['drawers']
5
5
  end
6
6
 
7
+ def self.config_path(path = nil)
8
+ if path
9
+ @config_path
10
+ else
11
+ @config_path = path
12
+ end
13
+
14
+ File.expand_path(@config_path || '~/.catalog.yml')
15
+ end
16
+
7
17
  private
8
18
 
9
19
  def self.config
10
20
  unless @config
11
- raw_content = File.read(File.expand_path('~/.catalog.yml'))
21
+ raw_content = File.read(config_path)
12
22
  @config = YAML.load(raw_content)
13
23
  end
14
24
 
@@ -1,7 +1,7 @@
1
1
  module Catalog
2
2
  class Organizer
3
3
  def initialize(base_path: nil)
4
- @base_path = base_path || '~/Downloads/*'
4
+ @base_path = base_path ? "#{base_path}/*" : '~/Downloads/*'
5
5
  end
6
6
 
7
7
  def run!
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Catalog
2
4
  class DocumentMover
3
5
  def initialize(document:, drawer:)
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Catalog
2
4
  class DrawerMatcher
3
5
  # Accessors
@@ -1,3 +1,3 @@
1
1
  module Catalog
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garneau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: Catalog prevents your download folder from being a mess on Mac Os X.
56
56
  email:
57
57
  - sam@garno.me
58
- executables: []
58
+ executables:
59
+ - catalog
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -64,8 +65,10 @@ files:
64
65
  - Gemfile.lock
65
66
  - LICENSE.md
66
67
  - README.md
68
+ - bin/catalog
67
69
  - catalog.gemspec
68
70
  - lib/catalog.rb
71
+ - lib/catalog/cli.rb
69
72
  - lib/catalog/config.rb
70
73
  - lib/catalog/errors/configuration_missing.rb
71
74
  - lib/catalog/models/document.rb