kodiak 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.
data/Manifest ADDED
@@ -0,0 +1,32 @@
1
+ Manifest
2
+ Rakefile
3
+ bin/kodiak
4
+ config/.kodiak_config
5
+ config/.kodiak_log
6
+ config/kodiak-icon.png
7
+ config/kodiak-usage.txt
8
+ config/kodiak.yaml
9
+ lib/kodiak.rb
10
+ lib/kodiak/cli.rb
11
+ lib/kodiak/config_reader.rb
12
+ lib/kodiak/generator.rb
13
+ lib/kodiak/notification.rb
14
+ lib/kodiak/transporter.rb
15
+ lib/kodiak/utils.rb
16
+ lib/kodiak/watcher.rb
17
+ test/app/scripts/javascript/application/application.js
18
+ test/app/scripts/javascript/application/init.js
19
+ test/app/scripts/javascript/jquery/jquery.js
20
+ test/app/scripts/javascript/jquery/plugins/jquery.hashchange.js
21
+ test/app/scripts/javascript/map/layer.js
22
+ test/app/scripts/javascript/map/map.js
23
+ test/app/scripts/javascript/map/overlay.js
24
+ test/app/scripts/javascript/map/point.js
25
+ test/app/scripts/javascript/map/polygon.js
26
+ test/app/scripts/javascript/utils/hash.js
27
+ test/app/scripts/javascript/utils/utils.js
28
+ test/app/stylesheets/css/application.master.css
29
+ test/app/stylesheets/less/application.fonts.less
30
+ test/app/stylesheets/less/application.master.less
31
+ test/public/scripts/application.js
32
+ test/public/scripts/init.js
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'rbconfig'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ $: << File.expand_path(File.dirname(__FILE__) + "/lib")
7
+ require 'kodiak'
8
+
9
+ Echoe.new(Kodiak::APP_NAME.downcase, Kodiak::VERSION) do |p|
10
+ p.description = "A static file transporter"
11
+ p.summary = ""
12
+ p.url = "http://github.com/imulus/kodiak"
13
+ p.author = "Imulus"
14
+ p.email = "developer@imulus.com"
15
+ p.ignore_pattern = ["tmp/*", "script/*", "test/*", "assets/*"]
16
+
17
+ dependencies = Array.new
18
+ dependencies << "term-ansicolor >=1.0.5"
19
+ dependencies << "directory_watcher >=1.4.0"
20
+
21
+ target_os = Config::CONFIG['target_os']
22
+
23
+ if target_os =~ /darwin/i
24
+ dependencies << "rb-appscript >=0.6.1"
25
+ elsif target_os =~ /linux/i
26
+ elsif target_os =~ /mswin|mingw/i
27
+ end
28
+
29
+ p.development_dependencies = dependencies
30
+ p.runtime_dependencies = dependencies
31
+ end
data/bin/kodiak ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
4
+ require 'fileutils'
5
+ require 'rubygems'
6
+ require 'optparse'
7
+ require 'kodiak'
8
+
9
+
10
+ @options = {}
11
+
12
+ OptionParser.new do |opts|
13
+ opts.on("-f", "--force", "Force") do |option|
14
+ @options[:force] = option
15
+ end
16
+ opts.on("-q", "--quiet", "Quiet") do |option|
17
+ @options[:quiet] = option
18
+ end
19
+ opts.on("-v", "--verbose", "Verbose") do |option|
20
+ @options[:verbose] = option
21
+ end
22
+ opts.on("-s", "--safe", "Safe") do |option|
23
+ @options[:safe] = option
24
+ end
25
+ opts.on("--user.name") do |option|
26
+ @options[:name] = ARGV[0]
27
+ end
28
+ opts.on("--user.email") do |option|
29
+ @options[:email] = ARGV[0]
30
+ end
31
+ end.parse!
32
+
33
+
34
+ # giddy up
35
+ case ARGV.first
36
+ when 'generate'
37
+ Kodiak::Generator.new(@options).generate
38
+ when 'push'
39
+ Kodiak::push(@options)
40
+ when 'watch'
41
+ Kodiak::watch(@options)
42
+ when 'configure'
43
+ Kodiak::configure(@options)
44
+ when 'log'
45
+ Kodiak::view_log
46
+ else
47
+ Kodiak::usage
48
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ __ __ ____ ____ _ ____ __ __
2
+ | |/ // () \| _) \| | / () \ | |/ /
3
+ |__|\__\\____/|____/|_|/__/\__\|__|\__\
4
+
Binary file
@@ -0,0 +1,23 @@
1
+ __ __ ____ ____ _ ____ __ __
2
+ | |/ // () \| _) \| | / () \ | |/ /
3
+ |__|\__\\____/|____/|_|/__/\__\|__|\__\
4
+
5
+ ------------------------------------------
6
+ Kodiak - A static file transporter
7
+ http://github.com/imulus/kodiak
8
+ ------------------------------------------
9
+
10
+ Usage : 'kodiak Action [Environment] [Options]'
11
+
12
+ == Actions
13
+ push - Transports files, requires environment param | ex: 'kodiak push local'
14
+ watch - Starts the Kodiak observe mechanism. Automatically transports files as they are modified.
15
+ generate - Create a Kodiak configuration file in this directory
16
+ log - View log history
17
+
18
+ == Options
19
+ -f | --force - force overwrites on destination files
20
+ -s | --safe - skip safety prompts
21
+ -q | --quiet - suppress notifications
22
+ -v | --verbose - output log messages
23
+
@@ -0,0 +1,35 @@
1
+ # Example environments
2
+ # development:
3
+ # files:
4
+ # 'src/javascript/application.js' : 'public/scripts/application.js'
5
+ # 'src/css/screen.css' : 'public/css/screen.css'
6
+ #
7
+ # staging:
8
+ # files:
9
+ # 'src/javascript/application.js' : 'public/scripts/application.js'
10
+ # 'src/css/screen.css' : 'public/css/screen.css'
11
+ #
12
+ # production:
13
+ # files:
14
+ # 'src/javascript/application.js' : 'public/scripts/application.js'
15
+ # 'src/css/screen.css' : 'public/css/screen.css'
16
+
17
+ #########################################################################################################
18
+
19
+ # You can name your environments how you wish. 'development', 'staging' and 'production are just examples.
20
+ # Once your environments are defined, you can call them from the command line | ex: kodiak push staging
21
+
22
+ #########################################################################################################
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
data/kodiak.gemspec ADDED
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{kodiak}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Imulus"]
9
+ s.date = %q{2011-05-31}
10
+ s.default_executable = %q{kodiak}
11
+ s.description = %q{A static file transporter}
12
+ s.email = %q{developer@imulus.com}
13
+ s.executables = ["kodiak"]
14
+ s.extra_rdoc_files = ["bin/kodiak", "lib/kodiak.rb", "lib/kodiak/cli.rb", "lib/kodiak/config_reader.rb", "lib/kodiak/generator.rb", "lib/kodiak/notification.rb", "lib/kodiak/transporter.rb", "lib/kodiak/utils.rb", "lib/kodiak/watcher.rb"]
15
+ s.files = ["Manifest", "Rakefile", "bin/kodiak", "config/.kodiak_config", "config/.kodiak_log", "config/kodiak-icon.png", "config/kodiak-usage.txt", "config/kodiak.yaml", "lib/kodiak.rb", "lib/kodiak/cli.rb", "lib/kodiak/config_reader.rb", "lib/kodiak/generator.rb", "lib/kodiak/notification.rb", "lib/kodiak/transporter.rb", "lib/kodiak/utils.rb", "lib/kodiak/watcher.rb", "test/app/scripts/javascript/application/application.js", "test/app/scripts/javascript/application/init.js", "test/app/scripts/javascript/jquery/jquery.js", "test/app/scripts/javascript/jquery/plugins/jquery.hashchange.js", "test/app/scripts/javascript/map/layer.js", "test/app/scripts/javascript/map/map.js", "test/app/scripts/javascript/map/overlay.js", "test/app/scripts/javascript/map/point.js", "test/app/scripts/javascript/map/polygon.js", "test/app/scripts/javascript/utils/hash.js", "test/app/scripts/javascript/utils/utils.js", "test/app/stylesheets/css/application.master.css", "test/app/stylesheets/less/application.fonts.less", "test/app/stylesheets/less/application.master.less", "test/public/scripts/application.js", "test/public/scripts/init.js", "kodiak.gemspec"]
16
+ s.homepage = %q{http://github.com/imulus/kodiak}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Kodiak"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{kodiak}
20
+ s.rubygems_version = %q{1.6.2}
21
+ s.summary = %q{A static file transporter}
22
+
23
+ if s.respond_to? :specification_version then
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<term-ansicolor>, [">= 1.0.5"])
28
+ s.add_runtime_dependency(%q<directory_watcher>, [">= 1.4.0"])
29
+ s.add_runtime_dependency(%q<rb-appscript>, [">= 0.6.1"])
30
+ s.add_development_dependency(%q<term-ansicolor>, [">= 1.0.5"])
31
+ s.add_development_dependency(%q<directory_watcher>, [">= 1.4.0"])
32
+ s.add_development_dependency(%q<rb-appscript>, [">= 0.6.1"])
33
+ else
34
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
35
+ s.add_dependency(%q<directory_watcher>, [">= 1.4.0"])
36
+ s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
37
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
38
+ s.add_dependency(%q<directory_watcher>, [">= 1.4.0"])
39
+ s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
40
+ end
41
+ else
42
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
43
+ s.add_dependency(%q<directory_watcher>, [">= 1.4.0"])
44
+ s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
45
+ s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
46
+ s.add_dependency(%q<directory_watcher>, [">= 1.4.0"])
47
+ s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
48
+ end
49
+ end
data/lib/kodiak.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'yaml'
2
+ require 'kodiak/utils'
3
+ require 'kodiak/cli'
4
+ require 'kodiak/notification'
5
+ require 'kodiak/generator'
6
+ require 'kodiak/config_reader'
7
+ require 'kodiak/transporter'
8
+ require 'kodiak/watcher'
9
+
10
+ module Kodiak
11
+ APP_NAME = "Kodiak"
12
+ VERSION = "0.0.1"
13
+ ROOT_PATH = Dir.pwd
14
+ CONFIG_PATH = File.expand_path(File.dirname(__FILE__) + "/../config")
15
+ CONFIG_FILENAME = "kodiak.yaml"
16
+ CONFIG_ICON = "kodiak-icon.png"
17
+ USAGE_FILENAME = "kodiak-usage.txt"
18
+ GLOBAL_CONFIG = ".kodiak_config"
19
+ LOG_FILENAME = ".kodiak_log"
20
+
21
+ attr_accessor :user
22
+
23
+ def self.user=(user)
24
+ @user = user
25
+ end
26
+
27
+ def self.user
28
+ @user
29
+ end
30
+
31
+ end
data/lib/kodiak/cli.rb ADDED
@@ -0,0 +1,100 @@
1
+ module Kodiak
2
+
3
+ def self.push(options)
4
+ ARGV.shift
5
+
6
+ if ! ARGV[0]
7
+ Kodiak::Notification.new "Push requires an environment parameter\n", "failure"
8
+ puts "Example: 'kodiak push remote'"
9
+ exit
10
+ end
11
+
12
+ options[:environment] = ARGV[0]
13
+ config = Kodiak::ConfigReader.new(options)
14
+
15
+ if options[:safe]
16
+ continue = "yes"
17
+ else
18
+ puts "[environment = #{options[:environment]}]\n"
19
+ puts "\nPush these files?"
20
+ config.files.each do |file|
21
+ puts " - #{file[:source]} --> #{file[:destination]}"
22
+ end
23
+ puts "\nContinue? [yes|no]"
24
+ continue = STDIN.gets.chomp
25
+ end
26
+
27
+
28
+ if continue =~ /([Yy][Ee][Ss]|[Yy]|1)/
29
+ Kodiak::Transporter.new(config, options).transport
30
+ else
31
+ puts "Push canceled by user"
32
+ exit
33
+ end
34
+ end
35
+
36
+
37
+ def self.watch(options)
38
+ ARGV.shift
39
+
40
+ if ! ARGV[0]
41
+ puts "Watch requires an environment parameter"
42
+ puts "Example: 'kodiak watch remote'"
43
+ exit
44
+ end
45
+
46
+ options[:environment] = ARGV[0]
47
+ config = Kodiak::ConfigReader.new(options)
48
+
49
+ if options[:safe]
50
+ continue = "yes"
51
+ else
52
+ puts "Start Kodiak server? [yes|no]"
53
+ continue = STDIN.gets.chomp
54
+ end
55
+
56
+ if continue =~ /([Yy][Ee][Ss]|[Yy]|1)/
57
+ Kodiak::Watcher.new(config, options)
58
+ end
59
+ end
60
+
61
+
62
+ def self.configure(options)
63
+ if not File.exists? "#{ENV['HOME']}/#{Kodiak::GLOBAL_CONFIG}"
64
+ FileUtils.cp_r "#{Kodiak::CONFIG_PATH}/#{Kodiak::GLOBAL_CONFIG}", "#{ENV['HOME']}/#{Kodiak::GLOBAL_CONFIG}", :remove_destination => true
65
+ end
66
+
67
+ user = ""
68
+ options.each do |key, value|
69
+ user += "#{key} : #{value}\n"
70
+ end
71
+
72
+ file = File.open("#{ENV['HOME']}/#{Kodiak::GLOBAL_CONFIG}", "w+")
73
+ file.write(user)
74
+ file.close
75
+
76
+ Kodiak::Notification.new "Global configuration complete\n", "success"
77
+ Kodiak::Notification.new "#{user}"
78
+ end
79
+
80
+
81
+ def self.view_log
82
+ if not File.exists? Kodiak::LOG_FILENAME
83
+ puts "Log file does not exist. Sorry."
84
+ exit
85
+ end
86
+
87
+ file = File.open("#{Kodiak::LOG_FILENAME}", "r")
88
+ puts file.read
89
+ file.close
90
+ end
91
+
92
+ def self.usage
93
+ file = File.open("#{Kodiak::CONFIG_PATH}/#{Kodiak::USAGE_FILENAME}", 'r')
94
+ puts file.read
95
+ file.close
96
+ end
97
+
98
+
99
+
100
+ end
@@ -0,0 +1,113 @@
1
+ require 'fileutils'
2
+
3
+ module Kodiak
4
+ class ConfigReader
5
+
6
+ attr_accessor :options, :input, :files, :environment, :user
7
+
8
+ def initialize(options)
9
+ @options = options
10
+ @environment = @options[:environment]
11
+ @input = get_config
12
+ @files = []
13
+ check_and_set_globals
14
+ find_and_add_files
15
+ end
16
+
17
+
18
+ def find_and_add_files
19
+ if @input[@environment]
20
+ @input[@environment]['files'].each do |source, destination|
21
+ Dir.glob(source).each do |file|
22
+ input = { :source => file, :destination => destination }
23
+ @files.push input
24
+ end
25
+ end
26
+ else
27
+ puts "Environment '#{environment}' is not defined in kodiak.yaml"
28
+ puts "Environments defined:"
29
+ @input.each do |name, environment|
30
+ puts "- #{name}"
31
+ end
32
+ exit
33
+ end
34
+ end
35
+
36
+
37
+ def ftp?
38
+ @input[@environment]['ftp'] || false
39
+ end
40
+
41
+
42
+ def ftp
43
+ environment = @input[@environment]
44
+
45
+ # supply a default path of root
46
+ if ! environment['path']
47
+ environment['path'] = ""
48
+ end
49
+
50
+ credentials = {}
51
+ items = ['server','username','password','path']
52
+
53
+ #check that they provided all the creds we need
54
+ items.each do |item|
55
+ if ! environment[item]
56
+ puts "Missing FTP credential: #{item}"
57
+ exit
58
+ else
59
+ credentials[item] = environment[item]
60
+ end
61
+ end
62
+ return credentials
63
+ end
64
+
65
+ def get_config
66
+ if File.exists?(Kodiak::CONFIG_FILENAME)
67
+ begin
68
+ config = YAML.load(File.open(Kodiak::CONFIG_FILENAME))
69
+ if config.class == Hash && ! config.empty?
70
+ return config
71
+ else
72
+ Kodiak::Notification.new "Kodiak configuration exists but has not been defined yet. Configure it in #{Kodiak::CONFIG_FILENAME}\n", "failure"
73
+ system("open #{Kodiak::CONFIG_FILENAME}")
74
+ exit(0)
75
+ end
76
+ rescue ArgumentError => e
77
+ Kodiak::Notification.new "Could not parse YAML: #{e.message}\n", "failure"
78
+ exit
79
+ end
80
+ else
81
+ Kodiak::Notification.new "Could not find a Kodiak configuration file in this directory. Use 'kodiak generate' to create one.\n", "failure"
82
+ exit
83
+ end
84
+ end
85
+
86
+ def check_and_set_globals
87
+ if File.exists? "#{ENV['HOME']}/#{Kodiak::GLOBAL_CONFIG}"
88
+ begin
89
+ user = YAML.load(File.open("#{ENV['HOME']}/#{Kodiak::GLOBAL_CONFIG}"))
90
+ if user.class == Hash && ! user.empty?
91
+ Kodiak.user = user
92
+ @user = user
93
+ else
94
+ Kodiak::Notification.new "Kodiak has not been globally configured or the configuration is broken\n", "failure"
95
+ puts "To configure, use:"
96
+ puts 'kodiak configure --user.name "Firstname Lastname" --user.email "your_email@youremail.com"'
97
+ exit
98
+ end
99
+ rescue ArgumentError => e
100
+ puts "Could not parse YAML: #{e.message}\n"
101
+ exit
102
+ end
103
+ else
104
+ Kodiak::Notification.new "Kodiak has not been globally configured or the configuration is broken\n", "failure"
105
+ puts "To configure, use:"
106
+ puts 'kodiak configure --user.name "Firstname Lastname" --user.email "your_email@youremail.com"'
107
+ exit
108
+ end
109
+ end
110
+
111
+
112
+ end
113
+ end