Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
using YAML:Store; version bump v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFnord committed Aug 19, 2015
1 parent be2b2a5 commit 9260cc7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
28 changes: 11 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ GEM
specs:
awesome_print (1.6.1)
blankslate (3.1.3)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
colorize (0.7.7)
diff-lcs (1.2.5)
docile (1.1.5)
ffi (1.9.8)
ffi (1.9.10)
formatador (0.2.5)
gli (2.13.1)
guard (2.12.6)
guard (2.13.0)
formatador (>= 0.2.4)
listen (~> 2.7)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
Expand All @@ -38,23 +36,21 @@ GEM
guard (~> 2.2)
guard-compat (~> 1.1)
guard-compat (1.2.1)
guard-rspec (4.5.2)
guard-rspec (4.6.4)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hitimes (1.2.2)
json (1.8.3)
listen (2.10.0)
celluloid (~> 0.16.0)
listen (3.0.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
method_source (0.8.2)
nenv (0.2.0)
notiffany (0.0.6)
notiffany (0.0.7)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.6.0)
parallel (1.6.1)
parslet (1.7.0)
blankslate (>= 2.0, <= 4.0)
pry (0.10.1)
Expand All @@ -69,12 +65,12 @@ GEM
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
Expand All @@ -87,8 +83,6 @@ GEM
slop (3.6.0)
terminal-notifier-guard (1.6.4)
thor (0.19.1)
timers (4.0.1)
hitimes

PLATFORMS
ruby
Expand All @@ -103,4 +97,4 @@ DEPENDENCIES
terminal-notifier-guard

BUNDLED WITH
1.10.4
1.10.6
1 change: 1 addition & 0 deletions lib/rb_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'parslet'
require 'parslet/convenience'
require 'colorize'
require 'yaml/store'

# internal requirements
require 'rb_tags/version.rb'
Expand Down
15 changes: 10 additions & 5 deletions lib/rb_tags/concerns/yaml_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
module YamlTasks
def read_from_yaml_file dir: nil
YAML.load_file(store(dir)) if File.exist?(store(dir))
# # WRITE
def write_to_yaml(dir: nil, this: {})
db = YAML::Store.new(store(dir), thread_safe: true)
db.transaction { db["tags"] = this }
end

def write_to_yaml dir: nil, this: {}
File.open(store(dir), 'w') {|out| YAML.dump this, out}
# # READ
def read_from_yaml_file(dir: nil)
db = YAML::Store.new(store(dir), thread_safe: true)
db.transaction { db.fetch("tags") }
end

private

def store(dir = nil)
if !!dir
store = File.join(dir,".tags")
else
store = File.join(Dir.getwd,".tags")
end
end
end
end
2 changes: 1 addition & 1 deletion spec/rb_tags/concerns/yaml_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
it { expect(store).to eq File.join('/somewhere',".tags") }
end
end
end
end
4 changes: 1 addition & 3 deletions spec/rb_tags/tags_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
describe Tags do
before(:each) do
# tag_file = File.join(Dir.getwd,'.tags')
# FileUtils.rm(tag_file) if File.exist?(tag_file)
end
end

it { expect(described_class).to eq(Tags) }

Expand Down
2 changes: 1 addition & 1 deletion spec/rb_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ class Foo

end
end
end
end

0 comments on commit 9260cc7

Please sign in to comment.