KindleCG 0.0.1 → 0.0.2

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: 5d1d82944b95dbf3604090ecdb82aec451a30964
4
- data.tar.gz: 31029f6e48a1b38bc5761284182d30da4d9852c8
3
+ metadata.gz: 5dba61c07d74148ab1a3b0d9b004625423cf4831
4
+ data.tar.gz: a72e227abaff49aff4b0a11d0237ce753f9229c6
5
5
  SHA512:
6
- metadata.gz: 6b6b16eec0216586da49de7dc723956d85a83b73074c3af122d79b95eb7f8d606a1207f6f64abfdca240b9af071937098520375b4473a75ab95f8bd419943c10
7
- data.tar.gz: 5baa89ab6bddcc950ef128395b64f4894b31fd6dce1916c54dfad6e06529824109dcbff9c092c02af32ff540c3512e911ba5c2dfe6d5390978f2da0b22428bbb
6
+ metadata.gz: 0c7c270658600bb6d58fd702640ef8b40d8ca7095ee4209a4bd94367b62f7cfe7535af39611c1d10c6075d95fe8e389e9ce8efb865eaaa724b7db1e3d3dcc7b3
7
+ data.tar.gz: ad693afa420cb751c2a2be31d9ea7de1ecf7fa7fa077e8cba3d2f18b2df26eadd70d479f807dc8143824ac438625de9e91120780e54244d76440ceed0b4dab8e
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
  ## Directory Tree to Kindle Collections generator
3
3
 
4
4
  A command line ruby script that will generate collections in your kindle based on the directory structure of your ebooks.
5
- The library to understand the mobi format are a straight port/refactor of the python plugin for calibre.
6
5
 
7
6
  ## Installation
8
7
 
@@ -10,10 +9,19 @@ The library to understand the mobi format are a straight port/refactor of the py
10
9
 
11
10
  ## Usage
12
11
 
13
- After installing the gem you will have access to a command line tool kindlecg.
14
- Just run it and will generate collections based on the directory structure of your ebooks in your kindle device.
12
+ After installing the gem you will have access to the command line tool **kindlecg**.
15
13
 
16
- *WARNING* The script is under development. It override your current collections!!!
14
+ The kindlecg has just two commands available:
15
+ kindlecg check # check if a kindle is attached to the computer
16
+ kindlecg generate # generate and save the collections
17
+
18
+ Just run the kindlecg without any option to show the help.
19
+
20
+ By default, the commands assume that you are on a mac and the kindle mountpoint is /Volumes/Kindle but you can change that passing
21
+ the option *-m* followed by the mountpoint of the kindle on your computer.
22
+
23
+ The script override your kindle collections but can take a backup that you can manually restore if you pass the *-b* option.
24
+ The .bak file will be saved in your kindle device in the system folder.
17
25
 
18
26
  ## Contributing
19
27
 
data/lib/KindleCG/cli.rb CHANGED
@@ -3,22 +3,37 @@ require 'KindleCG'
3
3
 
4
4
  module KindleCG
5
5
  class CLI < Thor
6
+ method_option :mountpoint, type: :string, aliases: "-m",
7
+ desc: "specify a different mountpoint for the kindle device"
8
+ method_option :backup, type: :boolean, aliases: "-b",
9
+ desc: "take a backup of the collections before overriding it"
6
10
  desc 'generate', 'generate and save the collections'
7
11
  def generate
12
+ if options[:mountpoint]
13
+ KindleCG.os_mountpoint = options[:mountpoint]
14
+ end
15
+
8
16
  check
9
17
 
10
18
  kindle = Generator.new
11
19
  kindle.generate_collections
20
+ if options[:backup]
21
+ kindle.backup
22
+ end
12
23
  kindle.save
13
24
  end
14
25
 
26
+ method_option :mountpoint, type: :string, aliases: "-m",
27
+ desc: "specify a different mountpoint for the kindle device"
15
28
  desc 'check', 'check if a kindle is attached to the computer'
16
29
  def check
17
- unless File.directory?(KindleCG.os_mountpoint)
18
- raise Thor::Error, "Could not find any kindle attached to #{KindleCG.os_mountpoint}"
30
+ mountpoint = options[:mountpoint] || KindleCG.os_mountpoint
31
+
32
+ unless File.directory?(mountpoint)
33
+ raise Thor::Error, "Could not find any kindle attached to #{mountpoint}"
19
34
  exit 1
20
35
  else
21
- say "Your kindle is attached to #{KindleCG.os_mountpoint}. Very good! :)", :green
36
+ say "Your kindle is attached to #{mountpoint}. Very good! :)", :green
22
37
  end
23
38
  end
24
39
  end
@@ -1,3 +1,3 @@
1
1
  module KindleCG
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/KindleCG.rb CHANGED
@@ -63,6 +63,10 @@ module KindleCG
63
63
  end
64
64
  end
65
65
 
66
+ def backup
67
+ FileUtils.cp(KindleCG.os_collections_path, [KindleCG.os_collections_path, 'bak'].join('.'), {preserve: false})
68
+ end
69
+
66
70
  def save
67
71
  IO.write(KindleCG.os_collections_path, @collections.to_json)
68
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: KindleCG
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Lorusso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-08 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor