simple_note_parser 0.1.0

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
+ SHA256:
3
+ metadata.gz: 5579e486ec6aa019af93b40189887cf9a73283abd4cb6428c0fb084417b0ab53
4
+ data.tar.gz: fcf8bb176f8d4bb830e97c95a6110d400c39a0b4d9b017e1100833ce024f3661
5
+ SHA512:
6
+ metadata.gz: dbeaa7b2b31b0197865bb5e3710933d6871b2423517763611d06af45df0be7b699d6a5e5ca7df10dd2c618f2740286ce79b19edcd87bcca144dfaaa14167423f
7
+ data.tar.gz: 7c2ec7b318765aac4b4d5287c18e77621e39ce019e5d65cc1ffbdac05aa103453e51c0b75697af6a996a8769af044b21a3d8385edb4283cc503f3a900aefe6aa
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in simple_note_parser.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simple_note_parser (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.14.0)
10
+ rake (12.3.2)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ minitest (~> 5.0)
17
+ rake (~> 12.0)
18
+ simple_note_parser!
19
+
20
+ BUNDLED WITH
21
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Steve Polito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # SimpleNoteParser
2
+
3
+ Organizes exported [Simplenote](https://app.simplenote.com/) data into directories based on the note's tag.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simple_note_parser'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simple_note_parser
20
+
21
+ ## Usage
22
+
23
+ 1. Export data from [Simplenote](https://simplenote.com/help/#export).
24
+ 1. Unzip the file.
25
+ 1. Open a new terminal window and change directories by navigating into the unzipped directory.
26
+ 1. Run `gem install simple_note_parser`
27
+ 1. Run `bin/console`. When the prompt opens, run the following:
28
+
29
+ ```ruby
30
+ @notes = SimpleNoteParser.new
31
+ @notes.import
32
+ ```
33
+
34
+ This will create a directory called `organized-by-tag` in the current directory containing directories based on each note's tag.
35
+
36
+ 1. Optionally run `@notes.import` to recursively remove the `organized-by-tag` directory.
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/stevepolitodesign/simple_note_parser.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simple_note_parser"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ class SimpleNoteParser
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,60 @@
1
+ require "simple_note_parser/version"
2
+ require "json"
3
+ require "fileutils"
4
+ class SimpleNoteParser
5
+ attr_accessor :file, :destination
6
+
7
+ def initialize(file = "./source/notes.json", destination = "./organized-by-tag")
8
+ @file = file
9
+ @destination = destination
10
+ end
11
+
12
+ def clean
13
+ FileUtils.rm_rf(destination)
14
+ end
15
+
16
+ def import
17
+ json_data = load_json_data(file)
18
+ notes = parse_json_data(json_data)
19
+ process_notes(notes)
20
+ end
21
+
22
+ private
23
+
24
+ def load_json_data(path)
25
+ file = File.open path
26
+ json_data = JSON.load file
27
+ end
28
+
29
+ def parse_json_data(json_data)
30
+ notes = json_data["activeNotes"]
31
+ end
32
+
33
+ def process_notes(notes)
34
+ notes.each do |note|
35
+ tags = note["tags"]
36
+ if tags.nil? || tags.empty?
37
+ path = "#{destination}/no-tags"
38
+ create_directory(path)
39
+ create_file(path, note)
40
+ else
41
+ tags.each do |tag|
42
+ path = "#{destination}/#{tag.downcase}"
43
+ create_directory(path)
44
+ create_file(path, note)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def create_directory(path)
51
+ FileUtils.mkdir_p(path) unless Dir.exist?(path)
52
+ end
53
+
54
+ def create_file(path, note)
55
+ first_line = note["content"].split("\r").first
56
+ name = first_line.downcase.strip.tr(" ", "-").gsub(/[^\w-]/, "")
57
+ content = note["content"]
58
+ File.open("#{path}/#{name}.txt", "w") { |f| f.write content }
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'lib/simple_note_parser/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "simple_note_parser"
5
+ spec.version = SimpleNoteParser::VERSION
6
+ spec.authors = ["Steve Polito"]
7
+ spec.email = ["info@stevepolitodesign.com"]
8
+
9
+ spec.summary = %q{Parse notes from Simplenote}
10
+ spec.description = %q{Organizes exported Simplenote data into directories based on the note's tag.}
11
+ spec.homepage = "https://github.com/stevepolitodesign/simple_note_parser"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/stevepolitodesign/simple_note_parser"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_note_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Polito
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Organizes exported Simplenote data into directories based on the note's
14
+ tag.
15
+ email:
16
+ - info@stevepolitodesign.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".travis.yml"
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - lib/simple_note_parser.rb
31
+ - lib/simple_note_parser/version.rb
32
+ - simple_note_parser.gemspec
33
+ homepage: https://github.com/stevepolitodesign/simple_note_parser
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ allowed_push_host: https://rubygems.org/
38
+ homepage_uri: https://github.com/stevepolitodesign/simple_note_parser
39
+ source_code_uri: https://github.com/stevepolitodesign/simple_note_parser
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.3.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.8
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Parse notes from Simplenote
59
+ test_files: []