示例#1
0
                        _.each(data, function(val) {

                            // Create object from keys and val
                            var d = _.object(keys, val);

                            // Setup station vars
                            station.center = {
                                lat: d.stop_lat,
                                lng: d.stop_lon
                            };
                            station.title = _.humanize(d.stop_name);
                            station.infos = _.humanize(d.stop_desc);
                            station.openDataID = d.stop_id;

                            // Check if station is not yet documented
                            var fingerPrint = station.title + '-' + station.center.lat + '-' + station.center.lng;
                            if (!duplicated[fingerPrint]) {

                                // Remember the fingerprint
                                duplicated[fingerPrint] = true;

                                // Add station to output stations array
                                stations.push(_.clone(station, true));
                                console.log(station);
                            }

                        });
  askFor: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay('Welcome to the marvelous AngularModule generator!'));
    var moduleName = _.slugify(_.humanize(path.basename(process.cwd())));

    var prompts = [
//      {
//        type: 'confirm',
//        name: 'someOption',
//        message: 'Would you like to enable this option?',
//        default: true
//      }
      {
        type: 'input',
        name: 'moduleName',
        message: 'What is the name of your module?',
        default: moduleName
      }
      ,
      {
        type: 'input',
        name: 'gitHubUsername',
        message: 'What is your GitHub username (used to set the repository in package.json)?',
        default: ''
      }
    ];

    this.prompt(prompts, function (props) {
      this.moduleName = props.moduleName;
      this.gitHubUsername = props.gitHubUsername;
      done();
    }.bind(this));
  },
示例#3
0
  constructor: function() {
    // arguments and options should be
    // defined in the constructor.
    yeoman.Base.apply(this, arguments);

    this.argument('appName', { type: String, required: false });
    this.appName = _.camelize(_.slugify(_.humanize(this.appName)));
  },
export default function() {
  this.argument('name', { type: String, required: false });

  this.lodash = _;

  var yoCheckPromise;

  // CI won't have yo installed
  if(!process.env.CI) {
    yoCheckPromise = runCmd('yo --version').then(stdout => {
      if(!semver.satisfies(semver.clean(stdout), '>= 1.7.1')) {
        throw new Error('ERROR: You need to update yo to at least 1.7.1 (npm i -g yo)');
      }
    });
  } else {
    yoCheckPromise = Promise.resolve();
  }

  try {
    this.appname = require(path.join(process.cwd(), 'bower.json')).name;
  } catch(err) {
    this.appname = path.basename(process.cwd());
  }
  this.appname = _.slugify(_.humanize(this.appname));
  this.scriptAppName = this.config.get('moduleName') || _.camelize(this.appname) + appName(this);

  this.cameledName = _.camelize(this.name);
  this.classedName = _.classify(this.name);
  this.kebabName = _.kebabCase(this.name);

  this.filters = this.config.get('filters');
  this.extensions = this.config.get('extensions');
  this.hasFilter = filter => this.filters.indexOf(filter) !== -1;
  this.hasExtension = ext => this.extensions.indexOf(ext) !== -1;

  this.scriptExt = this.hasExtension('ts') ? 'ts' : 'js';
  this.templateExt = this.hasExtension('pug') ? 'pug' : 'html';
  this.styleExt = this.hasExtension('sass') ? 'scss' :
    this.hasExtension('less') ? 'less' :
    this.hasExtension('stylus') ? 'styl' :
    'css';

  // dynamic assertion statements
  this.expect = () => this.hasFilter('expect') ? 'expect(' : '';
  this.to = () => this.hasFilter('expect') ? ').to' : '.should';

  if(typeof this.env.options.appPath === 'undefined') {
    try {
      this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath;
    } catch(err) {}
    this.env.options.appPath = this.env.options.appPath || 'app';
  }

  this.sourceRoot(path.join(__dirname, '..', '/templates'));

  return yoCheckPromise;
}
  askFor: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay('Welcome to the marvelous Foundation generator!'));
    var siteName = _.slugify(_.humanize(path.basename(process.cwd())));

    var prompts = [
      {
        type: 'input',
        name: 'siteName',
        message: 'What is the name of your site?',
        default: siteName
      }
      ,
      {
        type: 'input',
        name: 'rubyGemSet',
        message: 'What ruby gemset do you want to use for this project?',
        default: siteName
      }
      ,
      {
        type: 'confirm',
        name: 'useCompass',
        message: 'Would you like to use the Compass extension for Sass?',
        default: false
      }
      ,
      {
        type: 'input',
        name: 'gitHubUsername',
        message: 'What is your GitHub username (used to set the repository in package.json)?',
        default: ''
      }
    ];

    this.prompt(prompts, function (props) {
      this.siteName = props.siteName;
      this.rubyGemSet = props.rubyGemSet;
      this.useCompass = props.useCompass;
//      console.log(this.useCompass);
      this.gitHubUsername = props.gitHubUsername;
      done();
    }.bind(this));
  },
 this.prompt( prompts, ( { app } ) => {
   this.app = app;
   this.appname = _.camelize( _.slugify( _.humanize( app ) ) );
   // resolve
   done();
 } );
示例#7
0
 return this.prompt(prompts).then(function(answers) {
   this.answers = answers;
   this.answers.appname = _.camelize(_.slugify(_.humanize(this.answers.app)));
 }.bind(this));