Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Changed build setting directories parameter to files
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Aug 31, 2011
1 parent f130c61 commit 9f472c0
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 39 deletions.
3 changes: 2 additions & 1 deletion lib/bpm/package.rb
Expand Up @@ -148,7 +148,8 @@ def directory_files
dir_names.reject! { |t| t == tests_path } dir_names.reject! { |t| t == tests_path }


build_names = bpm_build.values.map do |hash| build_names = bpm_build.values.map do |hash|
hash['directories'] || hash['assets'] # Directories is deprecated
hash['files'] || hash['directories'] || hash['assets']
end end


build_names += PLUGIN_TYPES.map do |type| build_names += PLUGIN_TYPES.map do |type|
Expand Down
1 change: 0 additions & 1 deletion lib/bpm/pipeline.rb
Expand Up @@ -112,7 +112,6 @@ def magic_paths
# Returns an array of all the buildable assets in the current directory. # Returns an array of all the buildable assets in the current directory.
# These are the assets that will be built when you compile the project. # These are the assets that will be built when you compile the project.
def buildable_assets def buildable_assets

# make sure the logical_path can be used to simply build into the # make sure the logical_path can be used to simply build into the
# assets directory when we are done # assets directory when we are done
ret = project.buildable_asset_filenames mode ret = project.buildable_asset_filenames mode
Expand Down
46 changes: 26 additions & 20 deletions lib/bpm/project.rb
Expand Up @@ -135,33 +135,34 @@ def preview_root(*paths)
end end


def build_app? def build_app?
!!(bpm_build && bpm_build["bpm_libs.js"] && # Make sure we have some lib files
bpm_build["bpm_libs.js"]["directories"] && !!(bpm_build &&
bpm_build["bpm_libs.js"]["directories"].size>0) bpm_build["bpm_libs.js"] &&
((bpm_build["bpm_libs.js"]["files"] && bpm_build["bpm_libs.js"]["files"].size>0) ||
(bpm_build["bpm_libs.js"]["directories"] && bpm_build["bpm_libs.js"]["directories"].size>0)))
end end


def build_app=(value) def build_app=(value)

bpm_libs = "bpm_libs.js" bpm_libs = "bpm_libs.js"
bpm_styles = "bpm_styles.css" bpm_styles = "bpm_styles.css"


if value if value
bpm_build[bpm_libs] ||= {} bpm_build[bpm_libs] ||= {}
hash = bpm_build[bpm_libs] hash = bpm_build[bpm_libs]
hash['directories'] ||= [] hash['files'] ||= hash['directories'] || []
hash['directories'] << 'lib' if hash['directories'].size==0 hash['files'] << 'lib' if hash['files'].size==0
hash['minifier'] ||= 'uglify-js' hash['minifier'] ||= 'uglify-js'


bpm_build[bpm_styles] ||= {} bpm_build[bpm_styles] ||= {}
hash = bpm_build[bpm_styles] hash = bpm_build[bpm_styles]
hash['directories'] ||= [] hash['files'] ||= hash['directories'] || []
hash['directories'] << 'css' if hash['directories'].size==0 hash['files'] << 'css' if hash['files'].size==0


directories ||= {} directories ||= {}
directories['lib'] ||= ['app'] directories['lib'] ||= ['lib']
else else
bpm_build[bpm_libs]['directories'] = [] bpm_build[bpm_libs]['files'] = []
bpm_build[bpm_styles]['directories'] = [] bpm_build[bpm_styles]['files'] = []
end end
value value
end end
Expand Down Expand Up @@ -761,16 +762,21 @@ def has_mode(opts, mode)
## BUILD OPTIONS ## BUILD OPTIONS


def merge_build_opts(ret, dep_name, target_name, opts, mode) def merge_build_opts(ret, dep_name, target_name, opts, mode)

ret[target_name] ||= {} ret[target_name] ||= {}


if opts['assets'] if opts['assets']
ret[target_name] = opts['assets'] ret[target_name] = opts['assets']
return return
end end


if opts['directories'] && opts['directories'].size>0 if opts['directories']
ret[target_name][dep_name] = opts['directories'] warn "[DEPRECATION] Use 'files' array instead of 'directories' array in #{dep_name} config"
opts['files'] ||= []
opts['files'] += opts.delete('directories')
end

if opts['files'] && opts['files'].size>0
ret[target_name][dep_name] = opts['files']
end end


if opts['minifier'] if opts['minifier']
Expand Down Expand Up @@ -807,13 +813,13 @@ def project_settings_excludes(dep_name, target_name)


DEFAULT_BUILD_OPTS = { DEFAULT_BUILD_OPTS = {
'bpm_libs.js' => { 'bpm_libs.js' => {
'directories' => ['lib'], 'files' => ['lib'],
'modes' => ['*'] 'modes' => ['*']
}, },


'bpm_styles.css' => { 'bpm_styles.css' => {
'directories' => ['css'], 'files' => ['css'],
'modes' => ['*'] 'modes' => ['*']
} }
} }


Expand All @@ -840,8 +846,8 @@ def default_build_opts(dep_name)
} }


ret["#{dep_name}/bpm_tests.js"] = { ret["#{dep_name}/bpm_tests.js"] = {
'directories' => ['tests'], 'files' => ['tests'],
'modes' => ['debug'] 'modes' => ['debug']
} }


@default_build_opts[dep_name] = ret @default_build_opts[dep_name] = ret
Expand Down
Binary file modified spec/fixtures/gems/core-test-0.4.9.bpkg
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/fixtures/packages/core-test/package.json
Expand Up @@ -39,7 +39,7 @@


"bpm:build": { "bpm:build": {
"bpm_styles.css": { "bpm_styles.css": {
"directories": ["resources"] "files": ["resources"]
}, },


"core-test": { "core-test": {
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/projects/coffee/coffee.json
Expand Up @@ -10,7 +10,7 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": ["lib", "templates"] "files": ["lib", "templates"]
} }
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/projects/hello_world/hello_world.json
Expand Up @@ -26,15 +26,15 @@
"bpm:build": { "bpm:build": {


"hello_world/bpm_libs.js": { "hello_world/bpm_libs.js": {
"directories": ["lib", "custom"] "files": ["lib", "custom"]
}, },


"hello_world/bpm_styles.css": { "hello_world/bpm_styles.css": {
"directories": ["css"] "files": ["css"]
}, },


"hello_world/bpm_tests.js": { "hello_world/bpm_tests.js": {
"directories": ["test"] "files": ["test"]
} }
} }


Expand Down
Expand Up @@ -18,7 +18,7 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": ["lib", "not-normal"], "files": ["lib", "not-normal"],
"minifier": "uglify-js" "minifier": "uglify-js"
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/projects/init_app/new_project.json
Expand Up @@ -4,15 +4,15 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": [ "files": [
"lib" "lib"
], ],
"minifier": "uglify-js" "minifier": "uglify-js"
}, },
"bpm_styles.css": { "bpm_styles.css": {
"directories": [ "files": [
"css" "css"
] ]
} }
} }
} }
4 changes: 2 additions & 2 deletions spec/fixtures/projects/init_default/new_project.json
Expand Up @@ -4,12 +4,12 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": [], "files": [],
"minifier": "uglify-js" "minifier": "uglify-js"
}, },


"bpm_styles.css": { "bpm_styles.css": {
"directories": [] "files": []
} }
} }
} }
2 changes: 1 addition & 1 deletion spec/fixtures/projects/minitest/minitest.json
Expand Up @@ -19,7 +19,7 @@
}, },


"minitest/bpm_libs.js": { "minitest/bpm_libs.js": {
"directories": ["lib"], "files": ["lib"],
"minifier": { "uglyduck": ">= 0" }, "minifier": { "uglyduck": ">= 0" },
"uglyduck:where": "sanfran" "uglyduck:where": "sanfran"
} }
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/projects/minitrans/minitrans.json
Expand Up @@ -17,7 +17,7 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": ["lib"], "files": ["lib"],
"minifier": "uglyduck" "minifier": "uglyduck"
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -25,7 +25,7 @@ def reset_host
# Use to avoid throwing errors just because an extra newline shows up # Use to avoid throwing errors just because an extra newline shows up
# somewhere # somewhere
def normalize_whitespace(string) def normalize_whitespace(string)
string.gsub(/ +/, ' ').gsub(/\n+/,"\n") string.gsub(/ +/, ' ').gsub(/\n+/,"\n").strip
end end


def compare_file_contents(actual_path, expected_path) def compare_file_contents(actual_path, expected_path)
Expand Down
5 changes: 2 additions & 3 deletions templates/init/project.json
Expand Up @@ -4,13 +4,12 @@


"bpm:build": { "bpm:build": {
"bpm_libs.js": { "bpm_libs.js": {
"directories": [], "files": [],
"minifier": "uglify-js" "minifier": "uglify-js"
}, },


"bpm_styles.css": { "bpm_styles.css": {
"directories": [] "files": []
} }
} }
} }

0 comments on commit 9f472c0

Please sign in to comment.