bookmarkeron 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: 784d63cb0ed2d7f91f20244369ac6e8e36ea764b
4
- data.tar.gz: 6599bd23ab9ebdc226bd39fbfebe3bc472864b1b
3
+ metadata.gz: d9ee5571f36d79a3a7451289524def9f16ab3c60
4
+ data.tar.gz: abbdc83a873df2b78f21b9a95368c4948e3aae75
5
5
  SHA512:
6
- metadata.gz: 3aff5f9e9571905f9d99e3530d3e5f666fb883c7184729b92c25938ffd31d7c721d1421bb7658df3709b748b9974f4d2277797326022de573b34c993a7ab61c2
7
- data.tar.gz: d5c1e5465f4e630c70bb306113666b008903fc1687c9fc82b8c428c8e0f4f6369c8895b23f24f1625e8e83454ad0c5294fc55a9945f33c9634013d0ce4b23039
6
+ metadata.gz: 0ebfe6594730fb0eeea3f29e9b6530bb56459cca73e94379456124c6fc47cf03ee6ecfaf8ed08407552e3dd61f85f8c34e4fc97e84a74c9eb501465a3d93fe4e
7
+ data.tar.gz: b95096a1973f1bdf160ed8e38cd3a08f74e216dfb0a96d9af8b63a790a77fee5978a8a245b796cad67a7e45dc145a1e25906debbab7a287b1ea152cffba73ffb
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.2
2
+ Add globbing, so that we merge bookmarks into profiles other than the default
3
+ profile, and don't crash if the Default profile is absent.
data/bookmarkeron.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "fakefs"
23
24
  spec.add_development_dependency "rspec"
24
25
  spec.add_development_dependency "awesome_print"
25
26
  end
data/lib/bookmarkeron.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bookmarkeron/version"
2
+ require "bookmarkeron/finder"
2
3
  require "bookmarkeron/merger"
3
4
  require "bookmarkeron/cli"
4
5
 
5
6
  module Bookmarkeron
6
- # Your code goes here...
7
7
  end
@@ -1,8 +1,18 @@
1
1
  module Bookmarkeron
2
2
  class CLI
3
- def self.run(source, dest = CHROME_BOOKMARKS_PATH)
4
- merger = Merger.new({source: source, target: dest})
5
- File.write(dest, merger.result_json)
3
+ def self.run(source, destination = nil)
4
+ if destination
5
+ dests = [destination]
6
+ else
7
+ dests = Finder.find
8
+ end
9
+ dests.each do |dest|
10
+ puts "merging bookmarks into #{dest}"
11
+ merger = Merger.new({source: source, target: dest})
12
+ File.write(dest, merger.result_json)
13
+ end
14
+
15
+ puts "#{dests.size} profiles updated"
6
16
  end
7
17
  end
8
18
  end
@@ -0,0 +1,9 @@
1
+ module Bookmarkeron
2
+ class Finder
3
+ class << self
4
+ def find
5
+ Dir.glob("#{ENV['HOME']}/Library/Application Support/Google/Chrome/**/Bookmarks")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Bookmarkeron
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Bookmarkeron
4
- describe "CLI" do
4
+ describe CLI do
5
+
5
6
  it "writes new stuff into the target file" do
6
7
  FileUtils.cp fixtures("chrome"), fixtures("cli_test")
7
8
 
@@ -13,5 +14,20 @@ module Bookmarkeron
13
14
  FileUtils.rm fixtures("cli_test")
14
15
  File.exist?(fixtures("cli_test")).should be_false
15
16
  end
17
+
18
+ describe "with no target" do
19
+ it "finds all Bookmark files in the chrome directory and runs on those" do
20
+ fake_merger = double(:merger, allow: true)
21
+ Finder.should_receive(:find).and_return(["a", "b"])
22
+ Merger.should_receive(:new).with(hash_including(target: "a")).and_return(fake_merger)
23
+ Merger.should_receive(:new).with(hash_including(target: "b")).and_return(fake_merger)
24
+ fake_merger.should_receive(:result_json).twice
25
+ File.should_receive(:write).twice
26
+
27
+ CLI.run(fixtures("example.yml"))
28
+
29
+ # use this:find ~/Library/Application\ Support/Google/Chrome -name Bookmarks
30
+ end
31
+ end
16
32
  end
17
33
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module Bookmarkeron
4
+ describe Finder do
5
+ include FakeFS::SpecHelpers
6
+
7
+ xit "finds all the Bookmark files on the file system" do
8
+ root = File.join(ENV["HOME"], "Library", "Application Support", "Chrome")
9
+ profiles = ["A", "Bee", "see"]
10
+ bookmark_files = []
11
+
12
+ profiles.map do |p|
13
+ FileUtils.mkdir_p File.join(root, p)
14
+ bookmark_file = File.join(root, p, 'Bookmarks')
15
+ bookmark_files << bookmark_file
16
+ nonsense_file = File.join(root, p, 'Sandwich')
17
+ FileUtils.touch bookmark_file
18
+ FileUtils.touch nonsense_file
19
+ end
20
+
21
+ Finder.find.should == bookmark_files
22
+ end
23
+ end
24
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rspec'
2
+ require 'rspec/mocks'
2
3
  require 'bookmarkeron'
3
4
  require 'awesome_print'
5
+ require 'fakefs/spec_helpers'
4
6
 
5
7
  def fixtures(filename)
6
8
  File.join(File.dirname(__FILE__), "fixtures", filename)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookmarkeron
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
  - rukednous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-17 00:00:00.000000000 Z
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fakefs
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +89,7 @@ extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
91
  - .gitignore
92
+ - CHANGELOG
78
93
  - Gemfile
79
94
  - LICENSE.txt
80
95
  - README.md
@@ -83,9 +98,11 @@ files:
83
98
  - bookmarkeron.gemspec
84
99
  - lib/bookmarkeron.rb
85
100
  - lib/bookmarkeron/cli.rb
101
+ - lib/bookmarkeron/finder.rb
86
102
  - lib/bookmarkeron/merger.rb
87
103
  - lib/bookmarkeron/version.rb
88
104
  - spec/cli_spec.rb
105
+ - spec/finder_spec.rb
89
106
  - spec/fixtures/chrome
90
107
  - spec/fixtures/example.yml
91
108
  - spec/merger_spec.rb
@@ -116,6 +133,7 @@ specification_version: 4
116
133
  summary: declare bookmarks in a yaml file, merge them into your Chrome bookmarks
117
134
  test_files:
118
135
  - spec/cli_spec.rb
136
+ - spec/finder_spec.rb
119
137
  - spec/fixtures/chrome
120
138
  - spec/fixtures/example.yml
121
139
  - spec/merger_spec.rb