rdm 0.1.9 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17937c3383d168f5769d3905ca00c92bafdf5764
4
- data.tar.gz: 7822aadb44658bc12dd458af0493203b9d55a352
3
+ metadata.gz: 4947208b5f0d21df716919d7c796e6af40f6795e
4
+ data.tar.gz: bef05794da4fca103eaedd3d1b6e441b427ad1cc
5
5
  SHA512:
6
- metadata.gz: 4b6c6bd70d549af995cb909aba34428a18b6d87c75f7a37f3b9fadb62079888b9a83fccd453ea9257be98f3a6f8ecb24be43f48e5e2c35a0c454d7129faa24e5
7
- data.tar.gz: 6eb6663138790754791e235ba260a4399ae268f3892b229553b17fdac438b5d9b43fac3769d283e272c697f3f49db0824cba37a4b64bd8dfcfd53e9bf43b1ffc
6
+ metadata.gz: c5eb3843050d05e5e0a5b72eccf98c617349e8790b2a72dc7987365a6063d08361ee5b96ebf420d240c1f4e2e49682107975f644832ad8953b912f30951637aa
7
+ data.tar.gz: e248fb9f3cefa59e8ceb324820b688ba50fbcec5b7ccffd0796daee94326d9049c98f0e6d841aa5feaf7214bf45c434c1dcee9c0a0326a5cda7c87fa0ef74ddc
data/README.md CHANGED
@@ -1,4 +1,42 @@
1
1
  ### RDM (Ruby Dependecy Manager)
2
2
 
3
3
  Ruby dependency manager, helps managing local package dependencies.
4
- See sample application in "example" folder.
4
+ See sample application in "example" folder.
5
+
6
+
7
+ ## Setup
8
+ 1. create Rdm.packages in the root dir of your application
9
+ ```ruby
10
+ setup do
11
+ role ENV['RUBY_ENV'] || 'production'
12
+ configs_dir 'configs'
13
+ config_path ":configs_dir/:config_name/default.yml"
14
+ role_config_path ":configs_dir/:config_name/:role.yml"
15
+ package_subdir_name 'package'
16
+ end
17
+
18
+ config :database
19
+ config :app
20
+
21
+ package 'server'
22
+ package 'application/web'
23
+ package 'domain/core'
24
+ package 'infrastructure/repository'
25
+ ```
26
+
27
+ 1. Use package generator to create new package
28
+
29
+ ```ruby
30
+ rdm-generate package server --path=core/server
31
+ ```
32
+
33
+ 1. Setup RDM in boot.rb or spec_helper.rb or any other initializer. Rdm.init should point to the directory where Rdm.packages file is located
34
+
35
+ ```ruby
36
+ require 'rdm'
37
+ Rdm.init(File.expand_path("../../", __FILE__), :test)
38
+ ```
39
+
40
+ 1. Run rdm-install in root directory to create Package.rb.lock for each package. You should do that each time you create new package or update existing package dependencies.
41
+
42
+ 1. Go to package directory, create some tests and run them.
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'rubygems'
5
5
  require 'bundler'
6
+ Bundler.setup
6
7
  require 'rdm'
7
8
  require 'optparse'
8
9
 
@@ -13,7 +14,7 @@ options = {
13
14
  }
14
15
 
15
16
  if ARGV[0] != 'package'
16
- puts "Unsupported generator command provided. Please use rdm-generate packate args."
17
+ puts "Unsupported generator command provided. Please use `rdm-generate package PACKAGE_NAME args`."
17
18
  exit 1
18
19
  end
19
20
 
@@ -24,7 +25,7 @@ if package_name.empty?
24
25
  end
25
26
 
26
27
  OptionParser.new do |opts|
27
- opts.banner = "Usage: rdm-generate PACKAGE_NAME --path=RELATIVE_PATH --skip-rspec"
28
+ opts.banner = "Usage: rdm-generate package PACKAGE_NAME --path=RELATIVE_PATH --skip-rspec"
28
29
 
29
30
  opts.on('--skip-rspec', 'Skip rspec generation') do
30
31
  options[:skip_rspec] = true
@@ -0,0 +1,6 @@
1
+ install:
2
+ bundle exec rdm-install
3
+
4
+
5
+ servers:
6
+ bundle exec ruby server/server.rb
@@ -0,0 +1,5 @@
1
+ ### Lock all package dependencies
2
+ $ bundle exec rdm-install
3
+
4
+ ### Run server:
5
+ $ bundle exec ruby server/server.rb
@@ -2,10 +2,11 @@ class Web::SampleController
2
2
  #inject :sample_service
3
3
 
4
4
  def perform
5
+ puts "Web::SampleController called..."
5
6
  sample_service.perform
6
7
  end
7
8
 
8
9
  def sample_service
9
10
  Core::SampleService.new
10
11
  end
11
- end
12
+ end
@@ -2,10 +2,11 @@ class Core::SampleService
2
2
  #inject :sample_repository
3
3
 
4
4
  def perform
5
+ puts "Core::SampleService called..."
5
6
  sample_repository.perform
6
7
  end
7
8
 
8
9
  def sample_repository
9
10
  Repository::SampleRepository.new
10
11
  end
11
- end
12
+ end
@@ -1,6 +1,7 @@
1
1
  class Repository::SampleRepository
2
2
  def perform
3
+ puts "Repository::SampleRepository called..."
3
4
  config = Rdm.config
4
5
  puts "WORKS! (#{config.app_name})"
5
6
  end
6
- end
7
+ end
@@ -3,44 +3,91 @@ require 'fileutils'
3
3
  class Rdm::PackageGenerator
4
4
  class << self
5
5
  def generate_package(current_dir, package_name, package_relative_path, skip_rspec = false)
6
- source_path = File.join(current_dir, Rdm::SOURCE_FILENAME)
7
- source_content = File.open(source_path).read
6
+ Rdm::PackageGenerator.new(
7
+ current_dir, package_name, package_relative_path, skip_rspec
8
+ ).create
9
+ end
10
+ end
8
11
 
9
- rdm_source = Rdm::SourceParser.parse(source_content)
10
- package_subdir_name = Rdm.settings.send(:package_subdir_name)
12
+ attr_accessor :current_dir, :package_name, :package_relative_path, :skip_rspec
13
+ def initialize(current_dir, package_name, package_relative_path, skip_rspec = false)
14
+ @current_dir = current_dir
15
+ @package_name = package_name
16
+ @package_relative_path = package_relative_path
17
+ @skip_rspec = skip_rspec
18
+ end
11
19
 
12
- if Dir.exist?(File.join(current_dir, package_relative_path))
13
- raise Rdm::Errors::PackageDirExists, "package dir exists"
14
- end
20
+ def rdm_source
21
+ @rdm_source ||= Rdm::SourceParser.parse(source_content)
22
+ end
23
+ def source_path
24
+ File.join(current_dir, Rdm::SOURCE_FILENAME)
25
+ end
26
+ def source_content
27
+ File.open(source_path).read
28
+ end
15
29
 
16
- if rdm_source.package_paths.include?(package_relative_path)
17
- raise Rdm::Errors::PackageExists, "package exists"
18
- end
30
+ def create
31
+ check_preconditions!
32
+ package_subdir_name = Rdm.settings.send(:package_subdir_name)
19
33
 
20
- FileUtils.mkdir_p(File.join(current_dir, package_relative_path, package_subdir_name, package_name))
21
- FileUtils.touch(File.join(current_dir, package_relative_path, package_subdir_name, "#{package_name}.rb"))
22
- FileUtils.touch(File.join(current_dir, package_relative_path, '.gitignore'))
34
+ Dir.chdir(current_dir) do
35
+ FileUtils.mkdir_p(File.join(package_relative_path, package_subdir_name, package_name))
36
+ FileUtils.touch(File.join(package_relative_path, package_subdir_name, "#{package_name}.rb"))
37
+ FileUtils.touch(File.join(package_relative_path, '.gitignore'))
23
38
 
24
39
  if !skip_rspec
25
- FileUtils.cd(File.join(current_dir, package_relative_path)) do
26
- system('rspec --init')
27
- end
40
+ init_rspec
28
41
  end
29
42
 
30
- package_rb_template = <<EOF
43
+ File.write(File.join(package_relative_path, 'Package.rb'), package_rb_template)
44
+ end
45
+ move_templates
46
+ new_source_content = source_content + "\npackage '#{package_relative_path}'"
47
+ File.write(source_path, new_source_content)
48
+ end
49
+
50
+ def init_rspec
51
+ FileUtils.cd(File.join(package_relative_path)) do
52
+ system('rspec --init')
53
+ end
54
+ end
55
+
56
+ def move_templates
57
+ Dir.chdir(File.join(File.dirname(__FILE__), "templates")) do
58
+ copy_template(".rspec")
59
+ copy_template(".gitignore")
60
+ copy_template("rspec/spec_helper.rb")
61
+ end
62
+ end
63
+
64
+ def copy_template(filepath)
65
+ from = filepath
66
+ to = File.join(current_dir, package_relative_path, filepath)
67
+ FileUtils.mkdir_p(File.dirname(to))
68
+ FileUtils.cp(from, to)
69
+ end
70
+
71
+ def check_preconditions!
72
+ if Dir.exist?(File.join(current_dir, package_relative_path))
73
+ raise Rdm::Errors::PackageDirExists, "package dir exists"
74
+ end
75
+
76
+ if rdm_source.package_paths.include?(package_relative_path)
77
+ raise Rdm::Errors::PackageExists, "package exists"
78
+ end
79
+ end
80
+
81
+ def package_rb_template
82
+ v = <<EOF
31
83
  package do
32
84
  name '#{package_name}'
33
85
  version '1.0.0'
34
86
  end
35
87
 
36
88
  dependency do
37
- # import 'package_name'
89
+ # import 'utils'
38
90
  end
39
91
  EOF
40
- File.write(File.join(current_dir, package_relative_path, 'Package.rb'), package_rb_template)
41
-
42
- source_content += "\npackage '#{package_relative_path}'"
43
- File.write(source_path, source_content)
44
- end
45
92
  end
46
93
  end
@@ -0,0 +1 @@
1
+ Package.rb.lock
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ ENV['RUBY_ENV'] = 'test'
2
+
3
+ require 'rdm'
4
+ Rdm.init(File.expand_path('../../', FILE), :test)
5
+
6
+ require 'rspec'
7
+ require 'byebug'
8
+
9
+ RSpec.configure do |config|
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Rdm
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droid Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,6 +82,7 @@ files:
82
82
  - bin/rdm-generate
83
83
  - bin/rdm-install
84
84
  - example/Gemfile
85
+ - example/Makefile
85
86
  - example/Rdm.packages
86
87
  - example/Readme.md
87
88
  - example/application/web/Package.rb
@@ -112,6 +113,9 @@ files:
112
113
  - lib/rdm/source.rb
113
114
  - lib/rdm/source_installer.rb
114
115
  - lib/rdm/source_parser.rb
116
+ - lib/rdm/templates/.gitignore
117
+ - lib/rdm/templates/.rspec
118
+ - lib/rdm/templates/rspec/spec_helper.rb
115
119
  - lib/rdm/version.rb
116
120
  - rdm.gemspec
117
121
  - spec/fixtures/SampleSource.rb