vendor 0.0.1 → 0.0.2

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.
Files changed (166) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile.lock +2 -4
  3. data/LICENSE +20 -0
  4. data/Readme.markdown +91 -10
  5. data/bin/vendor +5 -53
  6. data/lib/vendor.rb +37 -26
  7. data/lib/vendor/api.rb +1 -1
  8. data/lib/vendor/cli.rb +3 -15
  9. data/lib/vendor/cli/app.rb +140 -0
  10. data/lib/vendor/cli/auth.rb +6 -4
  11. data/lib/vendor/cli/console.rb +25 -0
  12. data/lib/vendor/extensions/string.rb +1 -1
  13. data/lib/vendor/template.rb +55 -0
  14. data/lib/vendor/templates/Vendorfile +3 -0
  15. data/lib/vendor/templates/vendorspec +15 -0
  16. data/lib/vendor/ui.rb +62 -0
  17. data/lib/vendor/vendor_file.rb +12 -0
  18. data/lib/vendor/vendor_file/dsl.rb +54 -0
  19. data/lib/vendor/vendor_file/library.rb +16 -0
  20. data/lib/vendor/vendor_file/library/base.rb +95 -0
  21. data/lib/vendor/vendor_file/library/git.rb +71 -0
  22. data/lib/vendor/vendor_file/library/local.rb +22 -0
  23. data/lib/vendor/vendor_file/library/remote.rb +18 -0
  24. data/lib/vendor/vendor_file/loader.rb +36 -0
  25. data/lib/vendor/vendor_file/source.rb +21 -0
  26. data/lib/vendor/vendor_spec.rb +11 -0
  27. data/lib/vendor/vendor_spec/builder.rb +10 -3
  28. data/lib/vendor/version.rb +1 -1
  29. data/lib/vendor/xcode.rb +10 -0
  30. data/lib/vendor/xcode/project.rb +132 -19
  31. data/lib/vendor/xcode/proxy.rb +28 -0
  32. data/lib/vendor/xcode/{object.rb → proxy/base.rb} +52 -25
  33. data/lib/vendor/xcode/proxy/pbx_build_file.rb +9 -0
  34. data/lib/vendor/xcode/proxy/pbx_container_item_proxy.rb +8 -0
  35. data/lib/vendor/xcode/proxy/pbx_file_reference.rb +39 -0
  36. data/lib/vendor/xcode/proxy/pbx_frameworks_build_phase.rb +9 -0
  37. data/lib/vendor/xcode/proxy/pbx_group.rb +35 -0
  38. data/lib/vendor/xcode/{objects → proxy}/pbx_native_target.rb +2 -2
  39. data/lib/vendor/xcode/{objects → proxy}/pbx_project.rb +2 -2
  40. data/lib/vendor/xcode/proxy/pbx_resources_build_phase.rb +7 -0
  41. data/lib/vendor/xcode/proxy/pbx_shell_script_build_phase.rb +7 -0
  42. data/lib/vendor/xcode/proxy/pbx_sources_build_phase.rb +9 -0
  43. data/lib/vendor/xcode/proxy/pbx_target_dependency.rb +7 -0
  44. data/lib/vendor/xcode/proxy/pbx_variant_group.rb +7 -0
  45. data/lib/vendor/xcode/proxy/xc_build_configuration.rb +7 -0
  46. data/lib/vendor/xcode/proxy/xc_configuration_list.rb +9 -0
  47. data/lib/vendor/xcode/proxy/xc_version_group.rb +7 -0
  48. data/spec/{vendor → lib/vendor}/api_spec.rb +0 -0
  49. data/spec/{vendor → lib/vendor}/cli/auth_spec.rb +1 -1
  50. data/spec/{vendor → lib/vendor}/config_spec.rb +1 -1
  51. data/spec/lib/vendor/template_spec.rb +36 -0
  52. data/spec/lib/vendor/vendor_file/dsl_spec.rb +5 -0
  53. data/spec/lib/vendor/vendor_file/library/base_spec.rb +148 -0
  54. data/spec/lib/vendor/vendor_file/library/git_spec.rb +33 -0
  55. data/spec/lib/vendor/vendor_file/library/local_spec.rb +19 -0
  56. data/spec/lib/vendor/vendor_file/library/remote_spec.rb +13 -0
  57. data/spec/lib/vendor/vendor_file/loader_spec.rb +102 -0
  58. data/spec/lib/vendor/vendor_file/source_spec.rb +17 -0
  59. data/spec/{vendor → lib/vendor}/vendor_spec/builder_spec.rb +0 -0
  60. data/spec/{vendor → lib/vendor}/vendor_spec/dsl_spec.rb +0 -0
  61. data/spec/{vendor → lib/vendor}/vendor_spec/loader_spec.rb +1 -1
  62. data/spec/lib/vendor/xcode/project_spec.rb +400 -0
  63. data/spec/{vendor/xcode/object_spec.rb → lib/vendor/xcode/proxy/base_spec.rb} +15 -3
  64. data/spec/lib/vendor/xcode/proxy/pbx_file_reference_spec.rb +25 -0
  65. data/spec/lib/vendor/xcode/proxy/pbx_group_spec.rb +27 -0
  66. data/spec/{vendor/xcode/objects → lib/vendor/xcode/proxy}/pbx_project_spec.rb +1 -1
  67. data/spec/spec_helper.rb +5 -3
  68. data/spec/support/api_stubs.rb +4 -3
  69. data/spec/support/resources/Vendorfile +22 -0
  70. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/BICoreDataCache.mom +0 -0
  71. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/BMMapCalloutView.nib +0 -0
  72. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/Info.plist +0 -0
  73. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/bingmaps_logo.png +0 -0
  74. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/bingmaps_logo@2x.png +0 -0
  75. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_selected_comp.png +0 -0
  76. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_selected_comp@2x.png +0 -0
  77. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_unselected.png +0 -0
  78. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_unselected@2x.png +0 -0
  79. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_unselected_comp.png +0 -0
  80. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/blue_unselected_comp@2x.png +0 -0
  81. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/callout_white.png +0 -0
  82. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/callout_white@2x.png +0 -0
  83. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_selected_comp.png +0 -0
  84. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_selected_comp@2x.png +0 -0
  85. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_unselected.png +0 -0
  86. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_unselected@2x.png +0 -0
  87. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_unselected_comp.png +0 -0
  88. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/green_unselected_comp@2x.png +0 -0
  89. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/mapConfiguration.plist +0 -0
  90. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/me_dot_128.png +0 -0
  91. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/networkDefaults.plist +0 -0
  92. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_selected_comp.png +0 -0
  93. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_selected_comp@2x.png +0 -0
  94. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_unselected.png +0 -0
  95. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_unselected@2x.png +0 -0
  96. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_unselected_comp.png +0 -0
  97. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/orange_unselected_comp@2x.png +0 -0
  98. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_selected_comp.png +0 -0
  99. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_selected_comp@2x.png +0 -0
  100. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_unselected.png +0 -0
  101. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_unselected@2x.png +0 -0
  102. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_unselected_comp.png +0 -0
  103. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/purple_unselected_comp@2x.png +0 -0
  104. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_selected_comp.png +0 -0
  105. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_selected_comp@2x.png +0 -0
  106. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_unselected.png +0 -0
  107. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_unselected@2x.png +0 -0
  108. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_unselected_comp.png +0 -0
  109. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/red_unselected_comp@2x.png +0 -0
  110. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/shadow.png +0 -0
  111. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/shadow@2x.png +0 -0
  112. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_selected_comp.png +0 -0
  113. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_selected_comp@2x.png +0 -0
  114. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_unselected.png +0 -0
  115. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_unselected@2x.png +0 -0
  116. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_unselected_comp.png +0 -0
  117. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps.Resources.bundle/yellow_unselected_comp@2x.png +0 -0
  118. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMEntity.h +34 -0
  119. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMGeometry.h +67 -0
  120. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMMapView.h +159 -0
  121. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMMarker.h +41 -0
  122. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMMarkerView.h +47 -0
  123. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMPushpinView.h +31 -0
  124. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMReverseGeocoder.h +63 -0
  125. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMTypes.h +25 -0
  126. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BMUserLocation.h +26 -0
  127. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/BingMaps/BingMaps.h +210 -0
  128. data/spec/support/resources/cache/base/BingMapsIOS/MapControl/libBingMaps.a +0 -0
  129. data/spec/support/resources/cache/base/BingMapsIOS/README.html +8 -0
  130. data/spec/support/resources/cache/base/DKBenchmark-Manifest/data/DKBenchmark.h +18 -0
  131. data/spec/support/resources/cache/base/DKBenchmark-Manifest/data/DKBenchmark.m +73 -0
  132. data/spec/support/resources/cache/base/DKBenchmark-Manifest/vendor.json +1 -0
  133. data/spec/support/resources/cache/base/DKBenchmark-Vendorspec/DKBenchmark.h +18 -0
  134. data/spec/support/resources/cache/base/DKBenchmark-Vendorspec/DKBenchmark.m +73 -0
  135. data/spec/support/resources/cache/base/DKBenchmark-Vendorspec/DKBenchmark.vendorspec +11 -0
  136. data/spec/support/resources/projects/TabBarWithUnitTests/TabBarWithUnitTests.xcodeproj/project.pbxproj +10 -0
  137. data/spec/support/resources/projects/UtilityApplication/UtilityApplication.xcodeproj/project.pbxproj +288 -0
  138. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAAppDelegate.h +15 -0
  139. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAAppDelegate.m +60 -0
  140. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAFlipsideViewController.h +23 -0
  141. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAFlipsideViewController.m +69 -0
  142. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAMainViewController.h +13 -0
  143. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UAMainViewController.m +75 -0
  144. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UtilityApplication-Info.plist +42 -0
  145. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/UtilityApplication-Prefix.pch +14 -0
  146. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/en.lproj/InfoPlist.strings +2 -0
  147. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/en.lproj/MainStoryboard.storyboard +90 -0
  148. data/spec/support/resources/projects/UtilityApplication/UtilityApplication/main.m +18 -0
  149. data/spec/support/resources/{files → source}/SecondViewController.h +0 -0
  150. data/spec/support/resources/{files → source}/SecondViewController.m +0 -0
  151. data/vendor.gemspec +0 -1
  152. metadata +254 -74
  153. data/LICENCE +0 -19
  154. data/lib/vendor/xcode/objects/pbx_build_file.rb +0 -9
  155. data/lib/vendor/xcode/objects/pbx_container_item_proxy.rb +0 -8
  156. data/lib/vendor/xcode/objects/pbx_file_reference.rb +0 -21
  157. data/lib/vendor/xcode/objects/pbx_frameworks_build_phase.rb +0 -9
  158. data/lib/vendor/xcode/objects/pbx_group.rb +0 -13
  159. data/lib/vendor/xcode/objects/pbx_resources_build_phase.rb +0 -7
  160. data/lib/vendor/xcode/objects/pbx_shell_script_build_phase.rb +0 -7
  161. data/lib/vendor/xcode/objects/pbx_sources_build_phase.rb +0 -9
  162. data/lib/vendor/xcode/objects/pbx_target_dependency.rb +0 -7
  163. data/lib/vendor/xcode/objects/pbx_variant_group.rb +0 -7
  164. data/lib/vendor/xcode/objects/xc_build_configuration.rb +0 -7
  165. data/lib/vendor/xcode/objects/xc_configuration_list.rb +0 -9
  166. data/spec/vendor/xcode/project_spec.rb +0 -211
@@ -1,4 +1,5 @@
1
1
  module Vendor
2
+
2
3
  module CLI
3
4
 
4
5
  module Auth
@@ -6,21 +7,21 @@ module Vendor
6
7
  extend self
7
8
 
8
9
  def api_key
9
- Vendor::Config.get(:"credentials.vendorage_api_key")
10
+ Vendor::Config.get(:"credentials.vendorforge_api_key")
10
11
  end
11
12
 
12
13
  def api_key=(value)
13
- Vendor::Config.set(:"credentials.vendorage_api_key", value)
14
+ Vendor::Config.set(:"credentials.vendorforge_api_key", value)
14
15
  end
15
16
 
16
17
  def fetch_api_key
17
- puts "Please enter your vendorage.com login and password".yellow
18
+ Vendor.ui.warn "Please enter your vendorforge.org login and password"
18
19
  printf "Login: "
19
20
  username = STDIN.gets.chomp.strip
20
21
  printf "Password: "
21
22
  password = STDIN.gets.chomp.strip
22
23
 
23
- Vendor::Config.set(:"credentials.vendorage_api_key", Vendor::API.api_key(username, password))
24
+ Vendor::Config.set(:"credentials.vendorforge_api_key", Vendor::API.api_key(username, password))
24
25
  end
25
26
 
26
27
  def with_api_key(&block)
@@ -35,4 +36,5 @@ module Vendor
35
36
  end
36
37
 
37
38
  end
39
+
38
40
  end
@@ -0,0 +1,25 @@
1
+ module Vendor
2
+
3
+ module CLI
4
+
5
+ module Console
6
+
7
+ # This reload method kinda works. It works if you change/add methods, but if you
8
+ # remove methods from a class, they still seem to hang around. I believe there is
9
+ # a fair amount of magic in rails that lets you call a reload!, but for the save
10
+ # of Vendor development, this will suffice.
11
+ def self.reload!
12
+ begin
13
+ old_verbose, $VERBOSE = $VERBOSE, nil
14
+ $".grep(/\/lib\/vendor/).each {|e| $".delete(e) && require(e) }
15
+ ensure
16
+ $VERBOSE = old_verbose
17
+ end
18
+ "Reloaded!"
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -4,7 +4,7 @@ class String
4
4
  if length == 0
5
5
  "\"\""
6
6
  else
7
- match(/\-|\s|\+|\<|\$|\"|\[|\=|\*/) ? self.inspect : self
7
+ match(/\-|\s|\+|\<|\$|\"|\[|\=|\*|@/) ? self.inspect : self
8
8
  end
9
9
  end
10
10
 
@@ -0,0 +1,55 @@
1
+ module Vendor
2
+
3
+ module Template
4
+
5
+ require 'erb'
6
+
7
+ class Locals
8
+
9
+ def initialize(options)
10
+ # Create methods for each of the options
11
+ (class << self; self; end).class_eval do
12
+ options.each_pair do |key, value|
13
+ define_method key.to_sym do
14
+ value
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def get_binding
21
+ return binding()
22
+ end
23
+
24
+ end
25
+
26
+ class << self
27
+
28
+ def copy(name, options = {})
29
+ # Where should we write this file?
30
+ file_name = options[:name] || name
31
+ target = File.join(File.expand_path(Dir.pwd), file_name)
32
+
33
+ # The template to load
34
+ template = File.join(Vendor.root, "vendor", "templates", name)
35
+
36
+ if File.exist?(target)
37
+ Vendor.ui.error "#{name} already exists at #{target}"
38
+ else
39
+ Vendor.ui.info "Writing new #{name} to #{target}"
40
+
41
+ contents = parse(File.read(template), options[:locals] || {})
42
+
43
+ File.open(target, 'w') { |f| f.write(contents) }
44
+ end
45
+ end
46
+
47
+ def parse(contents, locals)
48
+ ERB.new(contents).result(Locals.new(locals).get_binding)
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,3 @@
1
+ source :vendorforge
2
+
3
+ lib "DKBenchmark", "0.2"
@@ -0,0 +1,15 @@
1
+ # This is a generated version of the vendorspec. Please change the
2
+ # values to suit your library. Refer to the documentation for a list of
3
+ # all possible attributes.
4
+
5
+ name "<%= name %>"
6
+ version "0.1"
7
+
8
+ authors "<%= username %>"
9
+ email "<%= email %>"
10
+ homepage "HOMEPAGE GOES HERE"
11
+ description "DESCRIPTION GOES HERE"
12
+
13
+ github "GITHUB LINK GOES HERE"
14
+
15
+ files `git ls-files`.split("\n")
@@ -0,0 +1,62 @@
1
+ module Vendor
2
+
3
+ class UI
4
+
5
+ def warn(message)
6
+ end
7
+
8
+ def debug(message)
9
+ end
10
+
11
+ def error(message)
12
+ end
13
+
14
+ def info(message)
15
+ end
16
+
17
+ def success(message)
18
+ end
19
+
20
+ class Shell < UI
21
+
22
+ attr_writer :shell
23
+
24
+ def initialize(shell)
25
+ @shell = shell
26
+ @quiet = false
27
+ @debug = ENV['DEBUG']
28
+ end
29
+
30
+ def debug(msg)
31
+ @shell.say(msg) if @debug && !@quiet
32
+ end
33
+
34
+ def info(msg)
35
+ @shell.say(msg) if !@quiet
36
+ end
37
+
38
+ def success(msg)
39
+ @shell.say(msg, :green) if !@quiet
40
+ end
41
+
42
+ def warn(msg)
43
+ @shell.say(msg, :yellow)
44
+ end
45
+
46
+ def error(msg)
47
+ @shell.say(msg, :red)
48
+ end
49
+
50
+ def be_quiet!
51
+ @quiet = true
52
+ end
53
+
54
+ def debug!
55
+ @debug = true
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,12 @@
1
+ module Vendor
2
+
3
+ module VendorFile
4
+
5
+ autoload :Source, "vendor/vendor_file/source"
6
+ autoload :Loader, "vendor/vendor_file/loader"
7
+ autoload :DSL, "vendor/vendor_file/dsl"
8
+ autoload :Library, "vendor/vendor_file/library"
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,54 @@
1
+ module Vendor
2
+
3
+ module VendorFile
4
+
5
+ class DSL
6
+
7
+ class UnknownLibraryType < StandardError; end
8
+
9
+ attr_reader :sources
10
+ attr_reader :libraries
11
+
12
+ def initialize
13
+ @sources = []
14
+ @libraries = []
15
+ end
16
+
17
+ def source(source)
18
+ @sources << Vendor::VendorFile::Source.new(source)
19
+ end
20
+
21
+ def lib(name, version = nil, options = nil)
22
+ if options.nil? && version.kind_of?(Hash)
23
+ options = version
24
+ version = nil
25
+ end
26
+
27
+ klass = Vendor::VendorFile::Library::Remote
28
+
29
+ if options
30
+ if options.has_key?(:git)
31
+ klass = Vendor::VendorFile::Library::Git
32
+ elsif options.has_key?(:path)
33
+ klass = Vendor::VendorFile::Library::Local
34
+ end
35
+ end
36
+
37
+ opts = { :name => name }.merge(options || {})
38
+ opts[:targets] = @with_targets if @with_targets && !opts.has_key?(:target) && !opts.has_key?(:targets)
39
+ opts[:version] = version if version
40
+
41
+ @libraries << klass.new(opts)
42
+ end
43
+
44
+ def target(*targets, &block)
45
+ @with_targets = targets
46
+ yield
47
+ @with_targets = nil
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,16 @@
1
+ module Vendor
2
+
3
+ module VendorFile
4
+
5
+ module Library
6
+
7
+ autoload :Base, "vendor/vendor_file/library/base"
8
+ autoload :Git, "vendor/vendor_file/library/git"
9
+ autoload :Remote, "vendor/vendor_file/library/remote"
10
+ autoload :Local, "vendor/vendor_file/library/local"
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,95 @@
1
+ module Vendor
2
+
3
+ module VendorFile
4
+
5
+ module Library
6
+
7
+ class Base
8
+
9
+ attr_accessor :name
10
+ attr_accessor :targets
11
+ attr_accessor :require
12
+
13
+ def initialize(attributes = {})
14
+ @source_tree = :relative
15
+ attributes.each { |k, v| self.send("#{k}=", v) }
16
+ end
17
+
18
+ def targets=(value)
19
+ @targets = [ *value ]
20
+ end
21
+
22
+ alias :target= :targets=
23
+
24
+ def cache_path
25
+ @cache_path ||= File.join(Vendor.library_path, self.class.name.split('::').last.downcase, name)
26
+ end
27
+
28
+ def download
29
+ # Do nothing by default, leave that up to the implementation
30
+ end
31
+
32
+ def install(project)
33
+ Vendor.ui.debug "Installing #{name} into #{project} (source_tree = #{@source_tree})"
34
+
35
+ destination = "Vendor/#{name}"
36
+
37
+ # Remove the group, and recreate
38
+ project.remove_group destination
39
+
40
+ # Install the files back into the project
41
+ files.each do |file|
42
+ Vendor.ui.debug "Copying file #{file} to #{destination}"
43
+
44
+ project.add_file :targets => targets, :path => destination,
45
+ :file => file, :source_tree => @source_tree
46
+ end
47
+ end
48
+
49
+ def files
50
+ unless File.exist?(cache_path)
51
+ Vendor.ui.error "Could not find libray `#{name}` at path `#{cache_path}`"
52
+ return []
53
+ end
54
+
55
+ # Try and find a vendorspec in the cached folder
56
+ vendor_spec = Dir[File.join(cache_path, "*.vendorspec")].first
57
+
58
+ # Try and find a manifest (a built vendor file)
59
+ manifest = File.join(cache_path, "vendor.json")
60
+
61
+ # Calculate the files we need to add. There are 3 different types
62
+ # of installation:
63
+ # 1) Installation from a manifest (a built lib)
64
+ # 2) Loading the .vendorspec and seeing what files needed to be added
65
+ # 3) Try to be smart and try and find files to install
66
+ install_files = if manifest && File.exist?(manifest)
67
+
68
+ json = JSON.parse(File.read(manifest))
69
+ json['files'].map { |file| File.join(cache_path, "data", file) }
70
+
71
+ elsif vendor_spec && File.exist?(vendor_spec)
72
+
73
+ loader = Vendor::VendorSpec::Loader.new
74
+ loader.load vendor_spec
75
+ loader.dsl.files.map { |file| File.join(cache_path, file) }
76
+
77
+ else
78
+
79
+ location = [ cache_path, self.require, "**/*.*" ].compact
80
+ Dir[ File.join *location ]
81
+
82
+ end
83
+
84
+ # Remove files that are within folders with a ".", such as ".bundle"
85
+ # and ".frameworks"
86
+ install_files.reject { |file| file =~ /\/?[^\/]+\.[^\/]+\// }
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,71 @@
1
+ module Vendor
2
+ module VendorFile
3
+ module Library
4
+
5
+ require 'digest/md5'
6
+
7
+ class Git < Base
8
+
9
+ class GitError < StandardError; end
10
+
11
+ attr_accessor :uri
12
+ attr_accessor :tag
13
+
14
+ alias :branch= :tag=
15
+ alias :ref= :tag=
16
+ alias :git= :uri=
17
+
18
+ def initialize(attributes = {})
19
+ attributes[:tag] ||= attributes[:ref] || attributes[:branch] || "master"
20
+
21
+ super(attributes)
22
+ end
23
+
24
+ def download
25
+ if File.exist?(cache_path)
26
+ Vendor.ui.info "Updating #{uri}"
27
+
28
+ Dir.chdir(cache_path) do
29
+ git %|fetch --force --quiet --tags #{uri_escaped}|
30
+ end
31
+ else
32
+ Vendor.ui.info "Fetching #{uri}"
33
+
34
+ FileUtils.mkdir_p(cache_path)
35
+ git %|clone #{uri_escaped} "#{cache_path}"|
36
+ end
37
+
38
+ Dir.chdir(cache_path) do
39
+ git "reset --hard #{tag}"
40
+ end
41
+ end
42
+
43
+ # If you change the git path, and not the lib name, we want to update
44
+ # the sources correctly. So instead of using the name, use a hash of
45
+ # the URI
46
+ def cache_path
47
+ @cache_path ||= File.join(Vendor.library_path, "git", Digest::MD5.hexdigest(uri))
48
+ end
49
+
50
+ private
51
+
52
+ def git(command)
53
+ out = %x{git #{command}}
54
+
55
+ if $?.exitstatus != 0
56
+ raise GitError, "Git error: command `git #{command}` in directory #{Dir.pwd} has failed."
57
+ end
58
+ out
59
+ end
60
+
61
+ def uri_escaped
62
+ # Bash requires single quoted strings, with the single quotes escaped
63
+ # by ending the string, escaping the quote, and restarting the string.
64
+ "'" + uri.gsub("'") {|s| "'\\''"} + "'"
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+ end
71
+ end