docman 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8893ad5f25d4117a072f5f7edb564663b22ed031
4
+ data.tar.gz: 4e62f4e889d431b6249a5971d861978996eeb8f8
5
+ SHA512:
6
+ metadata.gz: ad3ecf053c0833c16be220bf5374aaaa14eb306b15415b6f0d98e431fd483af975bb352682500d6e76ae3a9ea1e91da20916717492c8d48447ed3f688bc1842b
7
+ data.tar.gz: 97a9fcb4a6907a0699baeb35fc597c8aab410e8f18470f328c9c50434816d52a6b3904f0bf2594f87b36751c2e69478df7ceb52b65941f9f96d5f13ec651410a
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docman.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexander Tolstikov
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,28 @@
1
+ # Docman
2
+
3
+ Docman made for DOCroot MANagement for Drupal projects
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'docman'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install docman
18
+
19
+ ## Usage
20
+
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it ( https://github.com/aroq/docman/fork )
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/docman.rb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'docman/cli'
4
+
5
+ Docman::CLI.start(ARGV)
@@ -0,0 +1,32 @@
1
+ deploy_targets:
2
+ local:
3
+ build_types:
4
+ root: dir
5
+ drupal: drupal
6
+ repo: repo
7
+ dir: dir
8
+ acquia:
9
+ build_types:
10
+ root: repo
11
+ drupal: drupal
12
+ repo: subrepo
13
+ dir: dir
14
+
15
+ environments:
16
+ local:
17
+ deploy_target:
18
+ local
19
+ dev:
20
+ deploy_target:
21
+ acquia
22
+ test:
23
+ deploy_target:
24
+ acquia
25
+ prod:
26
+ deploy_target:
27
+ acquia
28
+
29
+ states:
30
+ - development
31
+ - staging
32
+ - stable
data/docman.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'docman/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docman"
8
+ spec.version = Docman::VERSION
9
+ spec.authors = ["Alexander Tolstikov"]
10
+ spec.email = ["atolstikov@adyax.com"]
11
+ spec.summary = %q{Docman made for DOCroot MANagement for Drupal projects}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "cucumber"
23
+ spec.add_development_dependency "aruba"
24
+
25
+ spec.add_dependency 'thor'
26
+ spec.add_dependency 'configliere'
27
+ end
@@ -0,0 +1,47 @@
1
+ Feature: Docroot management (deploy to local)
2
+
3
+ In order to manage docroot
4
+ As a developer using Cucumber
5
+ I want to use the deploy steps to deploy to local
6
+
7
+ @announce
8
+ @no-clobber
9
+ Scenario: Local init
10
+ Given I run `docman.rb init sample-docroot https://github.com/aroq/dm-test-docroot-config.git`
11
+ Then the exit status should be 0
12
+ Then the following directories should exist:
13
+ | sample-docroot |
14
+ | sample-docroot/config |
15
+
16
+ @announce
17
+ @no-clobber
18
+ Scenario: Local build development
19
+ Given I cd to "sample-docroot"
20
+ Then I run `docman.rb build local development`
21
+ Then the exit status should be 0
22
+ Then the following directories should exist:
23
+ | master |
24
+ | master/docroot |
25
+ | master/docroot/sites |
26
+ | master/hooks |
27
+ | master/profiles |
28
+ | master/profiles/sample_profile |
29
+ | master/projects/sample_project1 |
30
+ | master/projects/sample_project2 |
31
+
32
+ @announce
33
+ @no-clobber
34
+ Scenario: Local push into project1 develop
35
+ Given I cd to "sample-docroot/master/projects/sample_project1"
36
+ And I run `git checkout develop`
37
+ And I run `git pull origin develop`
38
+ Then the exit status should be 0
39
+ Given a file named "develop.txt" with:
40
+ """
41
+ test content
42
+
43
+ """
44
+ And I run `git add -A`
45
+ And I run `git commit -m "Test commit to develop"`
46
+ And I run `git push origin develop`
47
+ Then the exit status should be 0
@@ -0,0 +1,5 @@
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 600
5
+ end
@@ -0,0 +1,21 @@
1
+ # Given(/^I have deployed "(.*?)" state to "(.*?)" from scratch$/) do |state, target|
2
+ # in_current_dir do
3
+ # clean_current_dir
4
+ # run "build.rb #{target} #{state}"
5
+ # end
6
+ # end
7
+ #
8
+ # When(/^I store bump version from file "(.*?)"$/) do |file|
9
+ # ENV['DM_BUMPED_VERSION'] = IO.read(file)
10
+ # end
11
+ #
12
+ # When(/^I change repo state to last bumped tag for "(.*?)" version$/) do |state|
13
+ # version = ENV["DM_BUMPED_VERSION"]
14
+ # run "state.sh tag #{version} #{state}"
15
+ # end
16
+ #
17
+ # Then(/^the file "(.*?)" should contain last bumped tag$/) do |file|
18
+ # version = ENV["DM_BUMPED_VERSION"]
19
+ # puts "Last bumped tag: #{version}"
20
+ # prep_for_fs_check { expect(IO.read(file)).to eq version }
21
+ # end
data/lib/docman.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'docman/version'
2
+ require 'yaml'
3
+ require 'configliere'
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ require 'docman/git'
7
+
8
+ module Docman
9
+ class Docman
10
+
11
+ def initialize()
12
+ @app_root_dir = Pathname(__FILE__).dirname.parent
13
+ @current_dir = Dir.pwd
14
+ # TODO: Define workspace properly
15
+ @workspace_dir = @current_dir
16
+ @docroot_dir = @workspace_dir
17
+ @docroot_config_dir = File.join(@docroot_dir, 'config')
18
+ @docroot_structure = directory_hash File.join(@docroot_config_dir, 'master')
19
+
20
+ Settings.read File.join(@app_root_dir, 'config', 'config.yaml')
21
+ Settings.resolve!
22
+ @app_settings = Settings
23
+ @environments = Settings['environments']
24
+ @deploy_targets = Settings['deploy_targets']
25
+ end
26
+
27
+ def directory_hash(path, prefix = '')
28
+ return unless File.file? File.join(path, 'info.yaml')
29
+
30
+ name = File.basename path
31
+ prefix = prefix.size > 0 ? File.join(prefix, name) : name
32
+ info = YAML::load_file(File.join(path, 'info.yaml'))
33
+ info['full_path'] = path
34
+ info['build_path'] = prefix
35
+ info['name'] = name
36
+
37
+ data = {:data => info}
38
+ data[:children] = children = []
39
+ Dir.foreach(path) do |entry|
40
+ next if (entry == '..' || entry == '.' || entry == '_states')
41
+ full_path = File.join(path, entry)
42
+ if File.directory?(full_path)
43
+ dir_hash = directory_hash(full_path, prefix)
44
+ unless dir_hash == nil
45
+ children << dir_hash
46
+ end
47
+ end
48
+ end
49
+
50
+ data
51
+ end
52
+
53
+ def build(target, state)
54
+ @target = target
55
+ @state = state
56
+ traverse_docroot_structure
57
+ end
58
+
59
+ def deploy
60
+
61
+ end
62
+
63
+ def traverse_docroot_structure(dir = nil)
64
+ dir = dir ? dir : @docroot_structure
65
+
66
+ build_dir dir[:data]
67
+
68
+ dir[:children].each do |child|
69
+ traverse_docroot_structure child
70
+ end
71
+ end
72
+
73
+ def build_dir(info)
74
+ case get_build_type info
75
+ when 'dir'
76
+ build_dir_dir info
77
+ when 'repo'
78
+ build_dir_repo info
79
+ when 'subrepo'
80
+ build_dir_subrepo info
81
+ end
82
+ end
83
+
84
+ def get_version(info)
85
+ info['states'][@state]
86
+ end
87
+
88
+ def get_deploy_target
89
+ @deploy_targets[@environments[@target]['deploy_target']]
90
+ end
91
+
92
+ def get_build_type(info)
93
+ get_deploy_target['build_types'][info['type']]
94
+ end
95
+
96
+ def build_dir_dir(info)
97
+ FileUtils::mkdir_p get_path_in_docroot info['build_path']
98
+ end
99
+
100
+ def build_dir_repo(info)
101
+ repo = info['repo']
102
+ build_path = get_path_in_docroot info['build_path']
103
+ version_type = get_version(info)['type']
104
+ version = get_version(info)['version']
105
+ Git.new.get_repo(repo, build_path, version_type, version)
106
+ end
107
+
108
+ def build_dir_subrepo(info)
109
+
110
+ end
111
+
112
+ def get_path_in_docroot(path)
113
+ File.join(@docroot_dir, path)
114
+ end
115
+ end
116
+
117
+ end
data/lib/docman/cli.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'thor'
2
+ require 'docman'
3
+
4
+ module Docman
5
+ class CLI < Thor
6
+ desc 'init NAME', 'init to NAME'
7
+ def init(name, repo)
8
+ puts "Init docroot directory #{name} and retrieve config from provided repo."
9
+ if File.directory? "#{name}"
10
+ `rm -fR #{name}`
11
+ end
12
+ `mkdir #{name} && cd #{name} && git clone #{repo} config`
13
+ end
14
+
15
+ desc 'build NAME', 'init to NAME'
16
+ def build(target, state)
17
+ unless File.directory?('config')
18
+ $stderr.puts 'ERROR: No config directory in docroot'
19
+ exit 1
20
+ end
21
+
22
+ `cd config && git reset --hard && git clean -f -d && git pull origin master`
23
+ Docman.new.build(target, state)
24
+ end
25
+ end
26
+ end
data/lib/docman/git.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Docman
2
+
3
+ class Git
4
+ def get_repo(repo, path, type, version)
5
+ if File.directory? path
6
+ Dir.chdir path
7
+ `git checkout #{version} && git pull origin #{version}` if type == 'branch'
8
+ `git checkout #{version}` if type == 'tag'
9
+ else
10
+ `git clone #{repo} #{path}`
11
+ Dir.chdir path
12
+ `git checkout #{version}`
13
+ end
14
+
15
+ # if result.nil?
16
+ # puts "Error: #{$?}"
17
+ # end
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module Docman
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Tolstikov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: cucumber
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: aruba
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
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: configliere
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - atolstikov@adyax.com
100
+ executables:
101
+ - docman.rb
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/docman.rb
111
+ - config/config.yaml
112
+ - docman.gemspec
113
+ - features/local.feature
114
+ - features/support/env.rb
115
+ - features/support/step_definitions/dm_steps.rb
116
+ - lib/docman.rb
117
+ - lib/docman/cli.rb
118
+ - lib/docman/git.rb
119
+ - lib/docman/version.rb
120
+ homepage: ''
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Docman made for DOCroot MANagement for Drupal projects
144
+ test_files:
145
+ - features/local.feature
146
+ - features/support/env.rb
147
+ - features/support/step_definitions/dm_steps.rb