cook.ie 0.1.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: 1bc450a3d5e968f1aed942a4fb0a413f0f0c4b34
4
+ data.tar.gz: da4ea4d608ebaba14bd08d6b48a2ae10103f9df1
5
+ SHA512:
6
+ metadata.gz: fb7325ee69a15a49212ccb4aaa5bbbb3ca3ae12c0aa5baee6ec6930750391de63f88d93e01ba56cde2feb16f5f8fb70f4688920c2e70092f0d3aea336f4e1f15
7
+ data.tar.gz: 6d852aaa579e4968c226ce2d0b291eba4e91d5fa1ff8e049d4668f7eeaa14a474beba10b4640a567c089e3e9ea192dee399d40c826947052c05a98ad574fd2bc
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cookie_cutter.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,52 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(spec) \
6
+ .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(%r{^spec/.+_spec\.rb$})
49
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
50
+ #watch(%r{^lib/cookie_cutter/(.+)\.rb$}) { |m| "spec/cookie_cutter/#{m[1]}_spec.rb" }
51
+ watch('spec/spec_helper.rb') { "spec" }
52
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ritchie Macapinlac
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,42 @@
1
+ # cook.ie
2
+
3
+ [![Build
4
+ Status](https://travis-ci.org/rsmacapinlac/cook.ie.svg?branch=master)](https://travis-ci.org/rsmacapinlac/cook.ie)
5
+
6
+ This gem makes cookies. I mean, if cookies were text files derived from erb templates.
7
+
8
+ ## Installation
9
+
10
+ Nooo!!! Don't install it. It's not done!
11
+
12
+ ## Setup
13
+
14
+ The gem assumes that you have an environment variable called CC_TEMPLATE_DIR
15
+ that has a pointer to a template folder. If it doesn't find one it defaults to
16
+
17
+ `~/Dropbox/!Templates`
18
+
19
+ It also expects a `config.yml` file in there to make it a bit smarter.
20
+
21
+ In the template folder, you have a config.yml file and your template files.
22
+
23
+ ## Usage
24
+
25
+ Look, it's not done but I mean you can download the code or clone this. Then
26
+ figure out how to use it.
27
+
28
+ `bin/cookie template_name name`
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/[my-github-username]/cookie_cutter/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
8
+ t.rspec_opts = '--format documentation'
9
+ # t.rspec_opts << ' more options'
10
+ # t.rcov = true
11
+ end
12
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cookie_cutter"
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
data/bin/cookie ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cookie_cutter"
5
+
6
+ template_dir = ENV['CC_TEMPLATE_DIR']
7
+ if template_dir.nil?
8
+ puts "in here"
9
+ template_dir = '~/Dropbox/!Templates'
10
+ template_dir = File.expand_path(template_dir)
11
+ end
12
+
13
+ options = {}
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: cookie [options] template_name cookie_name"
16
+
17
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
18
+ options[:verbose] = v
19
+ end
20
+ end.parse!
21
+
22
+ unless ARGV.size != 2
23
+ r = CookieCutter::Recipe.new(template_dir)
24
+ c = r.build_cookie(ARGV[1], ARGV[0])
25
+ c.save
26
+ end
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/test_cookie ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cookie_cutter"
5
+
6
+ r = CookieCutter::Recipe.new(File.expand_path File.join('spec', 'test_config'))
7
+ c = r.build_cookie('test-cookie', 'test-output')
8
+ puts c.save
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cookie_cutter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cook.ie"
8
+ spec.version = CookieCutter::VERSION
9
+ spec.authors = ["Ritchie Macapinlac"]
10
+ spec.email = ["ritchie@macapinlac.com"]
11
+
12
+ spec.summary = %q{This Gem makes cookies if cookies were files derived from erb templates.}
13
+ spec.homepage = "http://www.macapinlac.com/projects/cook-ie"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ #if spec.respond_to?(:metadata)
22
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
23
+ #end
24
+
25
+ spec.add_runtime_dependency "log4r"
26
+
27
+ spec.add_development_dependency "bundler"
28
+ spec.add_development_dependency "guard-rspec"
29
+ spec.add_development_dependency "rake"
30
+ end
@@ -0,0 +1,56 @@
1
+ require 'pathname'
2
+
3
+ module CookieCutter
4
+ # builds a text file with specified parameters
5
+ # A cookie knows:
6
+ # * it's name
7
+ # * where to save itself
8
+ class Cookie
9
+ attr_accessor :name, :overwrite
10
+ attr_accessor :template_options
11
+
12
+ # constants
13
+ OUTPUT_DIR = 'output_dir'
14
+ TEMPLATE_NAME = 'template'
15
+ CONFIG_PATH = 'config_path'
16
+
17
+ def initialize(name, template_options = {})
18
+ # defaults
19
+ @overwrite = true
20
+ @name = name
21
+ @template_options = template_options
22
+ end
23
+
24
+ def assemble
25
+ ERB.new(File.open(self.template_path).read).result(binding)
26
+ end
27
+
28
+ def save
29
+ save_path = File.join(self.where_to_save, "#{@name}.txt")
30
+ f = File.open(save_path, 'w+')
31
+ f.write(self.assemble)
32
+ end
33
+
34
+ # assumption, all templates will be kept in the config directory
35
+ def template_path
36
+ path = File.expand_path File.join(@template_options[CONFIG_PATH], @template_options[TEMPLATE_NAME])
37
+ # TODO fix and throw some sort of cool exception
38
+ if !File.exists? path
39
+ path = nil
40
+ end
41
+ return path
42
+ end
43
+
44
+ # if the output dir is relative, then assume relative to the current folder
45
+ # otherwise absolute
46
+ def where_to_save
47
+ output_dir = @template_options[OUTPUT_DIR]
48
+ # assume absolute
49
+ full_path = output_dir
50
+ if (Pathname.new(output_dir)).relative?
51
+ full_path = File.expand_path(output_dir, Dir.pwd)
52
+ end
53
+ return full_path
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,48 @@
1
+ require 'yaml'
2
+
3
+ module CookieCutter
4
+ # Reads config file information and builds a cookie from the selected template
5
+ class Recipe
6
+ DEFAULT_CONFIG_FILENAME = 'config.yml'
7
+ attr_accessor :cookie, :config_file_path
8
+
9
+ CONFIG_PATH = 'config_path'
10
+
11
+ def initialize(config_file_path = nil)
12
+ throw ArgumentError if config_file_path.nil?
13
+
14
+ @config_file_path = config_file_path
15
+ @_config = Recipe.read_config_file(config_file_path)
16
+ end
17
+
18
+ def config
19
+ @_config
20
+ end
21
+
22
+ def template
23
+ @_template[Recipe::CONFIG_PATH] = @config_file_path
24
+ @_template
25
+ end
26
+
27
+ def build_cookie(cookie_name, which_template)
28
+ @_template = self.config[which_template]
29
+ @cookie = Cookie.new(cookie_name, self.template)
30
+ end
31
+
32
+ private
33
+
34
+ def self.config_is_dir(config_path)
35
+ path = File.expand_path(config_path)
36
+ File.directory? path
37
+ end
38
+
39
+ def self.read_config_file(template_path)
40
+ if Recipe.config_is_dir(template_path) == true
41
+ full_path = File.expand_path File.join(template_path, Recipe::DEFAULT_CONFIG_FILENAME)
42
+ else
43
+ full_path = File.expand_path File.join(template_path)
44
+ end
45
+ return YAML::load_file(full_path)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module CookieCutter
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'cookie_cutter/version'
2
+ require 'cookie_cutter/recipe'
3
+ require 'cookie_cutter/cookie'
4
+
5
+ require 'log4r'
6
+
7
+ include Log4r
8
+
9
+ module CookieCutter
10
+
11
+ class << self
12
+ attr_writer :logger
13
+
14
+ def logger
15
+ if @logger.nil?
16
+ @logger = Logger.new(self.name)
17
+ @logger.outputters = Outputter.stdout
18
+ end
19
+ @logger
20
+ end
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cook.ie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ritchie Macapinlac
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: log4r
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
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: guard-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: rake
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:
70
+ email:
71
+ - ritchie@macapinlac.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - .travis.yml
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Guardfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/cookie
87
+ - bin/setup
88
+ - bin/test_cookie
89
+ - cookie_cutter.gemspec
90
+ - lib/cookie_cutter.rb
91
+ - lib/cookie_cutter/cookie.rb
92
+ - lib/cookie_cutter/recipe.rb
93
+ - lib/cookie_cutter/version.rb
94
+ homepage: http://www.macapinlac.com/projects/cook-ie
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.8
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: This Gem makes cookies if cookies were files derived from erb templates.
118
+ test_files: []