annal 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
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
18
+ .DS_Store
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ rvm gemset use ${PWD##*/}
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in annal.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sam Schenkman-Moore
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.
@@ -0,0 +1,29 @@
1
+ # Annal
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'annal'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install annal
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,28 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ namespace 'test' do
6
+ test_files = FileList['test/**/*_test.rb']
7
+ integration_test_files = FileList['test/**/*_integration_test.rb']
8
+ unit_test_files = test_files - integration_test_files
9
+
10
+ desc "Run unit tests"
11
+ Rake::TestTask.new('unit') do |t|
12
+ t.libs.push "lib"
13
+ t.test_files = unit_test_files
14
+ t.verbose = false
15
+ end
16
+
17
+ desc "Run integration tests"
18
+ Rake::TestTask.new('integration') do |t|
19
+ t.libs.push "lib"
20
+ t.test_files = integration_test_files
21
+ t.verbose = false
22
+ end
23
+ end
24
+
25
+ #Rake::Task['test'].clear
26
+ desc "Run all tests"
27
+ task 'test' => %w[test:unit test:integration]
28
+ task 'default' => 'test'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'annal/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "annal"
8
+ gem.version = Annal::VERSION
9
+ gem.authors = ["Sam Schenkman-Moore"]
10
+ gem.email = ["samsm@samsm.com"]
11
+ gem.description = %q{Loads up files. Parses YAML/JSON and other stuff maybe.}
12
+ gem.summary = %q{A wrapper for text files.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "activesupport"
21
+
22
+ gem.add_development_dependency "minitest"
23
+ gem.add_development_dependency "rake"
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ require "annal/version"
2
+ require 'annal/parse'
3
+ require 'annal/fetch'
4
+ require 'annal/document'
5
+
6
+ module Annal
7
+ def self.root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ def self.project_root
12
+ File.expand_path(File.join(root, '..'))
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support/concern'
2
+
3
+ module Annal
4
+ class Document
5
+ def self.find(path)
6
+ fetch = Fetch.new(path)
7
+ new(fetch)
8
+ end
9
+
10
+ attr_accessor :raw_string, :fetch
11
+
12
+ def initialize(file_or_str)
13
+ if file_or_str.respond_to?(:read)
14
+ self.fetch = file_or_str
15
+ else
16
+ self.raw_string = file_or_str
17
+ end
18
+ end
19
+
20
+ def text
21
+ fetch && fetch.read or
22
+ raw_string
23
+ end
24
+
25
+ def parse
26
+ Parse.new(text)
27
+ end
28
+
29
+ def data
30
+ parse.data
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ module Annal
2
+ class Fetch
3
+ attr_accessor :path, :file
4
+ def initialize(file_identifier)
5
+ self.file = if file_identifier.respond_to?(:read)
6
+ file_identifier
7
+ else
8
+ File.open(file_identifier)
9
+ end
10
+ end
11
+
12
+ def local?
13
+ true
14
+ end
15
+
16
+ def read
17
+ @read ||= file.read
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'yaml'
2
+
3
+ module Annal
4
+ class Parse
5
+ attr_accessor :raw_data
6
+ def initialize(raw_data)
7
+ self.raw_data = raw_data
8
+ end
9
+
10
+ def data
11
+ parse_yaml
12
+ end
13
+
14
+ # Also parses JSON
15
+ def parse_yaml
16
+ YAML.load(raw_data)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Annal
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'minitest_helper'
2
+
3
+ class TestAnnalIntegration < MiniTest::Unit::TestCase
4
+
5
+ def test_loading_json
6
+ doc = Annal::Document.new(json_text)
7
+ assert_kind_of Hash, doc.data
8
+ end
9
+
10
+ def test_loading_yaml
11
+ doc = Annal::Document.new(yaml_text)
12
+ assert_kind_of Hash, doc.data
13
+ end
14
+
15
+ def test_find
16
+ doc = Annal::Document.find("#{Annal.project_root}/test/test.json")
17
+ assert_kind_of Hash, doc.data
18
+ assert_kind_of Hash, doc.data
19
+ end
20
+
21
+ end
@@ -0,0 +1,12 @@
1
+ require_relative 'minitest_helper'
2
+
3
+ class TestAnnal < MiniTest::Unit::TestCase
4
+ def setup
5
+ # @meme = Meme.new
6
+ end
7
+
8
+ def test_that_kitty_can_eat
9
+ assert_kind_of Module, Annal
10
+ end
11
+
12
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'minitest_helper'
2
+
3
+ class TestFetchIntegration < MiniTest::Unit::TestCase
4
+
5
+ def test_fetch
6
+ read = Annal::Fetch.new("#{Annal.project_root}/test/test.json").read
7
+ assert_match 'development_environment', read
8
+ end
9
+
10
+ def test_double_read
11
+ fetch = Annal::Fetch.new("#{Annal.project_root}/test/test.json")
12
+ assert_match 'development_environment', fetch.read
13
+ assert_match 'development_environment', fetch.read
14
+ end
15
+
16
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ gem 'minitest' # ensures you're using the gem, and not the built in MT
3
+ require 'minitest/autorun'
4
+ require 'minitest/unit'
5
+ require 'minitest/mock'
6
+
7
+ require 'annal'
8
+
9
+ def json_text
10
+ IO.read("#{Annal.project_root}/test/test.json")
11
+ end
12
+
13
+ def yaml_text
14
+ IO.read("#{Annal.project_root}/test/test.yml")
15
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'minitest_helper'
2
+
3
+ class TestParseIntegration < MiniTest::Unit::TestCase
4
+
5
+ def test_parsing_json
6
+ data = Annal::Parse.new(json_text).data
7
+ assert_kind_of Hash, data
8
+ end
9
+
10
+ def test_parsing_yaml
11
+ data = Annal::Parse.new(yaml_text).data
12
+ assert_kind_of Hash, data
13
+ end
14
+
15
+ def test_parsing_text
16
+ data = Annal::Parse.new('Hi there. No format here.').data
17
+ assert_kind_of String, data
18
+ end
19
+
20
+ def test_double_parsing
21
+ parse = Annal::Parse.new(json_text)
22
+ assert_kind_of Hash, parse.data
23
+ assert_kind_of Hash, parse.data
24
+ end
25
+
26
+ end
@@ -0,0 +1,22 @@
1
+ {
2
+ "command": "ruby -rubygems -rzeus/rails -eZeus.go",
3
+
4
+ "plan": {
5
+ "boot": {
6
+ "default_bundle": {
7
+ "development_environment": {
8
+ "prerake": {"rake": []},
9
+ "runner": ["r"],
10
+ "console": ["c"],
11
+ "server": ["s"],
12
+ "generate": ["g"],
13
+ "dbconsole": []
14
+ },
15
+ "test_environment": {
16
+ "cucumber_environment": {"cucumber": []},
17
+ "test_helper": {"test": ["rspec", "testrb"]}
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: annal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sam Schenkman-Moore
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70229027829860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70229027829860
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &70229027829060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70229027829060
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70229027828380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70229027828380
47
+ description: Loads up files. Parses YAML/JSON and other stuff maybe.
48
+ email:
49
+ - samsm@samsm.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rvmrc
56
+ - Gemfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - annal.gemspec
61
+ - lib/annal.rb
62
+ - lib/annal/document.rb
63
+ - lib/annal/fetch.rb
64
+ - lib/annal/parse.rb
65
+ - lib/annal/version.rb
66
+ - test/annal_integration_test.rb
67
+ - test/annal_test.rb
68
+ - test/fetch_integration_spec.rb
69
+ - test/minitest_helper.rb
70
+ - test/parse_integration_test.rb
71
+ - test/test.json
72
+ - test/test.yml
73
+ homepage: ''
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 1386763992562460045
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
95
+ - 0
96
+ hash: 1386763992562460045
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.10
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: A wrapper for text files.
103
+ test_files:
104
+ - test/annal_integration_test.rb
105
+ - test/annal_test.rb
106
+ - test/fetch_integration_spec.rb
107
+ - test/minitest_helper.rb
108
+ - test/parse_integration_test.rb
109
+ - test/test.json
110
+ - test/test.yml