/// <summary>
        /// Converts C# and VB.NET files to Ruby and saves the files.
        /// </summary>
        protected override void ConvertFile(FileProjectItem sourceItem, FileProjectItem targetItem)
        {
            ParseInformation          parseInfo = GetParseInfo(sourceItem.FileName);
            NRefactoryToRubyConverter converter = NRefactoryToRubyConverter.Create(sourceItem.Include, parseInfo);

            if (converter != null)
            {
                targetItem.Include = ChangeExtension(sourceItem.Include);

                string code     = GetParseableFileContent(sourceItem.FileName);
                string rubyCode = converter.Convert(code);

                RubyProject rubyTargetProject = (RubyProject)targetItem.Project;
                if ((converter.EntryPointMethods.Count > 0) && !rubyTargetProject.HasMainFile)
                {
                    rubyTargetProject.AddMainFile(targetItem.Include);
                    // Add code to call main method at the end of the file.
                    rubyCode += "\r\n\r\n" + converter.GenerateMainMethodCall(converter.EntryPointMethods[0]);
                }

                SaveFile(targetItem.FileName, rubyCode, textEditorProperties.Encoding);
            }
            else
            {
                LanguageConverterConvertFile(sourceItem, targetItem);
            }
        }
		public void SetUpFixture()
		{
			RubyMSBuildEngineHelper.InitMSBuildEngine();

			List<ProjectBindingDescriptor> bindings = new List<ProjectBindingDescriptor>();
			using (TextReader reader = RubyBindingAddInFile.ReadAddInFile()) {
				AddIn addin = AddIn.Load(reader, String.Empty);
				bindings.Add(new ProjectBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/ProjectBindings", "Ruby")));
			}
			ProjectBindingService.SetBindings(bindings);
			
			convertProjectCommand = new DerivedConvertProjectToRubyProjectCommand();
			parseInfo = new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent()));
			convertProjectCommand.ParseInfo = parseInfo;
			convertProjectCommand.FileServiceDefaultEncoding = Encoding.Unicode;
			
			sourceProject = new MockProject();
			sourceProject.Directory = @"d:\projects\test";
			source = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Program.cs");
			targetProject = (RubyProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
			target = new FileProjectItem(targetProject, source.ItemType, source.Include);
			source.CopyMetadataTo(target);
			
			textFileSource = new FileProjectItem(sourceProject, ItemType.None, @"src\readme.txt");
			textFileTarget = new FileProjectItem(targetProject, textFileSource.ItemType, textFileSource.Include);
			textFileSource.CopyMetadataTo(textFileTarget);
			
			convertProjectCommand.AddParseableFileContent(source.FileName, sourceCode);
			
			convertProjectCommand.CallConvertFile(source, target);
			convertProjectCommand.CallConvertFile(textFileSource, textFileTarget);
		}
		public void SetUpFixture()
		{
			projectBinding = new RubyProjectBinding();
			ProjectCreateInformation createInfo = new ProjectCreateInformation();
			createInfo.ProjectName = "Ruby";
			createInfo.OutputProjectFileName = @"C:\Projects\Ruby.rbproj";
			createInfo.Solution = new Solution();
			project = projectBinding.CreateProject(createInfo) as RubyProject;
		}
		public void IsTestProjectWhenPassedRubyPythonProjectReturnsTrue()
		{
			ProjectCreateInformation createInfo = new ProjectCreateInformation();
			createInfo.Solution = new Solution(new MockProjectChangeWatcher());
			createInfo.OutputProjectFileName = @"C:\projects\test.rbproj";
			RubyProject project = new RubyProject(createInfo);
			
			Assert.IsTrue(testFramework.IsTestProject(project));
		}
		public void SetUpFixture()
		{
			info = new ProjectCreateInformation();
			info.Solution = new Solution(new MockProjectChangeWatcher());
			info.ProjectName = "Test";
			info.OutputProjectFileName = @"C:\Projects\Test\Test.rbproj";
			info.RootNamespace = "Test";

			project = new RubyProject(info);
		}
Example #6
0
		public RubyProjectBehavior(RubyProject project, ProjectBehavior next = null)
			: base(project, next)
		{
			
		}
		public void CanParseRubyProject()
		{
			ProjectCreateInformation createInfo = new ProjectCreateInformation();
			createInfo.Solution = new Solution(new MockProjectChangeWatcher());
			createInfo.OutputProjectFileName = @"C:\projects\test.rbproj";
			RubyProject project = new RubyProject(createInfo);
			Assert.IsTrue(parser.CanParse(project));
		}
Example #8
0
 public RubyProjectBehavior(RubyProject project, ProjectBehavior next = null)
     : base(project, next)
 {
 }
        /// <summary>
        /// Creates an RubyProject.
        /// </summary>
        protected override IProject CreateProject(string targetProjectDirectory, IProject sourceProject)
        {
            RubyProject targetProject = (RubyProject)base.CreateProject(targetProjectDirectory, sourceProject);

            return(targetProject);
        }