writer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ 20*.md
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3@writer
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in writer.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Joe Sak
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,29 @@
1
+ # Writer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'writer'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install writer
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 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/wr ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'writer'
5
+ filename = ARGV[0]
6
+
7
+ if (load_config = File.open('config/writer.yml') rescue nil)
8
+ config = YAML.load(load_config)
9
+
10
+ Writer.configure do |c|
11
+ c.template_path = config['template_path']
12
+ end
13
+ end
14
+
15
+ if filename
16
+ Writer.write!(filename)
17
+ else
18
+ Writer.write!
19
+ end
@@ -0,0 +1,5 @@
1
+ module Writer
2
+ class Configuration
3
+ attr_accessor :template_path
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Writer
2
+ VERSION = "0.0.1"
3
+ end
data/lib/writer.rb ADDED
@@ -0,0 +1,38 @@
1
+ require "date"
2
+ require "writer/configuration"
3
+ require "writer/version"
4
+
5
+ module Writer
6
+ class << self
7
+ def write!(filename = todays_date_md)
8
+ create_file(filename)
9
+ end
10
+
11
+ def configure
12
+ @config = Configuration.new
13
+ yield(@config)
14
+ end
15
+
16
+ private
17
+ def create_file(name)
18
+ File.open(name, 'w') do |f|
19
+ f.puts template
20
+ end
21
+ end
22
+
23
+ def todays_date_md
24
+ date = Date.today
25
+ date.strftime('%Y-%m%b-%d.md')
26
+ end
27
+
28
+ def template
29
+ if config.template_path
30
+ File.open(config.template_path).read
31
+ end
32
+ end
33
+
34
+ def config
35
+ @config ||= Configuration.new
36
+ end
37
+ end
38
+ end
data/spec/.gitkeep ADDED
File without changes
@@ -0,0 +1,45 @@
1
+ require 'writer'
2
+
3
+ describe Writer do
4
+ let(:file) do
5
+ File.open('2012-01Jan-03.md')
6
+ end
7
+
8
+ before :each do
9
+ Date.stub(:today) do
10
+ Date.new(2012, 1, 3)
11
+ end
12
+ end
13
+
14
+ after :all do
15
+ File.delete('2012-01Jan-03.md')
16
+ File.delete('.template')
17
+ File.delete('My custom filename.txt')
18
+ end
19
+
20
+ it "creates today's file, blank" do
21
+ Writer.write!
22
+ file.read.should == "\n"
23
+ end
24
+
25
+ it "creates the file with your custom name" do
26
+ filename = "My custom filename.txt"
27
+ Writer.write!(filename)
28
+ File.open(filename)
29
+ end
30
+
31
+ it "uses a template, if it exists" do
32
+ body = "hello\nworld"
33
+
34
+ File.open('.template', 'w') do |f|
35
+ f.puts body
36
+ end
37
+
38
+ Writer.configure do |c|
39
+ c.template_path = '.template'
40
+ end
41
+
42
+ Writer.write!
43
+ file.read.should == body + "\n"
44
+ end
45
+ end
data/writer.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/writer/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Joe Sak"]
6
+ gem.email = ["joe@joesak.com"]
7
+ gem.description = %q{Easily start a new file to write in.}
8
+ gem.summary = %q{Start a new file and write in it.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "writer"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Writer::VERSION
17
+
18
+ gem.add_development_dependency 'rspec'
19
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: writer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Joe Sak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70193602201320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70193602201320
25
+ description: Easily start a new file to write in.
26
+ email:
27
+ - joe@joesak.com
28
+ executables:
29
+ - wr
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - .rspec
35
+ - .rvmrc
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - bin/wr
41
+ - lib/writer.rb
42
+ - lib/writer/configuration.rb
43
+ - lib/writer/version.rb
44
+ - spec/.gitkeep
45
+ - spec/writer_spec.rb
46
+ - writer.gemspec
47
+ homepage: ''
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.15
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Start a new file and write in it.
71
+ test_files:
72
+ - spec/.gitkeep
73
+ - spec/writer_spec.rb