bookmarkeron 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 784d63cb0ed2d7f91f20244369ac6e8e36ea764b
4
+ data.tar.gz: 6599bd23ab9ebdc226bd39fbfebe3bc472864b1b
5
+ SHA512:
6
+ metadata.gz: 3aff5f9e9571905f9d99e3530d3e5f666fb883c7184729b92c25938ffd31d7c721d1421bb7658df3709b748b9974f4d2277797326022de573b34c993a7ab61c2
7
+ data.tar.gz: d5c1e5465f4e630c70bb306113666b008903fc1687c9fc82b8c428c8e0f4f6369c8895b23f24f1625e8e83454ad0c5294fc55a9945f33c9634013d0ce4b23039
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bookmarkeron.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 rukednous
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Bookmarkeron
2
+
3
+ Sometimes it's helpful to have project-specific bookmarks when you're developing a web application. For example:
4
+
5
+ documentation
6
+ a javascript snippet to log in as a test user
7
+ your jasmine server
8
+ your CI server
9
+
10
+ but it's kind of a pain to version control shortcuts directly. Bookmarkeron lets you declare bookmarks as yaml:
11
+
12
+ bookmarks.yml:
13
+ ```
14
+ bookmarks:
15
+ -
16
+ url: "http://www.google.com"
17
+ name: "cheese"
18
+ -
19
+ url: "http://www.instapaper.com/u"
20
+ name: "schnoodle"
21
+ ```
22
+
23
+ ...which you can then merge into your Chrome bookmarks like so:
24
+
25
+ bkmk bookmarks.yml
26
+
27
+ this massages the .json file Chrome uses to store your bookmarks. It merges the bookmarks from the .yml file into your chrome bookmarks, preserving what you had.
28
+
29
+ It is meant to be idempotent; you can run it multiple times; it will not add a bookmark if it finds an existing bookmark with the same url.
30
+
31
+ It works on my machine.
32
+
33
+ ## Installation
34
+
35
+ Add this line to your application's Gemfile:
36
+
37
+ gem 'bookmarkeron'
38
+
39
+ And then execute:
40
+
41
+ $ bundle
42
+
43
+ Or install it yourself as:
44
+
45
+ $ gem install bookmarkeron
46
+
47
+ ## Usage
48
+
49
+ TODO: Write usage instructions here
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/bkmk ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'bookmarkeron'
7
+
8
+ Bookmarkeron::CLI.run *ARGV
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bookmarkeron/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bookmarkeron"
8
+ spec.version = Bookmarkeron::VERSION
9
+ spec.authors = ["rukednous"]
10
+ spec.email = ["luke.winikates@gmail.com"]
11
+ spec.description = %q{declare bookmarks in a yaml file, merge them into your Chrome bookmarks}
12
+ spec.summary = spec.description
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "awesome_print"
25
+ end
@@ -0,0 +1,7 @@
1
+ require "bookmarkeron/version"
2
+ require "bookmarkeron/merger"
3
+ require "bookmarkeron/cli"
4
+
5
+ module Bookmarkeron
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,8 @@
1
+ module Bookmarkeron
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)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,44 @@
1
+ require 'json'
2
+ require 'yaml'
3
+
4
+ module Bookmarkeron
5
+ CHROME_BOOKMARKS_PATH = File.join(ENV["HOME"], "Library/Application Support/Google/Chrome/Default/Bookmarks")
6
+
7
+ class Merger
8
+ attr_reader :target
9
+
10
+ def initialize(opts = {})
11
+ @target = opts[:target] || CHROME_BOOKMARKS_PATH
12
+ @source = opts[:source]
13
+ end
14
+
15
+ def bookmarks_from_source
16
+ yaml = YAML.load_file @source
17
+ yaml["bookmarks"]
18
+ end
19
+
20
+ def result
21
+ bookmarks = bookmarks_from_target["roots"]["bookmark_bar"]["children"]
22
+ bookmark_next_id = bookmarks_from_source.size
23
+ bookmarks_from_source.each do |bookmark|
24
+ next if bookmarks.find {|existing| existing["url"] == bookmark["url"]}
25
+ bookmarks << bookmark.merge({
26
+ "type"=> "url",
27
+ "date" => "13010285566708500",
28
+ "id" => bookmark_next_id
29
+ })
30
+
31
+ bookmark_next_id = bookmark_next_id + 1
32
+ end
33
+ bookmarks_from_target
34
+ end
35
+
36
+ def result_json
37
+ JSON.pretty_generate result
38
+ end
39
+
40
+ def bookmarks_from_target
41
+ @target_json ||= JSON.parse(File.read(@target))
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module Bookmarkeron
2
+ VERSION = "0.0.1"
3
+ end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module Bookmarkeron
4
+ describe "CLI" do
5
+ it "writes new stuff into the target file" do
6
+ FileUtils.cp fixtures("chrome"), fixtures("cli_test")
7
+
8
+ CLI.run(fixtures("example.yml"), fixtures("cli_test"))
9
+ json = JSON.load(File.read(fixtures("cli_test")))
10
+
11
+ json["roots"]["bookmark_bar"]["children"].size.should == 2
12
+
13
+ FileUtils.rm fixtures("cli_test")
14
+ File.exist?(fixtures("cli_test")).should be_false
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ {
2
+ "checksum": "766e4e46f8c41fb89c4a9d8bcc6597b2",
3
+ "roots": {
4
+ "bookmark_bar": {
5
+ "children": [ {
6
+ "date_added": "12960367845477293",
7
+ "id": "4",
8
+ "name": "Instapaper",
9
+ "type": "url",
10
+ "url": "http://www.instapaper.com/u"
11
+ }],
12
+ "date_added": "11644473600000000",
13
+ "date_modified": "13016260976789146",
14
+ "id": "1",
15
+ "name": "Bookmarks Bar",
16
+ "type": "folder"
17
+ },
18
+ "other": {
19
+ "children": [ ],
20
+ "date_added": "11644473600000000",
21
+ "date_modified": "12973845768093473",
22
+ "id": "2",
23
+ "name": "Other Bookmarks",
24
+ "type": "folder"
25
+ },
26
+ "synced": {
27
+ "children": [ ],
28
+ "date_added": "11644473600000000",
29
+ "date_modified": "0",
30
+ "id": "3",
31
+ "name": "Mobile Bookmarks",
32
+ "type": "folder"
33
+ }
34
+ },
35
+ "version": 1
36
+ }
@@ -0,0 +1,7 @@
1
+ bookmarks:
2
+ -
3
+ url: "http://www.google.com"
4
+ name: "cheese"
5
+ -
6
+ url: "http://www.instapaper.com/u"
7
+ name: "schnoodle"
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ def fixtures(filename)
4
+ File.join(File.dirname(__FILE__), "fixtures", filename)
5
+ end
6
+
7
+ module Bookmarkeron
8
+
9
+ describe Merger do
10
+
11
+ describe "defaults" do
12
+ its(:target) { should == CHROME_BOOKMARKS_PATH }
13
+ end
14
+
15
+ describe "merging urls into the Chrome bookmarks" do
16
+ let(:result) do
17
+ merger = Merger.new({target: fixtures("chrome"), source: fixtures("example.yml")})
18
+ merger.result
19
+ end
20
+
21
+ it "merges" do
22
+ result["roots"]["bookmark_bar"]["children"].find do |bookmark|
23
+ bookmark["url"] == "http://www.google.com"
24
+ bookmark["name"] == "cheese"
25
+ end.should_not be_nil
26
+ end
27
+
28
+ context "when a link with the same url already exists" do
29
+ it "does not add the new bookmark" do
30
+ result["roots"]["bookmark_bar"]["children"].find do |bookmark|
31
+ bookmark["url"] == "http://www.instapaper.com/u"
32
+ bookmark["name"] == "schnoodle"
33
+ end.should be_nil
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ require 'rspec'
2
+ require 'bookmarkeron'
3
+ require 'awesome_print'
4
+
5
+ def fixtures(filename)
6
+ File.join(File.dirname(__FILE__), "fixtures", filename)
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bookmarkeron
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - rukednous
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: declare bookmarks in a yaml file, merge them into your Chrome bookmarks
70
+ email:
71
+ - luke.winikates@gmail.com
72
+ executables:
73
+ - bkmk
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/bkmk
83
+ - bookmarkeron.gemspec
84
+ - lib/bookmarkeron.rb
85
+ - lib/bookmarkeron/cli.rb
86
+ - lib/bookmarkeron/merger.rb
87
+ - lib/bookmarkeron/version.rb
88
+ - spec/cli_spec.rb
89
+ - spec/fixtures/chrome
90
+ - spec/fixtures/example.yml
91
+ - spec/merger_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.0.0
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: declare bookmarks in a yaml file, merge them into your Chrome bookmarks
117
+ test_files:
118
+ - spec/cli_spec.rb
119
+ - spec/fixtures/chrome
120
+ - spec/fixtures/example.yml
121
+ - spec/merger_spec.rb
122
+ - spec/spec_helper.rb
123
+ has_rdoc: