allen 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ .DS_Store
2
+ .AppleDouble
3
+ .LSOverride
4
+ Icon
5
+ ._*
6
+ .Spotlight-V100
7
+ .Trashes
8
+ *.gem
9
+ *.rbc
10
+ .bundle
11
+ .config
12
+ coverage
13
+ InstalledFiles
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ .yardoc
22
+ _yardoc
23
+ doc/
24
+ scratch
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ notifications:
7
+ recipients:
8
+ - taylor.smith@imulus.com
9
+ - casey.ohara@imulus.com
10
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in allen.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ allen (0.1.0)
5
+ active_support (~> 3.0.0)
6
+ i18n (~> 0.6.1)
7
+ thor (~> 0.16.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ active_support (3.0.0)
13
+ activesupport (= 3.0.0)
14
+ activesupport (3.0.0)
15
+ diff-lcs (1.1.3)
16
+ ffi (1.1.5)
17
+ growl (1.0.3)
18
+ guard (1.2.3)
19
+ listen (>= 0.4.2)
20
+ thor (>= 0.14.6)
21
+ guard-rspec (1.2.1)
22
+ guard (>= 1.1)
23
+ i18n (0.6.1)
24
+ listen (0.4.7)
25
+ rb-fchange (~> 0.0.5)
26
+ rb-fsevent (~> 0.9.1)
27
+ rb-inotify (~> 0.8.8)
28
+ rb-fchange (0.0.6)
29
+ ffi
30
+ rb-fsevent (0.9.2)
31
+ rb-inotify (0.8.8)
32
+ ffi (>= 0.5.0)
33
+ rspec (2.11.0)
34
+ rspec-core (~> 2.11.0)
35
+ rspec-expectations (~> 2.11.0)
36
+ rspec-mocks (~> 2.11.0)
37
+ rspec-core (2.11.1)
38
+ rspec-expectations (2.11.3)
39
+ diff-lcs (~> 1.1.3)
40
+ rspec-mocks (2.11.3)
41
+ thor (0.16.0)
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ allen!
48
+ growl (= 1.0.3)
49
+ guard (= 1.2.3)
50
+ guard-rspec (= 1.2.1)
51
+ listen (= 0.4.7)
52
+ rspec (= 2.11.0)
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara request specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Taylor Smith
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
+ # Allen
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'allen'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install allen
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,14 @@
1
+ #!/usr/bin/env rake
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require "bundler/gem_tasks"
5
+
6
+ $: << File.expand_path(File.dirname(__FILE__) + "/lib")
7
+ require 'allen'
8
+
9
+ task :default => :spec
10
+
11
+ task :spec do
12
+ sh "rspec spec"
13
+ end
14
+
data/allen.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/allen/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Taylor Smith", "Casey O'Hara"]
6
+ gem.email = ["taylor.smith@imulus.com", "casey.ohara@imulus.com"]
7
+ gem.description = "Quickly build and manage Umbraco projects"
8
+ gem.summary = "CLI and Rake tools for quickly building and managing Umbraco projects"
9
+ gem.homepage = "http://github.com/imulus/allen"
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 = "allen"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Allen::VERSION
17
+
18
+ gem.add_runtime_dependency(%q<thor>, ["~> 0.16.0"])
19
+ gem.add_runtime_dependency(%q<i18n>, ["~> 0.6.1"])
20
+ gem.add_runtime_dependency(%q<active_support>, ["~> 3.0.0"])
21
+ gem.add_runtime_dependency(%q<albacore>, ["0.3.4"])
22
+ gem.add_runtime_dependency(%q<coyote>, ["1.2.2.rc1"])
23
+
24
+ gem.add_development_dependency(%q<rspec>, ["2.11.0"])
25
+ gem.add_development_dependency(%q<listen>, ["0.4.7"])
26
+ gem.add_development_dependency(%q<guard>, ["1.2.3"])
27
+ gem.add_development_dependency(%q<guard-rspec>, ["1.2.1"])
28
+ gem.add_development_dependency(%q<growl>, ["1.0.3"])
29
+ end
data/bin/allen ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
4
+
5
+ require 'allen'
6
+
7
+ Allen::Cli.start(ARGV)
8
+
data/lib/allen/cli.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'active_support/all'
2
+ require 'securerandom'
3
+
4
+ module Allen
5
+ class Cli < Thor
6
+ include Thor::Actions
7
+
8
+ attr_reader :name
9
+ source_paths << File.expand_path("../../../templates",__FILE__)
10
+
11
+ desc "new ClientName", "Initialize an Umbraco project"
12
+ def new(name)
13
+ @name = File.basename(File.expand_path(name)).gsub(/\W/, '_').squeeze('_').camelize
14
+ self.destination_root = File.join(File.dirname(File.expand_path(name)), @name)
15
+
16
+ empty_directory destination_root
17
+
18
+ @umbraco_guid = guid
19
+ @umbraco_assembly_guid = guid.downcase
20
+ @umbraco_extensions_guid = guid
21
+ @umbraco_extensions_assembly_guid = guid.downcase
22
+
23
+ directory 'src'
24
+ template '.gitignore'
25
+ template 'README.md.tt'
26
+ template 'Rakefile.tt'
27
+ template 'Gemfile'
28
+ end
29
+
30
+ no_tasks do
31
+ def guid
32
+ SecureRandom.uuid.to_s.upcase
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/allen/dsl.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'allen'
2
+ require 'allen/project'
3
+ require 'allen/settings'
4
+
5
+ module Allen
6
+ module DSL
7
+ def settings(&block)
8
+ Allen.settings.configure(block)
9
+ end
10
+
11
+ def project(name, &block)
12
+ project = Allen::Project.new(name, block)
13
+ Allen.projects << project
14
+ project
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,16 @@
1
+ require 'allen/settings'
2
+
3
+ module Allen
4
+ class Project
5
+ attr_accessor :name, :settings
6
+
7
+ def initialize(name="Umbraco", block=nil)
8
+ @name = name
9
+ @settings = Allen.settings.clone
10
+ @settings.configure do
11
+ name name
12
+ end
13
+ @settings.configure(block) if block
14
+ end
15
+ end
16
+ end
data/lib/allen/rake.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'allen/dsl'
2
+ require 'allen/task_definer'
3
+
4
+ module Allen
5
+ module RakeDSL
6
+ def define_tasks
7
+ TaskDefiner.new(Allen.settings, Allen.projects).define_tasks
8
+ end
9
+ end
10
+ end
11
+
12
+ include Allen::DSL
13
+ include Allen::RakeDSL
14
+
@@ -0,0 +1,44 @@
1
+ module Allen
2
+ class Settings
3
+ def initialize
4
+ pwd = Dir.pwd
5
+
6
+ defaults = Proc.new do
7
+ client "Client"
8
+ css_input "assets/stylesheets/app/application.less"
9
+ css_output "css/application.css"
10
+ js_input "assets/javascripts/app/application.coffee"
11
+ js_output "js/application.js"
12
+ root_dir { pwd }
13
+ src_dir { "#{root_dir}/src" }
14
+ solution { "#{src_dir}/#{client}.sln" }
15
+ targets [:clean, :build]
16
+ parameters ""
17
+ webroot { "#{src_dir}/#{client}.Umbraco" }
18
+ end
19
+
20
+ configure defaults
21
+ end
22
+
23
+ def configure(configuration=nil, &block)
24
+ instance_eval(&configuration) if configuration
25
+ instance_eval(&block) if block
26
+ end
27
+
28
+ def method_missing(method, value=nil, &block)
29
+ set(method, value, block) if !value.nil? or block
30
+ get(method)
31
+ end
32
+
33
+ def set(name, value, block)
34
+ instance_variable_set "@#{name}", !value.nil? ? value : block
35
+ end
36
+
37
+ def get(name)
38
+ value = instance_variable_get "@#{name}"
39
+ value = value.call if value.respond_to? :call
40
+ value
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,113 @@
1
+ require 'albacore'
2
+ require 'coyote/rake'
3
+
4
+ module Allen
5
+ class TaskDefiner
6
+ include Rake::DSL
7
+ attr_accessor :settings, :projects
8
+
9
+ def initialize(settings, projects)
10
+ @settings = settings
11
+ @projects = projects
12
+ end
13
+
14
+ def define_tasks
15
+ # Default Tasks
16
+ task :default => :build
17
+
18
+ # Build Task
19
+ desc "Build the solution in debug mode and compile all assets"
20
+ task :build => ['assets:build', 'deploy:build'] do
21
+ Rake.application.invoke_task('solution:msbuild["debug"]')
22
+ end
23
+
24
+ # Release Build
25
+ desc "Build the solution in release mode, compile and compress all assets"
26
+ task :release => ['assets:build', 'assets:compress'] do
27
+ Rake.application.invoke_task('solution:msbuild["release"]')
28
+ end
29
+
30
+ namespace :solution do
31
+ desc "Build the solution with a chosen configuration"
32
+ msbuild :msbuild, :config do |msb, args|
33
+ msb.solution = "#{settings.solution}"
34
+ msb.properties = { :configuration => args.config.to_sym }
35
+ msb.parameters = settings.parameters
36
+ msb.targets = settings.targets
37
+ end
38
+ end
39
+
40
+ namespace :deploy do
41
+ desc "Creates files for deployment"
42
+ task :build do
43
+ #create a version file with the time and the latest git commit
44
+ version_file = File.open("#{settings.webroot}/version","w")
45
+ version_file.puts "built: #{Time.now.to_s}"
46
+ version_file.puts `git log -1`
47
+ version_file.close
48
+
49
+ #create a commit-hash file with just the last commit hash in it
50
+ hash_file = File.open("#{settings.webroot}/commit-hash","w")
51
+ hash_file.print `git log -1 --format="%H"`.chomp
52
+ hash_file.close
53
+ end
54
+ end
55
+
56
+ namespace :assets do
57
+ desc "Watches assets for every project"
58
+ multitask :watch => projects.map { |project| "#{project.name.downcase}:assets:watch" }
59
+
60
+ desc "Builds assets for every project"
61
+ task :build => projects.map { |project| "#{project.name.downcase}:assets:build" }
62
+
63
+ desc "Compresses assets for every project"
64
+ task :compress => projects.map { |project| "#{project.name.downcase}:assets:compress" }
65
+ end
66
+
67
+ projects.each do |project|
68
+ namespace project.name.downcase do
69
+ desc "Build the #{project.name} project in debug mode and compile assets"
70
+ task :build => ['assets:build'] do
71
+ Rake.application.invoke_task(project.name.downcase + ':msbuild["debug"]')
72
+ end
73
+
74
+ desc "Build the #{project.name} project in debug mode"
75
+ msbuild :msbuild, :config do |msb, args|
76
+ msb.solution = "#{project.settings.src_dir}/#{project.settings.client}.#{project.name}/#{project.settings.client}.#{project.name}.csproj"
77
+ msb.properties = { :configuration => args.config.to_sym }
78
+ msb.parameters = project.settings.parameters
79
+ msb.targets = project.settings.targets
80
+ end
81
+
82
+ namespace :assets do
83
+ desc "Watches assets for the #{project.name} project"
84
+ multitask :watch => ['css:watch', 'js:watch']
85
+
86
+ desc "Builds assets for the #{project.name} project"
87
+ multitask :build => ['css:build', 'js:build']
88
+
89
+ desc "Compresses assets for the #{project.name} project"
90
+ multitask :compress => ['css:compress', 'js:compress']
91
+ end
92
+
93
+ namespace :css do
94
+ desc "Builds CSS for the #{project.name} project"
95
+ coyote do |config|
96
+ config.input = "#{project.settings.src_dir}/#{project.settings.client}.#{project.name}/#{project.settings.css_input}"
97
+ config.output = "#{project.settings.src_dir}/#{project.settings.client}.#{project.name}/#{project.settings.css_output}"
98
+ end
99
+ end
100
+
101
+ namespace :js do
102
+ desc "Builds JS for the #{project.name} project"
103
+ coyote do |config|
104
+ config.input = "#{project.settings.src_dir}/#{project.settings.client}.#{project.name}/#{project.settings.js_input}"
105
+ config.output = "#{project.settings.src_dir}/#{project.settings.client}.#{project.name}/#{project.settings.js_output}"
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+
@@ -0,0 +1,3 @@
1
+ module Allen
2
+ VERSION = '0.1.1'
3
+ end
data/lib/allen.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'thor'
2
+ require 'allen/cli'
3
+ require 'allen/version'
4
+
5
+ module Allen
6
+ def self.settings
7
+ @settings ||= Settings.new
8
+ end
9
+
10
+ def self.projects
11
+ @projects ||= []
12
+ end
13
+
14
+ def self.reset!
15
+ @settings = nil
16
+ @projects = nil
17
+ end
18
+ end
19
+
@@ -0,0 +1,37 @@
1
+ require 'allen/dsl'
2
+
3
+ include Allen::DSL
4
+
5
+ describe Allen::DSL do
6
+
7
+ it "can configure the client" do
8
+ settings do
9
+ client "RichMahogany"
10
+ root_dir { "path/to/root/dir" }
11
+ end
12
+ Allen.settings.client.should == "RichMahogany"
13
+ Allen.settings.root_dir.should == "path/to/root/dir"
14
+ end
15
+
16
+ it "can create projects" do
17
+ project "Rocketship"
18
+ project "Racecar"
19
+ Allen.projects.map(&:name).should == ['Rocketship', 'Racecar']
20
+ end
21
+
22
+ it "can configure projects" do
23
+ proj1 = project "Rhino" do
24
+ compile true
25
+ cache { false }
26
+ end
27
+
28
+ proj2 = project "Rupert" do
29
+ compressor :uglify
30
+ end
31
+
32
+ proj1.settings.compile.should == true
33
+ proj1.settings.cache.should == false
34
+ proj2.settings.compressor.should == :uglify
35
+ end
36
+ end
37
+
@@ -0,0 +1,32 @@
1
+ require 'allen'
2
+ require 'allen/project'
3
+
4
+ describe Allen::Project do
5
+
6
+ it "has good defaults" do
7
+ project = Allen::Project.new
8
+ project.name.should == "Umbraco"
9
+ end
10
+
11
+ it "makes its name also available in its settings" do
12
+ project = Allen::Project.new("Blog")
13
+ project.name.should == "Blog"
14
+ project.settings.name.should == "Blog"
15
+ end
16
+
17
+ it "derives its settings" do
18
+ Allen.settings.configure do
19
+ client "Ron Swanson"
20
+ name "Global Name"
21
+ cache true
22
+ end
23
+
24
+ project = Allen::Project.new "MustacheProject"
25
+
26
+ Allen.settings.name.should == "Global Name"
27
+ project.settings.name.should == "MustacheProject"
28
+ project.settings.cache.should == true
29
+ end
30
+
31
+ end
32
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'allen/rake'
3
+
4
+ describe "included modules" do
5
+ it "includes the DSL on kernel" do
6
+ Kernel.methods.should include :project, :settings
7
+ end
8
+
9
+ it "includes the rake DSL on the kernel" do
10
+ Kernel.methods.should include :define_tasks
11
+ end
12
+ end
13
+
@@ -0,0 +1,55 @@
1
+ require 'allen/settings'
2
+
3
+ describe Allen::Settings do
4
+ let(:pwd) { Dir.pwd }
5
+
6
+ it "has good defaults" do
7
+ settings = Allen::Settings.new
8
+ settings.client.should == "Client"
9
+ settings.css_input.should == "assets/stylesheets/app/application.less"
10
+ settings.css_output.should == "css/application.css"
11
+ settings.js_input.should == "assets/javascripts/app/application.coffee"
12
+ settings.js_output.should == "js/application.js"
13
+ settings.root_dir.should == pwd
14
+ settings.src_dir.should == "#{pwd}/src"
15
+ settings.solution.should == "#{pwd}/src/Client.sln"
16
+ settings.targets.should == [:clean, :build]
17
+ settings.parameters.should == ""
18
+ settings.webroot.should == "#{pwd}/src/Client.Umbraco"
19
+ end
20
+
21
+ it "allows the defaults to be overridden" do
22
+ settings = Allen::Settings.new
23
+ settings.configure do
24
+ client "FlavaFlav"
25
+ root_dir "~/Desktop"
26
+ end
27
+
28
+ settings.client.should == "FlavaFlav"
29
+ settings.root_dir.should == "~/Desktop"
30
+ settings.solution.should == "~/Desktop/src/FlavaFlav.sln"
31
+ end
32
+
33
+ it "can be copied and overriden" do
34
+ global_settings = Allen::Settings.new
35
+ global_settings.configure do
36
+ client "PedoBear"
37
+ webroot { "~/Desktop/#{client}/wwwroot" }
38
+ cache false
39
+ end
40
+
41
+ local_settings = global_settings.clone
42
+ local_settings.configure do
43
+ client "GoodGuyGreg"
44
+ webroot { "~/Desktop/#{client}/public" }
45
+ end
46
+
47
+ global_settings.client.should == "PedoBear"
48
+ global_settings.webroot.should == "~/Desktop/PedoBear/wwwroot"
49
+ global_settings.cache.should == false
50
+ local_settings.client.should == "GoodGuyGreg"
51
+ local_settings.webroot.should == "~/Desktop/GoodGuyGreg/public"
52
+ local_settings.cache.should == false
53
+ end
54
+ end
55
+
@@ -0,0 +1,22 @@
1
+ def sh(*args)
2
+ end
3
+
4
+ class Fake
5
+ class Task
6
+ def self.define_task(*args)
7
+ end
8
+ end
9
+
10
+ module DSL
11
+ end
12
+
13
+ def self.application
14
+ end
15
+ end
16
+
17
+ Rake = Fake unless defined? Rake
18
+
19
+
20
+ # stfu
21
+ $stdout = StringIO.new
22
+